arch/x86/mm/numa.c
Source file repositories/reference/linux-study-clean/arch/x86/mm/numa.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/mm/numa.c- Extension
.c- Size
- 10838 bytes
- Lines
- 465
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/kernel.hlinux/mm.hlinux/of.hlinux/string.hlinux/init.hlinux/memblock.hlinux/mmzone.hlinux/ctype.hlinux/nodemask.hlinux/sched.hlinux/topology.hlinux/sort.hlinux/numa_memblks.hasm/e820/api.hasm/proto.hasm/dma.hasm/numa.hasm/amd/nb.hmm_internal.h
Detected Declarations
function numa_setupfunction numa_cpu_nodefunction num_phys_nodesfunction numa_set_nodefunction numa_clear_nodefunction setup_node_to_cpumask_mapfunction numa_register_nodesfunction numa_init_arrayfunction numa_initfunction dummy_numa_initfunction x86_numa_initfunction init_cpu_to_nodefunction for_each_possible_cpufunction numa_add_cpufunction numa_remove_cpufunction __cpu_to_nodefunction cpu_to_nodefunction debug_cpumask_set_cpufunction numa_set_cpumaskfunction numa_add_cpufunction numa_remove_cpufunction numa_emu_update_cpu_to_nodefunction numa_emu_dma_endexport node_to_cpumask_mapexport __cpu_to_nodeexport cpumask_of_node
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Common code for 32 and 64-bit NUMA */
#include <linux/acpi.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/of.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/memblock.h>
#include <linux/mmzone.h>
#include <linux/ctype.h>
#include <linux/nodemask.h>
#include <linux/sched.h>
#include <linux/topology.h>
#include <linux/sort.h>
#include <linux/numa_memblks.h>
#include <asm/e820/api.h>
#include <asm/proto.h>
#include <asm/dma.h>
#include <asm/numa.h>
#include <asm/amd/nb.h>
#include "mm_internal.h"
int numa_off;
static __init int numa_setup(char *opt)
{
if (!opt)
return -EINVAL;
if (!strncmp(opt, "off", 3))
numa_off = 1;
if (!strncmp(opt, "fake=", 5))
return numa_emu_cmdline(opt + 5);
if (!strncmp(opt, "noacpi", 6))
disable_srat();
if (!strncmp(opt, "nohmat", 6))
disable_hmat();
return 0;
}
early_param("numa", numa_setup);
/*
* apicid, cpu, node mappings
*/
s16 __apicid_to_node[MAX_LOCAL_APIC] = {
[0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
};
nodemask_t numa_phys_nodes_parsed __initdata;
int numa_cpu_node(int cpu)
{
u32 apicid = early_per_cpu(x86_cpu_to_apicid, cpu);
if (apicid != BAD_APICID)
return __apicid_to_node[apicid];
return NUMA_NO_NODE;
}
int __init num_phys_nodes(void)
{
return bitmap_weight(numa_phys_nodes_parsed.bits, MAX_NUMNODES);
}
cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
EXPORT_SYMBOL(node_to_cpumask_map);
/*
* Map cpu index to node index
*/
DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE);
EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map);
void numa_set_node(int cpu, int node)
{
int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map);
/* early setting, no percpu area yet */
if (cpu_to_node_map) {
cpu_to_node_map[cpu] = node;
return;
}
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) {
printk(KERN_ERR "numa_set_node: invalid cpu# (%d)\n", cpu);
dump_stack();
return;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/kernel.h`, `linux/mm.h`, `linux/of.h`, `linux/string.h`, `linux/init.h`, `linux/memblock.h`, `linux/mmzone.h`.
- Detected declarations: `function numa_setup`, `function numa_cpu_node`, `function num_phys_nodes`, `function numa_set_node`, `function numa_clear_node`, `function setup_node_to_cpumask_map`, `function numa_register_nodes`, `function numa_init_array`, `function numa_init`, `function dummy_numa_init`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration 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.