arch/loongarch/vdso/vgetcpu.c
Source file repositories/reference/linux-study-clean/arch/loongarch/vdso/vgetcpu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/vdso/vgetcpu.c- Extension
.c- Size
- 691 bytes
- Lines
- 45
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- 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.
Dependency Surface
asm/vdso.h
Detected Declarations
function getcpufunction __vdso_getcpu
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Fast user context implementation of getcpu()
*/
#include <asm/vdso.h>
static __always_inline int read_cpu_id(void)
{
int cpu_id;
#ifdef CONFIG_64BIT
__asm__ __volatile__(
" rdtime.d $zero, %0\n"
: "=r" (cpu_id)
:
: "memory");
#else
__asm__ __volatile__(
" rdtimel.w $zero, %0\n"
: "=r" (cpu_id)
:
: "memory");
#endif
return cpu_id;
}
extern
int __vdso_getcpu(unsigned int *cpu, unsigned int *node, void *unused);
int __vdso_getcpu(unsigned int *cpu, unsigned int *node, void *unused)
{
int cpu_id;
cpu_id = read_cpu_id();
if (cpu)
*cpu = cpu_id;
if (node)
*node = vdso_u_arch_data.pdata[cpu_id].node;
return 0;
}
Annotation
- Immediate include surface: `asm/vdso.h`.
- Detected declarations: `function getcpu`, `function __vdso_getcpu`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.