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.

Dependency Surface

Detected Declarations

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

Implementation Notes