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.

Dependency Surface

Detected Declarations

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

Implementation Notes