include/linux/memory.h
Source file repositories/reference/linux-study-clean/include/linux/memory.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/memory.h- Extension
.h- Size
- 6940 bytes
- Lines
- 215
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/node.hlinux/compiler.hlinux/mutex.hlinux/memory_hotplug.h
Detected Declarations
struct memory_groupstruct memory_blockstruct memory_notifystruct notifier_blockstruct mem_sectionenum memory_block_statefunction memory_dev_initfunction register_memory_notifierfunction unregister_memory_notifierfunction hotplug_memory_notifierfunction memory_block_advise_max_sizefunction memory_block_advised_max_sizefunction memory_block_putfunction memory_block_idfunction pfn_to_block_idfunction phys_to_block_id
Annotated Snippet
struct memory_group {
int nid;
struct list_head memory_blocks;
unsigned long present_kernel_pages;
unsigned long present_movable_pages;
bool is_dynamic;
union {
struct {
unsigned long max_pages;
} s;
struct {
unsigned long unit_pages;
} d;
};
};
enum memory_block_state {
/* These states are exposed to userspace as text strings in sysfs */
MEM_ONLINE, /* exposed to userspace */
MEM_GOING_OFFLINE, /* exposed to userspace */
MEM_OFFLINE, /* exposed to userspace */
MEM_GOING_ONLINE,
MEM_CANCEL_ONLINE,
MEM_CANCEL_OFFLINE,
};
struct memory_block {
unsigned long start_section_nr;
enum memory_block_state state; /* serialized by the dev->lock */
enum mmop online_type; /* for passing data to online routine */
int nid; /* NID for this memory block */
/*
* The single zone of this memory block if all PFNs of this memory block
* that are System RAM (not a memory hole, not ZONE_DEVICE ranges) are
* managed by a single zone. NULL if multiple zones (including nodes)
* apply.
*/
struct zone *zone;
struct device dev;
struct vmem_altmap *altmap;
struct memory_group *group; /* group (if any) for this block */
struct list_head group_next; /* next block inside memory group */
#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
atomic_long_t nr_hwpoison;
#endif
};
int arch_get_memory_phys_device(unsigned long start_pfn);
unsigned long memory_block_size_bytes(void);
int set_memory_block_size_order(unsigned int order);
struct memory_notify {
unsigned long start_pfn;
unsigned long nr_pages;
};
struct notifier_block;
struct mem_section;
/*
* Priorities for the hotplug memory callback routines. Invoked from
* high to low. Higher priorities correspond to higher numbers.
*/
#define DEFAULT_CALLBACK_PRI 0
#define SLAB_CALLBACK_PRI 1
#define CXL_CALLBACK_PRI 5
#define HMAT_CALLBACK_PRI 6
#define MM_COMPUTE_BATCH_PRI 10
#define CPUSET_CALLBACK_PRI 10
#define MEMTIER_HOTPLUG_PRI 100
#define KSM_CALLBACK_PRI 100
#ifndef CONFIG_MEMORY_HOTPLUG
static inline void memory_dev_init(void)
{
return;
}
static inline int register_memory_notifier(struct notifier_block *nb)
{
return 0;
}
static inline void unregister_memory_notifier(struct notifier_block *nb)
{
}
static inline int memory_notify(enum memory_block_state state, void *v)
{
return 0;
}
static inline int hotplug_memory_notifier(notifier_fn_t fn, int pri)
{
Annotation
- Immediate include surface: `linux/node.h`, `linux/compiler.h`, `linux/mutex.h`, `linux/memory_hotplug.h`.
- Detected declarations: `struct memory_group`, `struct memory_block`, `struct memory_notify`, `struct notifier_block`, `struct mem_section`, `enum memory_block_state`, `function memory_dev_init`, `function register_memory_notifier`, `function unregister_memory_notifier`, `function hotplug_memory_notifier`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.