PG? Data? Of memory management related data structures

Carry on the memory management related concept explanation related data structure. There are mainly

  • PG? Data? T: indicates the node;
  • zone: memory domain;
  • Page: page frame;

Pglist data is defined as follows:

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 is an array containing the data structure of each memory domain (zone ﹣ DMA, zone ﹣ dma32, zone ﹣ normal...) in the node;
  • Node [zonelists] specifies the spare list of nodes;
  • NR? Zones indicates the number of different memory domains in the node;
  • Node? MEM? Map describes all physical memory pages of a node. Contains all memory domains of the node;
  • bdata system starts bootstrap memory allocator data structure instance;
  • Node start PFN the logical frame number of the first page of the current NUMA node. In UMA always 0
  • Number of page frames in the node [present] node;
  • Node spanned pages the number of page frames in a node. Because the existence of voids may not be equal to node [present] pages, it should be greater than or equal to node [present] pages;
  • Node? ID is the global node ID;
  • kswapd_wait: waiting queue of node, exchange waiting list of Daemons
  • Kswapd? Max? Order: the length of the area to be released, in page order

If there is more than one system node, the kernel maintains a bitmap to provide the status information of each node, which is an enum. It is defined as follows:

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
};

Posted by cqinzx on Sun, 12 Apr 2020 07:57:05 -0700