Skip to the content.

Memory Zones

node / zone 初始化

如果自习观察 zone_spanned_pages_in_node,发现 zone 的范围是受 arch_zone_highest_possible_pfn 控制的,如果是 NUMA 机器,可以发现只有 Node 0 上是有 DMA 和 DMA32,其他的 Node 上是没有该节点的。

问题

physical memory initialization

  1. 探测
  2. memblock

LoyenWang LoyenWang

整体完成的工作也比较简单,将所有 Node 中可用的 zone 全部添加到各个 Node 中的 zonelist 中,也就是对应的 struct pglist_data 结构体中的 struct zonelist node_zonelists 字段。 这一步之后,准备工作基本就绪,进行页面申请的工作就可以开始了。 loading

memory zone

TODO 等待分析: zone 功能不同,甚至 swap cache 到 page cache 需要靠拷贝的方法维持生活 ?

/*
 * When a page is moved from swapcache to shmem filecache (either by the
 * usual swapin of shmem_getpage_gfp(), or by the less common swapoff of
 * shmem_unuse_inode()), it may have been read in earlier from swap, in
 * ignorance of the mapping it belongs to.  If that mapping has special
 * constraints (like the gma500 GEM driver, which requires RAM below 4GB),
 * we may need to copy to a suitable page before moving to filecache.
 *
 * In a future release, this may well be extended to respect cpuset and
 * NUMA mempolicy, and applied also to anonymous pages in do_swap_page();
 * but for now it is a simple matter of zone.
 */
static bool shmem_should_replace_page(struct page *page, gfp_t gfp)
{
  return page_zonenum(page) > gfp_zone(gfp);
}

ZONE_MOVABLE

free_area_init_nodes 中初始化似乎完全没有哇:

    /* Print out the PFNs ZONE_MOVABLE begins at in each node */
    pr_info("Movable zone start for each node\n");
    for (i = 0; i < MAX_NUMNODES; i++) {
        if (zone_movable_pfn[i])
            pr_info("  Node %d: %#018Lx\n", i,
                   (u64)zone_movable_pfn[i] << PAGE_SHIFT);
    }

https://lwn.net/Articles/843326/ https://docs.kernel.org/admin-guide/mm/memory-hotplug.html

Create optional ZONE_MOVABLE to partition memory between movable and non-movable pages v2

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。