arch/x86/include/asm/percpu.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/percpu.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/percpu.h- Extension
.h- Size
- 23054 bytes
- Lines
- 664
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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
linux/args.hlinux/bits.hlinux/build_bug.hlinux/stringify.hasm/asm.hasm-generic/percpu.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#ifndef _ASM_X86_PERCPU_H
#define _ASM_X86_PERCPU_H
#ifdef CONFIG_X86_64
# define __percpu_seg gs
# define __percpu_rel (%rip)
#else
# define __percpu_seg fs
# define __percpu_rel
#endif
#ifdef __ASSEMBLER__
#ifdef CONFIG_SMP
# define __percpu %__percpu_seg:
#else
# define __percpu
#endif
#define PER_CPU_VAR(var) __percpu(var)__percpu_rel
#else /* !__ASSEMBLER__: */
#include <linux/args.h>
#include <linux/bits.h>
#include <linux/build_bug.h>
#include <linux/stringify.h>
#include <asm/asm.h>
#ifdef CONFIG_SMP
#define __force_percpu_prefix "%%"__stringify(__percpu_seg)":"
#ifdef CONFIG_CC_HAS_NAMED_AS
#ifdef __CHECKER__
# define __seg_gs __attribute__((address_space(__seg_gs)))
# define __seg_fs __attribute__((address_space(__seg_fs)))
#endif
#define __percpu_prefix
#else /* !CONFIG_CC_HAS_NAMED_AS: */
#define __percpu_prefix __force_percpu_prefix
#endif /* CONFIG_CC_HAS_NAMED_AS */
/*
* Compared to the generic __my_cpu_offset version, the following
* saves one instruction and avoids clobbering a temp register.
*/
#define __my_cpu_offset this_cpu_read(this_cpu_off)
/*
* arch_raw_cpu_ptr should not be used in 32-bit VDSO for a 64-bit
* kernel, because games are played with CONFIG_X86_64 there and
* sizeof(this_cpu_off) becames 4.
*/
#ifndef BUILD_VDSO32_64
#define arch_raw_cpu_ptr(_ptr) \
({ \
unsigned long tcp_ptr__ = raw_cpu_read_long(this_cpu_off); \
\
tcp_ptr__ += (__force unsigned long)(_ptr); \
(TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)tcp_ptr__; \
})
#else
#define arch_raw_cpu_ptr(_ptr) \
({ \
BUILD_BUG(); \
(TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)0; \
})
#endif
#define PER_CPU_VAR(var) %__percpu_seg:(var)__percpu_rel
#else /* !CONFIG_SMP: */
#define __force_percpu_prefix
#define __percpu_prefix
#define PER_CPU_VAR(var) (var)__percpu_rel
#endif /* CONFIG_SMP */
#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(USE_TYPEOF_UNQUAL)
# define __my_cpu_type(var) typeof(var)
# define __my_cpu_ptr(ptr) (ptr)
# define __my_cpu_var(var) (var)
Annotation
- Immediate include surface: `linux/args.h`, `linux/bits.h`, `linux/build_bug.h`, `linux/stringify.h`, `asm/asm.h`, `asm-generic/percpu.h`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.