arch/csky/include/asm/asid.h
Source file repositories/reference/linux-study-clean/arch/csky/include/asm/asid.h
File Facts
- System
- Linux kernel
- Corpus path
arch/csky/include/asm/asid.h- Extension
.h- Size
- 2440 bytes
- Lines
- 79
- Domain
- Architecture Layer
- Bucket
- arch/csky
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/compiler.hlinux/cpumask.hlinux/percpu.hlinux/spinlock.h
Detected Declarations
struct asid_infofunction asid_check_context
Annotated Snippet
#ifndef __ASM_ASM_ASID_H
#define __ASM_ASM_ASID_H
#include <linux/atomic.h>
#include <linux/compiler.h>
#include <linux/cpumask.h>
#include <linux/percpu.h>
#include <linux/spinlock.h>
struct asid_info
{
atomic64_t generation;
unsigned long *map;
atomic64_t __percpu *active;
u64 __percpu *reserved;
u32 bits;
/* Lock protecting the structure */
raw_spinlock_t lock;
/* Which CPU requires context flush on next call */
cpumask_t flush_pending;
/* Number of ASID allocated by context (shift value) */
unsigned int ctxt_shift;
/* Callback to locally flush the context. */
void (*flush_cpu_ctxt_cb)(void);
};
#define NUM_ASIDS(info) (1UL << ((info)->bits))
#define NUM_CTXT_ASIDS(info) (NUM_ASIDS(info) >> (info)->ctxt_shift)
#define active_asid(info, cpu) *per_cpu_ptr((info)->active, cpu)
void asid_new_context(struct asid_info *info, atomic64_t *pasid,
unsigned int cpu, struct mm_struct *mm);
/*
* Check the ASID is still valid for the context. If not generate a new ASID.
*
* @pasid: Pointer to the current ASID batch
* @cpu: current CPU ID. Must have been acquired through get_cpu()
*/
static inline void asid_check_context(struct asid_info *info,
atomic64_t *pasid, unsigned int cpu,
struct mm_struct *mm)
{
u64 asid, old_active_asid;
asid = atomic64_read(pasid);
/*
* The memory ordering here is subtle.
* If our active_asid is non-zero and the ASID matches the current
* generation, then we update the active_asid entry with a relaxed
* cmpxchg. Racing with a concurrent rollover means that either:
*
* - We get a zero back from the cmpxchg and end up waiting on the
* lock. Taking the lock synchronises with the rollover and so
* we are forced to see the updated generation.
*
* - We get a valid ASID back from the cmpxchg, which means the
* relaxed xchg in flush_context will treat us as reserved
* because atomic RmWs are totally ordered for a given location.
*/
old_active_asid = atomic64_read(&active_asid(info, cpu));
if (old_active_asid &&
!((asid ^ atomic64_read(&info->generation)) >> info->bits) &&
atomic64_cmpxchg_relaxed(&active_asid(info, cpu),
old_active_asid, asid))
return;
asid_new_context(info, pasid, cpu, mm);
}
int asid_allocator_init(struct asid_info *info,
u32 bits, unsigned int asid_per_ctxt,
void (*flush_cpu_ctxt_cb)(void));
#endif
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/compiler.h`, `linux/cpumask.h`, `linux/percpu.h`, `linux/spinlock.h`.
- Detected declarations: `struct asid_info`, `function asid_check_context`.
- Atlas domain: Architecture Layer / arch/csky.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.