mm/numa.c
Source file repositories/reference/linux-study-clean/mm/numa.c
File Facts
- System
- Linux kernel
- Corpus path
mm/numa.c- Extension
.c- Size
- 1592 bytes
- Lines
- 62
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/memblock.hlinux/printk.hlinux/numa.hlinux/numa_memblks.h
Detected Declarations
function alloc_node_datafunction alloc_offline_node_datafunction memory_add_physaddr_to_nidfunction phys_to_target_nodeexport node_dataexport memory_add_physaddr_to_nidexport phys_to_target_node
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/memblock.h>
#include <linux/printk.h>
#include <linux/numa.h>
#include <linux/numa_memblks.h>
struct pglist_data *node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);
/* Allocate NODE_DATA for a node on the local memory */
void __init alloc_node_data(int nid)
{
const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES);
u64 nd_pa;
int tnid;
/* Allocate node data. Try node-local memory and then any node. */
nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid);
if (!nd_pa)
panic("Cannot allocate %zu bytes for node %d data\n",
nd_size, nid);
/* report and initialize */
pr_info("NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid,
nd_pa, nd_pa + nd_size - 1);
tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT);
if (tnid != nid)
pr_info(" NODE_DATA(%d) on node %d\n", nid, tnid);
node_data[nid] = __va(nd_pa);
memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
}
void __init alloc_offline_node_data(int nid)
{
pg_data_t *pgdat;
node_data[nid] = memblock_alloc_or_panic(sizeof(*pgdat), SMP_CACHE_BYTES);
}
/* Stub functions: */
#ifndef memory_add_physaddr_to_nid
int memory_add_physaddr_to_nid(u64 start)
{
pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n",
start);
return 0;
}
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
#endif
#ifndef phys_to_target_node
int phys_to_target_node(u64 start)
{
pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n",
start);
return 0;
}
EXPORT_SYMBOL_GPL(phys_to_target_node);
#endif
Annotation
- Immediate include surface: `linux/memblock.h`, `linux/printk.h`, `linux/numa.h`, `linux/numa_memblks.h`.
- Detected declarations: `function alloc_node_data`, `function alloc_offline_node_data`, `function memory_add_physaddr_to_nid`, `function phys_to_target_node`, `export node_data`, `export memory_add_physaddr_to_nid`, `export phys_to_target_node`.
- Atlas domain: Core OS / Memory Management.
- 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.