Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1340743

[PATCH 15/27] mm, workingset: Make working set detection node-aware

From Mel Gorman <mgorman@techsingularity.net>
Newsgroups linux.kernel
Subject [PATCH 15/27] mm, workingset: Make working set detection node-aware
Date 2016-02-23 16:10 +0100
Message-ID <r5mL8-7at-25@gated-at.bofh.it> (permalink)
References <r5mL7-7at-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Working set and refault detection is still zone-based, fix it.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
 include/linux/mmzone.h |  6 +++---
 mm/vmstat.c            |  6 +++---
 mm/workingset.c        | 37 +++++++++++++++++--------------------
 3 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index ffe8a6e606b9..cef476813581 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -146,9 +146,6 @@ enum zone_stat_item {
 	NUMA_LOCAL,		/* allocation from local node */
 	NUMA_OTHER,		/* allocation from other node */
 #endif
-	WORKINGSET_REFAULT,
-	WORKINGSET_ACTIVATE,
-	WORKINGSET_NODERECLAIM,
 	NR_ANON_TRANSPARENT_HUGEPAGES,
 	NR_FREE_CMA_PAGES,
 	NR_VM_ZONE_STAT_ITEMS };
@@ -163,6 +160,9 @@ enum node_stat_item {
 	NR_ISOLATED_ANON,	/* Temporary isolated pages from anon lru */
 	NR_ISOLATED_FILE,	/* Temporary isolated pages from file lru */
 	NR_PAGES_SCANNED,	/* pages scanned since last reclaim */
+	WORKINGSET_REFAULT,
+	WORKINGSET_ACTIVATE,
+	WORKINGSET_NODERECLAIM,
 	NR_VM_NODE_STAT_ITEMS
 };
 
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 19bd521e161b..0746dd5e1e73 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -970,9 +970,6 @@ const char * const vmstat_text[] = {
 	"numa_local",
 	"numa_other",
 #endif
-	"workingset_refault",
-	"workingset_activate",
-	"workingset_nodereclaim",
 	"nr_anon_transparent_hugepages",
 	"nr_free_cma",
 
@@ -985,6 +982,9 @@ const char * const vmstat_text[] = {
 	"nr_isolated_anon",
 	"nr_isolated_file",
 	"nr_pages_scanned",
+	"workingset_refault",
+	"workingset_activate",
+	"workingset_nodereclaim",
 
 	/* enum writeback_stat_item counters */
 	"nr_dirty_threshold",
diff --git a/mm/workingset.c b/mm/workingset.c
index d06d69670b5d..82a3fedef0df 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -16,7 +16,7 @@
 /*
  *		Double CLOCK lists
  *
- * Per zone, two clock lists are maintained for file pages: the
+ * Per node, two clock lists are maintained for file pages: the
  * inactive and the active list.  Freshly faulted pages start out at
  * the head of the inactive list and page reclaim scans pages from the
  * tail.  Pages that are accessed multiple times on the inactive list
@@ -141,11 +141,11 @@
  *
  *		Implementation
  *
- * For each zone's file LRU lists, a counter for inactive evictions
- * and activations is maintained (zone->inactive_age).
+ * For each node's file LRU lists, a counter for inactive evictions
+ * and activations is maintained (node->inactive_age).
  *
  * On eviction, a snapshot of this counter (along with some bits to
- * identify the zone) is stored in the now empty page cache radix tree
+ * identify the node) is stored in the now empty page cache radix tree
  * slot of the evicted page.  This is called a shadow entry.
  *
  * On cache misses for which there are shadow entries, an eligible
@@ -167,33 +167,30 @@
  */
 static unsigned int bucket_order __read_mostly;
 
-static void *pack_shadow(int memcgid, struct zone *zone, unsigned long eviction)
+static void *pack_shadow(int memcgid, pg_data_t *pgdat, unsigned long eviction)
 {
 	eviction >>= bucket_order;
 	eviction = (eviction << MEM_CGROUP_ID_SHIFT) | memcgid;
-	eviction = (eviction << NODES_SHIFT) | zone_to_nid(zone);
-	eviction = (eviction << ZONES_SHIFT) | zone_idx(zone);
+	eviction = (eviction << NODES_SHIFT) | pgdat->node_id;
 	eviction = (eviction << RADIX_TREE_EXCEPTIONAL_SHIFT);
 
 	return (void *)(eviction | RADIX_TREE_EXCEPTIONAL_ENTRY);
 }
 
-static void unpack_shadow(void *shadow, int *memcgidp, struct zone **zonep,
+static void unpack_shadow(void *shadow, int *memcgidp, pg_data_t **pgdat,
 			  unsigned long *evictionp)
 {
 	unsigned long entry = (unsigned long)shadow;
-	int memcgid, nid, zid;
+	int memcgid, nid;
 
 	entry >>= RADIX_TREE_EXCEPTIONAL_SHIFT;
-	zid = entry & ((1UL << ZONES_SHIFT) - 1);
-	entry >>= ZONES_SHIFT;
 	nid = entry & ((1UL << NODES_SHIFT) - 1);
 	entry >>= NODES_SHIFT;
 	memcgid = entry & ((1UL << MEM_CGROUP_ID_SHIFT) - 1);
 	entry >>= MEM_CGROUP_ID_SHIFT;
 
 	*memcgidp = memcgid;
-	*zonep = NODE_DATA(nid)->node_zones + zid;
+	*pgdat = NODE_DATA(nid);
 	*evictionp = entry << bucket_order;
 }
 
@@ -220,7 +217,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)
 
 	lruvec = mem_cgroup_lruvec(zone->zone_pgdat, memcg);
 	eviction = atomic_long_inc_return(&lruvec->inactive_age);
-	return pack_shadow(memcgid, zone, eviction);
+	return pack_shadow(memcgid, zone->zone_pgdat, eviction);
 }
 
 /**
@@ -228,7 +225,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)
  * @shadow: shadow entry of the evicted page
  *
  * Calculates and evaluates the refault distance of the previously
- * evicted page in the context of the zone it was allocated in.
+ * evicted page in the context of the node it was allocated in.
  *
  * Returns %true if the page should be activated, %false otherwise.
  */
@@ -240,10 +237,10 @@ bool workingset_refault(void *shadow)
 	unsigned long eviction;
 	struct lruvec *lruvec;
 	unsigned long refault;
-	struct zone *zone;
+	struct pglist_data *pgdat;
 	int memcgid;
 
-	unpack_shadow(shadow, &memcgid, &zone, &eviction);
+	unpack_shadow(shadow, &memcgid, &pgdat, &eviction);
 
 	rcu_read_lock();
 	/*
@@ -267,7 +264,7 @@ bool workingset_refault(void *shadow)
 		rcu_read_unlock();
 		return false;
 	}
-	lruvec = mem_cgroup_lruvec(zone->zone_pgdat, memcg);
+	lruvec = mem_cgroup_lruvec(pgdat, memcg);
 	refault = atomic_long_read(&lruvec->inactive_age);
 	active_file = lruvec_lru_size(lruvec, LRU_ACTIVE_FILE);
 	rcu_read_unlock();
@@ -290,10 +287,10 @@ bool workingset_refault(void *shadow)
 	 */
 	refault_distance = (refault - eviction) & EVICTION_MASK;
 
-	inc_zone_state(zone, WORKINGSET_REFAULT);
+	inc_node_state(pgdat, WORKINGSET_REFAULT);
 
 	if (refault_distance <= active_file) {
-		inc_zone_state(zone, WORKINGSET_ACTIVATE);
+		inc_node_state(pgdat, WORKINGSET_ACTIVATE);
 		return true;
 	}
 	return false;
@@ -435,7 +432,7 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
 		}
 	}
 	BUG_ON(node->count);
