arch/x86/include/asm/topology.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/topology.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/topology.h- Extension
.h- Size
- 9442 bytes
- Lines
- 340
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/numa.hlinux/cpumask.hasm/mpspec.hasm/percpu.hasm-generic/topology.hlinux/cpu_smt.hlinux/cache.hasm/cpufeature.h
Detected Declarations
struct x86_topology_systemstruct cpuinfo_x86struct pci_busenum x86_topology_domainsenum x86_topology_cpu_typefunction early_cpu_to_nodefunction numa_node_idfunction early_cpu_to_nodefunction setup_node_to_cpumask_mapfunction topology_get_domain_sizefunction topology_get_domain_shiftfunction topology_max_packagesfunction topology_max_dies_per_packagefunction topology_num_cores_per_packagefunction topology_num_threads_per_packagefunction topology_num_nodes_per_packagefunction topology_get_logical_idfunction topology_phys_to_logical_pkgfunction topology_max_smt_threadsfunction topology_amd_nodes_per_pkgfunction topology_phys_to_logical_pkgfunction topology_max_smt_threadsfunction topology_amd_nodes_per_pkgfunction topology_is_primary_threadfunction topology_is_core_onlinefunction arch_fix_phys_package_idfunction sched_set_itmt_core_priofunction sched_clear_itmt_supportfunction arch_scale_freq_capacityfunction arch_enable_hybrid_capacity_scalefunction arch_set_cpu_capacity
Annotated Snippet
struct x86_topology_system {
unsigned int dom_shifts[TOPO_MAX_DOMAIN];
unsigned int dom_size[TOPO_MAX_DOMAIN];
};
extern struct x86_topology_system x86_topo_system;
static inline unsigned int topology_get_domain_size(enum x86_topology_domains dom)
{
return x86_topo_system.dom_size[dom];
}
static inline unsigned int topology_get_domain_shift(enum x86_topology_domains dom)
{
return dom == TOPO_SMT_DOMAIN ? 0 : x86_topo_system.dom_shifts[dom - 1];
}
extern const struct cpumask *cpu_coregroup_mask(int cpu);
extern const struct cpumask *cpu_clustergroup_mask(int cpu);
#define topology_logical_package_id(cpu) (cpu_data(cpu).topo.logical_pkg_id)
#define topology_physical_package_id(cpu) (cpu_data(cpu).topo.pkg_id)
#define topology_logical_die_id(cpu) (cpu_data(cpu).topo.logical_die_id)
#define topology_logical_core_id(cpu) (cpu_data(cpu).topo.logical_core_id)
#define topology_die_id(cpu) (cpu_data(cpu).topo.die_id)
#define topology_core_id(cpu) (cpu_data(cpu).topo.core_id)
#define topology_ppin(cpu) (cpu_data(cpu).ppin)
#define topology_amd_node_id(cpu) (cpu_data(cpu).topo.amd_node_id)
extern unsigned int __max_dies_per_package;
extern unsigned int __max_logical_packages;
extern unsigned int __max_threads_per_core;
extern unsigned int __num_threads_per_package;
extern unsigned int __num_cores_per_package;
extern unsigned int __num_nodes_per_package;
struct cpuinfo_x86;
const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
static inline unsigned int topology_max_packages(void)
{
return __max_logical_packages;
}
static inline unsigned int topology_max_dies_per_package(void)
{
return __max_dies_per_package;
}
static inline unsigned int topology_num_cores_per_package(void)
{
return __num_cores_per_package;
}
static inline unsigned int topology_num_threads_per_package(void)
{
return __num_threads_per_package;
}
static inline unsigned int topology_num_nodes_per_package(void)
{
return __num_nodes_per_package;
}
#ifdef CONFIG_X86_LOCAL_APIC
int topology_get_logical_id(u32 apicid, enum x86_topology_domains at_level);
#else
static inline int topology_get_logical_id(u32 apicid, enum x86_topology_domains at_level)
{
return 0;
}
#endif
#ifdef CONFIG_SMP
#define topology_cluster_id(cpu) (cpu_data(cpu).topo.l2c_id)
#define topology_die_cpumask(cpu) (per_cpu(cpu_die_map, cpu))
#define topology_cluster_cpumask(cpu) (cpu_clustergroup_mask(cpu))
#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
#define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
static inline int topology_phys_to_logical_pkg(unsigned int pkg)
{
return topology_get_logical_id(pkg << x86_topo_system.dom_shifts[TOPO_PKG_DOMAIN],
TOPO_PKG_DOMAIN);
}
Annotation
- Immediate include surface: `linux/numa.h`, `linux/cpumask.h`, `asm/mpspec.h`, `asm/percpu.h`, `asm-generic/topology.h`, `linux/cpu_smt.h`, `linux/cache.h`, `asm/cpufeature.h`.
- Detected declarations: `struct x86_topology_system`, `struct cpuinfo_x86`, `struct pci_bus`, `enum x86_topology_domains`, `enum x86_topology_cpu_type`, `function early_cpu_to_node`, `function numa_node_id`, `function early_cpu_to_node`, `function setup_node_to_cpumask_map`, `function topology_get_domain_size`.
- 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.