承接記憶體管理相關概念講解相關數據結構。主要有 pg_data_t: 表示節點; zone: 記憶體域; page: 頁幀; pglist_data定義如下: node_zones是一個數組,包含節點中各記憶體域(ZONE_DMA, ZONE_DMA32, ZONE_NORMAL...)的數據結構; no ...
承接記憶體管理相關概念講解相關數據結構。主要有
- pg_data_t: 表示節點;
- zone: 記憶體域;
- page: 頁幀;
pglist_data定義如下:
typedef struct pglist_data {
struct zone node_zones[MAX_NR_ZONES];
struct zonelist node_zonelists[MAX_ZONELISTS];
int nr_zones;
#ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */
struct page *node_mem_map;
#ifdef CONFIG_PAGE_EXTENSION
struct page_ext *node_page_ext;
#endif
#endif
#ifndef CONFIG_NO_BOOTMEM
struct bootmem_data *bdata;
#endif
#ifdef CONFIG_MEMORY_HOTPLUG
/*
* Must be held any time you expect node_start_pfn, node_present_pages
* or node_spanned_pages stay constant. Holding this will also
* guarantee that any pfn_valid() stays that way.
*
* pgdat_resize_lock() and pgdat_resize_unlock() are provided to
* manipulate node_size_lock without checking for CONFIG_MEMORY_HOTPLUG.
*
* Nests above zone->lock and zone->span_seqlock
*/
spinlock_t node_size_lock;
#endif
unsigned long node_start_pfn;
unsigned long node_present_pages; /* total number of physical pages */
unsigned long node_spanned_pages; /* total size of physical page
range, including holes */
int node_id;
wait_queue_head_t kswapd_wait;
wait_queue_head_t pfmemalloc_wait;
struct task_struct *kswapd; /* Protected by
mem_hotplug_begin/end() */
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;
/* Rate limiting time interval */
unsigned long numabalancing_migrate_next_window;
/* Number of pages migrated during the rate limiting time interval */
unsigned long numabalancing_migrate_nr_pages;
#endif
#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
/*
* If memory initialisation on large machines is deferred then this
* is the first PFN that needs to be initialised.
*/
unsigned long first_deferred_pfn;
/* Number of non-deferred pages */
unsigned long static_init_pgcnt;
#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
} pg_data_t;
- node_zones是一個數組,包含節點中各記憶體域(ZONE_DMA, ZONE_DMA32, ZONE_NORMAL...)的數據結構;
- node_zonelists指定了節點的備用列表;
- nr_zones 指示了節點中不同記憶體域數目;
- node_mem_map描述節點的所有物理記憶體頁面。包含節點的所有記憶體域;
- bdata 系統啟動自舉記憶體分配器數據結構實例;
- node_start_pfn 當前NUMA節點第一頁幀邏輯編號。在UMA總是0.
- node_present_pages節點中頁幀的數目;
- node_spanned_pages節點以頁幀為單位計算的數目。由於空洞的存在可能不等於node_present_pages,應該是大於等於node_present_pages;
- node_id是全局節點ID;
- kswapd_wait:node的等待隊列,交換守護列隊進程的等待列表
- kswapd_max_order:需要釋放的區域的長度,以頁階為單位
若系統節點多餘一個,則內核會維護一個點陣圖用於提供每個節點的狀態信息,狀態信息為一個enum。定義如下:
enum node_states {
N_POSSIBLE, /* The node could become online at some point */
N_ONLINE, /* The node is online */
N_NORMAL_MEMORY, /* The node has regular memory */
#ifdef CONFIG_HIGHMEM
N_HIGH_MEMORY, /* The node has regular or high memory */
#else
N_HIGH_MEMORY = N_NORMAL_MEMORY,
#endif
#ifdef CONFIG_MOVABLE_NODE
N_MEMORY, /* The node has memory(regular, high, movable) */
#else
N_MEMORY = N_HIGH_MEMORY,
#endif
N_CPU, /* The node has one or more cpus */
NR_NODE_STATES
};