zonelist_cache

来源:互联网 发布:网络通信协议 java 编辑:程序博客网 时间:2024/05/17 22:31
 


zonelist_cache


With zone_reclaim_mode enabled, it's possible for zones to be considered full in the zonelist_cache so they are skipped in the future.

当开始管理区回收模式后,就不在需要管理区列表cache了,在将来可能会忽略掉

If the process enters direct reclaim, the ZLC may still consider zones to be full even after reclaiming pages.

当进程进入直接回收模式后 ,回收页面之后,ZLC 可能会认为管理区还是满的

 Reconsider all zones for allocation

if direct reclaim returns successfully.

Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 mm/page_alloc.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6913854..149409c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1616,6 +1616,21 @@ static void zlc_mark_zone_full(struct zonelist *zonelist, struct zoneref *z)
  set_bit(i, zlc->fullzones);
 }
 
+/*
+ * clear all zones full, called after direct reclaim makes progress so
+that
+ * a zone that was recently full is not skipped over for up to a second 
+*/ static void zlc_clear_zones_full(struct zonelist *zonelist) {
+ struct zonelist_cache *zlc; /* cached zonelist speedup info */
+
+ zlc = zonelist->zlcache_ptr;
+ if (!zlc)
+  return;
+
+ bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST); }
+
 #else /* CONFIG_NUMA */
 
 static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags) @@ -1963,6 +1978,10 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
  if (unlikely(!(*did_some_progress)))
   return NULL;
 
+ /* After successful reclaim, reconsider all zones for allocation */
+ if (NUMA_BUILD)
+  zlc_clear_zones_full(zonelist);
+
 retry:
  page = get_page_from_freelist(gfp_mask, nodemask, order,
      zonelist, high_zoneidx,
--
1.7.3.4


zlc_setup

返回ZLC指针

ZLC的结构体

struct zonelist_cache {
 unsigned short z_to_n[MAX_ZONES_PER_ZONELIST];  /* zone->nid */
 DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST); /* zone full? */
 unsigned long last_full_zap;  /* when last zap'd (jiffies) */
};

#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)

最大节点树*最大管理区

static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
{
 struct zonelist_cache *zlc; /* cached zonelist speedup info */
 int i;    /* index of *z in zonelist zones */

 zlc = zonelist->zlcache_ptr;
 if (!zlc)
  return;

 i = z - zonelist->zones;

 set_bit(i, zlc->fullzones);
}

设置某个管理区满


从ZLC 中检查某个zone 是否有富余

static void __meminit build_zonelist_cache(pg_data_t *pgdat)
{
 int i;

 for (i = 0; i < MAX_NR_ZONES; i++) {
  struct zonelist *zonelist;
  struct zonelist_cache *zlc;
  struct zone **z;

  zonelist = pgdat->node_zonelists + i;
  zonelist->zlcache_ptr = zlc = &zonelist->zlcache;
  bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
  for (z = zonelist->zones; *z; z++)
   zlc->z_to_n[z - zonelist->zones] = zone_to_nid(*z);
 }
}

ZLC的建立

原创粉丝点击