drivers/base/arch_numa.c
Source file repositories/reference/linux-study-clean/drivers/base/arch_numa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/arch_numa.c- Extension
.c- Size
- 8520 bytes
- Lines
- 380
- Domain
- Driver Families
- Bucket
- drivers/base
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/memblock.hlinux/module.hlinux/of.hlinux/numa_memblks.hasm/sections.h
Detected Declarations
function numa_parse_early_paramfunction numa_update_cpufunction numa_add_cpufunction numa_remove_cpufunction numa_clear_nodefunction setup_node_to_cpumask_mapfunction numa_store_cpu_infofunction early_map_cpu_to_nodefunction early_cpu_to_nodefunction pcpu_cpu_distancefunction setup_per_cpu_areasfunction setup_node_datafunction numa_register_nodesfunction numa_initfunction dummy_numa_initfunction arch_acpi_numa_initfunction arch_acpi_numa_initfunction arch_numa_initfunction numa_emu_update_cpu_to_nodefunction numa_emu_dma_endfunction debug_cpumask_set_cpuexport node_to_cpumask_mapexport cpumask_of_nodeexport __per_cpu_offset
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* NUMA support, based on the x86 implementation.
*
* Copyright (C) 2015 Cavium Inc.
* Author: Ganapatrao Kulkarni <gkulkarni@cavium.com>
*/
#define pr_fmt(fmt) "NUMA: " fmt
#include <linux/acpi.h>
#include <linux/memblock.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/numa_memblks.h>
#include <asm/sections.h>
static int cpu_to_node_map[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE };
bool numa_off;
static __init int numa_parse_early_param(char *opt)
{
if (!opt)
return -EINVAL;
if (str_has_prefix(opt, "off"))
numa_off = true;
if (!strncmp(opt, "fake=", 5))
return numa_emu_cmdline(opt + 5);
return 0;
}
early_param("numa", numa_parse_early_param);
cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
EXPORT_SYMBOL(node_to_cpumask_map);
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
/*
* Returns a pointer to the bitmask of CPUs on Node 'node'.
*/
const struct cpumask *cpumask_of_node(int node)
{
if (node == NUMA_NO_NODE)
return cpu_all_mask;
if (WARN_ON(node < 0 || node >= nr_node_ids))
return cpu_none_mask;
if (WARN_ON(node_to_cpumask_map[node] == NULL))
return cpu_online_mask;
return node_to_cpumask_map[node];
}
EXPORT_SYMBOL(cpumask_of_node);
#endif
#ifndef CONFIG_NUMA_EMU
static void numa_update_cpu(unsigned int cpu, bool remove)
{
int nid = cpu_to_node(cpu);
if (nid == NUMA_NO_NODE)
return;
if (remove)
cpumask_clear_cpu(cpu, node_to_cpumask_map[nid]);
else
cpumask_set_cpu(cpu, node_to_cpumask_map[nid]);
}
void numa_add_cpu(unsigned int cpu)
{
numa_update_cpu(cpu, false);
}
void numa_remove_cpu(unsigned int cpu)
{
numa_update_cpu(cpu, true);
}
#endif
void numa_clear_node(unsigned int cpu)
{
numa_remove_cpu(cpu);
set_cpu_numa_node(cpu, NUMA_NO_NODE);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/memblock.h`, `linux/module.h`, `linux/of.h`, `linux/numa_memblks.h`, `asm/sections.h`.
- Detected declarations: `function numa_parse_early_param`, `function numa_update_cpu`, `function numa_add_cpu`, `function numa_remove_cpu`, `function numa_clear_node`, `function setup_node_to_cpumask_map`, `function numa_store_cpu_info`, `function early_map_cpu_to_node`, `function early_cpu_to_node`, `function pcpu_cpu_distance`.
- Atlas domain: Driver Families / drivers/base.
- 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.