bootmem机制是在linux启动期间,buddy管理器,slab管理器没有初始化好时使用的内存管理方法。
之后系统起来之后,就交由buddy等方法来管理了。
在多核系统中,每个核都对应这个一个node_data结构体,其中就记录着这个核使用的内存,也包括了bootmem的信息。
之后系统起来之后,就交由buddy等方法来管理了。
在多核系统中,每个核都对应这个一个node_data结构体,其中就记录着这个核使用的内存,也包括了bootmem的信息。
看一下node_data的结构体
#define LEVELS_PER_SLICE 128
struct slice_data {
unsigned long irq_enable_mask[2];
int level_to_irq[LEVELS_PER_SLICE];
};
struct hub_data {
cpumask_t h_cpus;
unsigned long slice_map;
unsigned long irq_alloc_mask[2];
struct slice_data slice[2];
};
struct node_data {
struct pglist_data pglist; //记录内存信息
struct hub_data hub;
cpumask_t cpumask;
};
#define NODE_DATA(n) (&__node_data[(n)]->pglist)
#define hub_data(n) (&__node_data[(n)]->hub)
struct bootmem_data;
typedef struct pglist_data {
struct zone node_zones[MAX_NR_ZONES]; //zone信息
struct zonelist node_zonelists[MAX_ZONELISTS]; //zone链表
int nr_zones;
#ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */
struct page *node_mem_map;
#ifdef CONFIG_MEMCG
struct page_cgroup *node_page_cgroup;
#endif
#endif
#ifndef CONFIG_NO_BOOTMEM
struct bootmem_data *bdata; //bootmem信息
#endif
#ifdef CONFIG_MEMORY_HOTPLUG
spinlock_t node_size_lock;
#endif
unsigned long node_start_pfn; //物理地址开始
unsigned long node_present_pages; /*总的物理页数*/
unsigned long node_spanned_pages; /*总的物理大小,包括hole*/
int node_id; //node号
nodemask_t reclaim_nodes; /* Nodes allowed to reclaim from */
wait_queue_head_t kswapd_wait;
wait_queue_head_t pfmemalloc_wait;
struct task_struct *kswapd; /* Protected by lock_memory_hotplug() */
int kswapd_max_order;
enum zone_type classzone_idx;
#ifdef CONFIG_NUMA_BALANCING
/* Lock serializing the migrate rate limiting window */
spinlock_t numabalancing_migrate_lock;
/* Rat