drivers/base/node.c
Source file repositories/reference/linux-study-clean/drivers/base/node.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/node.c- Extension
.c- Size
- 26971 bytes
- Lines
- 1019
- Domain
- Driver Families
- Bucket
- drivers/base
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/mm.hlinux/memory.hlinux/mempolicy.hlinux/vmstat.hlinux/notifier.hlinux/node.hlinux/hugetlb.hlinux/compaction.hlinux/cpumask.hlinux/topology.hlinux/nodemask.hlinux/cpu.hlinux/device.hlinux/pm_runtime.hlinux/swap.hlinux/slab.hlinux/memblock.h
Detected Declarations
struct node_access_nodesstruct node_cache_infostruct node_attrfunction cpumap_readfunction cpulist_readfunction register_node_notifierfunction unregister_node_notifierfunction node_notifyfunction node_remove_accessesfunction list_for_each_entry_safefunction node_access_releasefunction node_set_perf_attrsfunction node_update_perf_attrsfunction node_cache_releasefunction node_cacheinfo_releasefunction node_init_cache_devfunction node_add_cachefunction node_remove_cachesfunction list_for_each_entry_safefunction node_init_cachesfunction node_init_cachesfunction node_read_numastatfunction node_read_vmstatfunction node_read_distancefunction for_each_online_nodefunction node_device_releasefunction register_cpu_under_nodefunction register_memory_node_under_compute_nodefunction unregister_cpu_under_nodefunction do_register_memory_block_under_nodefunction register_mem_block_under_node_hotplugfunction unregister_memory_block_under_nodesfunction register_memory_blocks_under_nodesfunction for_each_mem_regionfunction register_memory_blocks_under_node_hotplugfunction register_nodefunction unregister_nodefunction show_node_statefunction node_dev_initexport register_node_notifierexport unregister_node_notifierexport node_set_perf_attrsexport node_update_perf_attrs
Annotated Snippet
static const struct bus_type node_subsys = {
.name = "node",
.dev_name = "node",
};
static inline ssize_t cpumap_read(struct file *file, struct kobject *kobj,
const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
struct device *dev = kobj_to_dev(kobj);
struct node *node_dev = to_node(dev);
cpumask_var_t mask;
ssize_t n;
if (!alloc_cpumask_var(&mask, GFP_KERNEL))
return 0;
cpumask_and(mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask);
n = cpumap_print_bitmask_to_buf(buf, mask, off, count);
free_cpumask_var(mask);
return n;
}
static const BIN_ATTR_RO(cpumap, CPUMAP_FILE_MAX_BYTES);
static inline ssize_t cpulist_read(struct file *file, struct kobject *kobj,
const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
struct device *dev = kobj_to_dev(kobj);
struct node *node_dev = to_node(dev);
cpumask_var_t mask;
ssize_t n;
if (!alloc_cpumask_var(&mask, GFP_KERNEL))
return 0;
cpumask_and(mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask);
n = cpumap_print_list_to_buf(buf, mask, off, count);
free_cpumask_var(mask);
return n;
}
static const BIN_ATTR_RO(cpulist, CPULIST_FILE_MAX_BYTES);
/**
* struct node_access_nodes - Access class device to hold user visible
* relationships to other nodes.
* @dev: Device for this memory access class
* @list_node: List element in the node's access list
* @access: The access class rank
* @coord: Heterogeneous memory performance coordinates
*/
struct node_access_nodes {
struct device dev;
struct list_head list_node;
unsigned int access;
#ifdef CONFIG_HMEM_REPORTING
struct access_coordinate coord;
#endif
};
#define to_access_nodes(dev) container_of(dev, struct node_access_nodes, dev)
static struct attribute *node_init_access_node_attrs[] = {
NULL,
};
static struct attribute *node_targ_access_node_attrs[] = {
NULL,
};
static const struct attribute_group initiators = {
.name = "initiators",
.attrs = node_init_access_node_attrs,
};
static const struct attribute_group targets = {
.name = "targets",
.attrs = node_targ_access_node_attrs,
};
static const struct attribute_group *node_access_node_groups[] = {
&initiators,
&targets,
NULL,
};
#ifdef CONFIG_MEMORY_HOTPLUG
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/mm.h`, `linux/memory.h`, `linux/mempolicy.h`, `linux/vmstat.h`, `linux/notifier.h`, `linux/node.h`.
- Detected declarations: `struct node_access_nodes`, `struct node_cache_info`, `struct node_attr`, `function cpumap_read`, `function cpulist_read`, `function register_node_notifier`, `function unregister_node_notifier`, `function node_notify`, `function node_remove_accesses`, `function list_for_each_entry_safe`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: pattern 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.