-	inc_zone_state(page_zone(virt_to_page(node)), WORKINGSET_NODERECLAIM);
+	inc_node_state(page_zone(virt_to_page(node))->zone_pgdat, WORKINGSET_NODERECLAIM);
 	if (!__radix_tree_delete_node(&mapping->page_tree, node))
 		BUG();
 
-- 
2.6.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
  [PATCH 06/27] mm, vmscan: Begin reclaiming pages on a per-node basis Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
    Re: [PATCH 06/27] mm, vmscan: Begin reclaiming pages on a per-node  basis Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 20:00 +0100
      Re: [PATCH 06/27] mm, vmscan: Begin reclaiming pages on a per-node  basis Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 20:10 +0100
      Re: [PATCH 06/27] mm, vmscan: Begin reclaiming pages on a per-node  basis Mel Gorman <mgorman@techsingularity.net> - 2016-02-24 11:30 +0100
  [PATCH 15/27] mm, workingset: Make working set detection node-aware Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
    Re: [PATCH 15/27] mm, workingset: Make working set detection  node-aware Johannes Weiner <hannes@cmpxchg.org> - 2016-02-28 17:20 +0100
  [PATCH 13/27] mm, vmscan: Make shrink_node decisions more node-centric Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
  [PATCH 09/27] mm, vmscan: Simplify the logic deciding whether kswapd sleeps Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
    Re: [PATCH 09/27] mm, vmscan: Simplify the logic deciding whether  kswapd sleeps Johannes Weiner <hannes@cmpxchg.org> - 2016-02-28 17:20 +0100
  [PATCH 10/27] mm, vmscan: By default have direct reclaim only shrink once per node Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
    Re: [PATCH 10/27] mm, vmscan: By default have direct reclaim only  shrink once per node Johannes Weiner <hannes@cmpxchg.org> - 2016-02-28 17:20 +0100
  [PATCH 12/27] mm: vmscan: Do not reclaim from kswapd if there is any eligible zone Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:10 +0100
  [PATCH 07/27] mm, vmscan: Have kswapd only scan based on the highest requested zone Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
    Re: [PATCH 07/27] mm, vmscan: Have kswapd only scan based on the  highest requested zone Johannes Weiner <hannes@cmpxchg.org> - 2016-02-25 23:20 +0100
  [PATCH 19/27] mm: Move most file-based accounting to the node Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
  [PATCH 18/27] mm: Rename NR_ANON_PAGES to NR_ANON_MAPPED Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
  [PATCH 01/27] mm, page_alloc: Use ac->classzone_idx instead of zone_idx(preferred_zone) Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
    Re: [PATCH 01/27] mm, page_alloc: Use ac->classzone_idx instead of  zone_idx(preferred_zone) Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 19:10 +0100
    Re: [PATCH 01/27] mm, page_alloc: Use ac->classzone_idx instead of  zone_idx(preferred_zone) Vlastimil Babka <vbabka@suse.cz> - 2016-03-03 11:40 +0100
  [PATCH 04/27] mm, vmscan: Move lru_lock to the node Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
    Re: [PATCH 04/27] mm, vmscan: Move lru_lock to the node Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 19:50 +0100
  [PATCH 17/27] mm: Move page mapped accounting to the node Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
  [PATCH 03/27] mm, vmstat: Add infrastructure for per-node vmstats Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
    Re: [PATCH 03/27] mm, vmstat: Add infrastructure for per-node vmstats Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 19:20 +0100
      Re: [PATCH 03/27] mm, vmstat: Add infrastructure for per-node vmstats Mel Gorman <mgorman@techsingularity.net> - 2016-02-24 10:20 +0100
  [PATCH 21/27] mm, vmscan: Update classzone_idx if  buffer_heads_over_limit Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
  [PATCH 11/27] mm, vmscan: Clear congestion, dirty and need for compaction on a per-node basis Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
  [PATCH 16/27] mm, page_alloc: Consider dirtyable memory in terms of  nodes Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
    Re: [PATCH 16/27] mm, page_alloc: Consider dirtyable memory in terms  of nodes Johannes Weiner <hannes@cmpxchg.org> - 2016-02-28 17:20 +0100
  [PATCH 20/27] mm: Move vmscan writes and file write accounting to  the node Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
  [PATCH 02/27] mm, vmscan: Check if cpusets are enabled during direct reclaim Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:20 +0100
    Re: [PATCH 02/27] mm, vmscan: Check if cpusets are enabled during  direct reclaim Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 19:10 +0100
    Re: [PATCH 02/27] mm, vmscan: Check if cpusets are enabled during  direct reclaim Vlastimil Babka <vbabka@suse.cz> - 2016-03-03 12:40 +0100
  [PATCH 27/27] mm: page_alloc: Cache the last node whose dirty limit  is reached Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:30 +0100
  [PATCH 25/27] mm, vmscan: Add classzone information to tracepoints Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:30 +0100
  [PATCH 23/27] mm, vmscan: Account in vmstat for pages skipped during  reclaim Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:30 +0100
  [PATCH 22/27] mm, vmscan: Only wakeup kswapd once per node for the  requested classzone Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:30 +0100
  [PATCH 24/27] mm: Convert zone_reclaim to node_reclaim Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:30 +0100
  [PATCH 26/27] mm, page_alloc: Remove fair zone allocation policy Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 16:30 +0100
  Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Christoph Lameter <cl@linux.com> - 2016-02-23 18:20 +0100
  Re: [PATCH 05/27] mm, vmscan: Move LRU lists to node Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 19:50 +0100
  Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 21:10 +0100
    Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 21:20 +0100
      Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Johannes Weiner <hannes@cmpxchg.org> - 2016-02-23 22:00 +0100
        Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Mel Gorman <mgorman@techsingularity.net> - 2016-02-23 23:00 +0100
          Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Johannes Weiner <hannes@cmpxchg.org> - 2016-02-24 01:20 +0100
            Re: [RFC PATCH 00/27] Move LRU page reclaim from zones to nodes v2 Mel Gorman <mgorman@techsingularity.net> - 2016-02-24 11:50 +0100

csiph-web