All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <20140620202449.GA30849@cmpxchg.org>

diff --git a/a/1.txt b/N1/1.txt
index 5c41eb5..9213ae7 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -54,3 +54,193 @@ comments, I have to watch my reflexes while moving stuff around :-)
 Updated patch:
 
 ---
+>From cd48b73fdca9e23aa21f65e9af1f850dbac5ab8e Mon Sep 17 00:00:00 2001
+From: Johannes Weiner <hannes@cmpxchg.org>
+Date: Wed, 11 Jun 2014 12:53:59 -0400
+Subject: [patch] mm: vmscan: rework compaction-ready signaling in direct
+ reclaim
+
+Page reclaim for a higher-order page runs until compaction is ready,
+then aborts and signals this situation through the return value of
+shrink_zones().  This is an oddly specific signal to encode in the
+return value of shrink_zones(), though, and can be quite confusing.
+
+Introduce sc->compaction_ready and signal the compactability of the
+zones out-of-band to free up the return value of shrink_zones() for
+actual zone reclaimability.
+
+Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
+Acked-by: Vlastimil Babka <vbabka@suse.cz>
+---
+ mm/vmscan.c | 67 ++++++++++++++++++++++++++++---------------------------------
+ 1 file changed, 31 insertions(+), 36 deletions(-)
+
+diff --git a/mm/vmscan.c b/mm/vmscan.c
+index 19b5b8016209..35747a75bf08 100644
+--- a/mm/vmscan.c
++++ b/mm/vmscan.c
+@@ -65,6 +65,9 @@ struct scan_control {
+ 	/* Number of pages freed so far during a call to shrink_zones() */
+ 	unsigned long nr_reclaimed;
+ 
++	/* One of the zones is ready for compaction */
++	int compaction_ready;
++
+ 	/* How many pages shrink_list() should reclaim */
+ 	unsigned long nr_to_reclaim;
+ 
+@@ -2292,15 +2295,11 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc)
+ }
+ 
+ /* Returns true if compaction should go ahead for a high-order request */
+-static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)
++static inline bool compaction_ready(struct zone *zone, int order)
+ {
+ 	unsigned long balance_gap, watermark;
+ 	bool watermark_ok;
+ 
+-	/* Do not consider compaction for orders reclaim is meant to satisfy */
+-	if (sc->order <= PAGE_ALLOC_COSTLY_ORDER)
+-		return false;
+-
+ 	/*
+ 	 * Compaction takes time to run and there are potentially other
+ 	 * callers using the pages just freed. Continue reclaiming until
+@@ -2309,18 +2308,18 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)
+ 	 */
+ 	balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP(
+ 			zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO));
+-	watermark = high_wmark_pages(zone) + balance_gap + (2UL << sc->order);
++	watermark = high_wmark_pages(zone) + balance_gap + (2UL << order);
+ 	watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0);
+ 
+ 	/*
+ 	 * If compaction is deferred, reclaim up to a point where
+ 	 * compaction will have a chance of success when re-enabled
+ 	 */
+-	if (compaction_deferred(zone, sc->order))
++	if (compaction_deferred(zone, order))
+ 		return watermark_ok;
+ 
+ 	/* If compaction is not ready to start, keep reclaiming */
+-	if (!compaction_suitable(zone, sc->order))
++	if (!compaction_suitable(zone, order))
+ 		return false;
+ 
+ 	return watermark_ok;
+@@ -2341,20 +2340,14 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)
+  *
+  * If a zone is deemed to be full of pinned pages then just give it a light
+  * scan then give up on it.
+- *
+- * This function returns true if a zone is being reclaimed for a costly
+- * high-order allocation and compaction is ready to begin. This indicates to
+- * the caller that it should consider retrying the allocation instead of
+- * further reclaim.
+  */
+-static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
++static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
+ {
+ 	struct zoneref *z;
+ 	struct zone *zone;
+ 	unsigned long nr_soft_reclaimed;
+ 	unsigned long nr_soft_scanned;
+ 	unsigned long lru_pages = 0;
+-	bool aborted_reclaim = false;
+ 	struct reclaim_state *reclaim_state = current->reclaim_state;
+ 	gfp_t orig_mask;
+ 	struct shrink_control shrink = {
+@@ -2391,22 +2384,24 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
+ 			if (sc->priority != DEF_PRIORITY &&
+ 			    !zone_reclaimable(zone))
+ 				continue;	/* Let kswapd poll it */
+-			if (IS_ENABLED(CONFIG_COMPACTION)) {
+-				/*
+-				 * If we already have plenty of memory free for
+-				 * compaction in this zone, don't free any more.
+-				 * Even though compaction is invoked for any
+-				 * non-zero order, only frequent costly order
+-				 * reclamation is disruptive enough to become a
+-				 * noticeable problem, like transparent huge
+-				 * page allocations.
+-				 */
+-				if ((zonelist_zone_idx(z) <= requested_highidx)
+-				    && compaction_ready(zone, sc)) {
+-					aborted_reclaim = true;
+-					continue;
+-				}
++
++			/*
++			 * If we already have plenty of memory free for
++			 * compaction in this zone, don't free any more.
++			 * Even though compaction is invoked for any
++			 * non-zero order, only frequent costly order
++			 * reclamation is disruptive enough to become a
++			 * noticeable problem, like transparent huge
++			 * page allocations.
++			 */
++			if (IS_ENABLED(CONFIG_COMPACTION) &&
++			    sc->order > PAGE_ALLOC_COSTLY_ORDER &&
++			    zonelist_zone_idx(z) <= requested_highidx &&
++			    compaction_ready(zone, sc->order)) {
++				sc->compaction_ready = true;
++				continue;
+ 			}
++
+ 			/*
+ 			 * This steals pages from memory cgroups over softlimit
+ 			 * and returns the number of reclaimed pages and
+@@ -2444,8 +2439,6 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
+ 	 * promoted it to __GFP_HIGHMEM.
+ 	 */
+ 	sc->gfp_mask = orig_mask;
+-
+-	return aborted_reclaim;
+ }
+ 
+ /* All zones in zonelist are unreclaimable? */
+@@ -2489,7 +2482,6 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
+ {
+ 	unsigned long total_scanned = 0;
+ 	unsigned long writeback_threshold;
+-	bool aborted_reclaim;
+ 
+ 	delayacct_freepages_start();
+ 
+@@ -2500,12 +2492,15 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
+ 		vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup,
+ 				sc->priority);
+ 		sc->nr_scanned = 0;
+-		aborted_reclaim = shrink_zones(zonelist, sc);
++		shrink_zones(zonelist, sc);
+ 
+ 		total_scanned += sc->nr_scanned;
+ 		if (sc->nr_reclaimed >= sc->nr_to_reclaim)
+ 			goto out;
+ 
++		if (sc->compaction_ready)
++			goto out;
++
+ 		/*
+ 		 * If we're getting trouble reclaiming, start doing
+ 		 * writepage even in laptop mode.
+@@ -2526,7 +2521,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
+ 						WB_REASON_TRY_TO_FREE_PAGES);
+ 			sc->may_writepage = 1;
+ 		}
+-	} while (--sc->priority >= 0 && !aborted_reclaim);
++	} while (--sc->priority >= 0);
+ 
+ out:
+ 	delayacct_freepages_end();
+@@ -2535,7 +2530,7 @@ out:
+ 		return sc->nr_reclaimed;
+ 
+ 	/* Aborted reclaim to try compaction? don't OOM, then */
+-	if (aborted_reclaim)
++	if (sc->compaction_ready)
+ 		return 1;
+ 
+ 	/* top priority shrink_zones still had more to do? don't OOM, then */
+-- 
+2.0.0
diff --git a/a/content_digest b/N1/content_digest
index ca72220..b27de08 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -68,6 +68,196 @@
  "\n"
  "Updated patch:\n"
  "\n"
- ---
+ "---\n"
+ ">From cd48b73fdca9e23aa21f65e9af1f850dbac5ab8e Mon Sep 17 00:00:00 2001\n"
+ "From: Johannes Weiner <hannes@cmpxchg.org>\n"
+ "Date: Wed, 11 Jun 2014 12:53:59 -0400\n"
+ "Subject: [patch] mm: vmscan: rework compaction-ready signaling in direct\n"
+ " reclaim\n"
+ "\n"
+ "Page reclaim for a higher-order page runs until compaction is ready,\n"
+ "then aborts and signals this situation through the return value of\n"
+ "shrink_zones().  This is an oddly specific signal to encode in the\n"
+ "return value of shrink_zones(), though, and can be quite confusing.\n"
+ "\n"
+ "Introduce sc->compaction_ready and signal the compactability of the\n"
+ "zones out-of-band to free up the return value of shrink_zones() for\n"
+ "actual zone reclaimability.\n"
+ "\n"
+ "Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>\n"
+ "Acked-by: Vlastimil Babka <vbabka@suse.cz>\n"
+ "---\n"
+ " mm/vmscan.c | 67 ++++++++++++++++++++++++++++---------------------------------\n"
+ " 1 file changed, 31 insertions(+), 36 deletions(-)\n"
+ "\n"
+ "diff --git a/mm/vmscan.c b/mm/vmscan.c\n"
+ "index 19b5b8016209..35747a75bf08 100644\n"
+ "--- a/mm/vmscan.c\n"
+ "+++ b/mm/vmscan.c\n"
+ "@@ -65,6 +65,9 @@ struct scan_control {\n"
+ " \t/* Number of pages freed so far during a call to shrink_zones() */\n"
+ " \tunsigned long nr_reclaimed;\n"
+ " \n"
+ "+\t/* One of the zones is ready for compaction */\n"
+ "+\tint compaction_ready;\n"
+ "+\n"
+ " \t/* How many pages shrink_list() should reclaim */\n"
+ " \tunsigned long nr_to_reclaim;\n"
+ " \n"
+ "@@ -2292,15 +2295,11 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc)\n"
+ " }\n"
+ " \n"
+ " /* Returns true if compaction should go ahead for a high-order request */\n"
+ "-static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)\n"
+ "+static inline bool compaction_ready(struct zone *zone, int order)\n"
+ " {\n"
+ " \tunsigned long balance_gap, watermark;\n"
+ " \tbool watermark_ok;\n"
+ " \n"
+ "-\t/* Do not consider compaction for orders reclaim is meant to satisfy */\n"
+ "-\tif (sc->order <= PAGE_ALLOC_COSTLY_ORDER)\n"
+ "-\t\treturn false;\n"
+ "-\n"
+ " \t/*\n"
+ " \t * Compaction takes time to run and there are potentially other\n"
+ " \t * callers using the pages just freed. Continue reclaiming until\n"
+ "@@ -2309,18 +2308,18 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)\n"
+ " \t */\n"
+ " \tbalance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP(\n"
+ " \t\t\tzone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO));\n"
+ "-\twatermark = high_wmark_pages(zone) + balance_gap + (2UL << sc->order);\n"
+ "+\twatermark = high_wmark_pages(zone) + balance_gap + (2UL << order);\n"
+ " \twatermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0);\n"
+ " \n"
+ " \t/*\n"
+ " \t * If compaction is deferred, reclaim up to a point where\n"
+ " \t * compaction will have a chance of success when re-enabled\n"
+ " \t */\n"
+ "-\tif (compaction_deferred(zone, sc->order))\n"
+ "+\tif (compaction_deferred(zone, order))\n"
+ " \t\treturn watermark_ok;\n"
+ " \n"
+ " \t/* If compaction is not ready to start, keep reclaiming */\n"
+ "-\tif (!compaction_suitable(zone, sc->order))\n"
+ "+\tif (!compaction_suitable(zone, order))\n"
+ " \t\treturn false;\n"
+ " \n"
+ " \treturn watermark_ok;\n"
+ "@@ -2341,20 +2340,14 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)\n"
+ "  *\n"
+ "  * If a zone is deemed to be full of pinned pages then just give it a light\n"
+ "  * scan then give up on it.\n"
+ "- *\n"
+ "- * This function returns true if a zone is being reclaimed for a costly\n"
+ "- * high-order allocation and compaction is ready to begin. This indicates to\n"
+ "- * the caller that it should consider retrying the allocation instead of\n"
+ "- * further reclaim.\n"
+ "  */\n"
+ "-static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)\n"
+ "+static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)\n"
+ " {\n"
+ " \tstruct zoneref *z;\n"
+ " \tstruct zone *zone;\n"
+ " \tunsigned long nr_soft_reclaimed;\n"
+ " \tunsigned long nr_soft_scanned;\n"
+ " \tunsigned long lru_pages = 0;\n"
+ "-\tbool aborted_reclaim = false;\n"
+ " \tstruct reclaim_state *reclaim_state = current->reclaim_state;\n"
+ " \tgfp_t orig_mask;\n"
+ " \tstruct shrink_control shrink = {\n"
+ "@@ -2391,22 +2384,24 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)\n"
+ " \t\t\tif (sc->priority != DEF_PRIORITY &&\n"
+ " \t\t\t    !zone_reclaimable(zone))\n"
+ " \t\t\t\tcontinue;\t/* Let kswapd poll it */\n"
+ "-\t\t\tif (IS_ENABLED(CONFIG_COMPACTION)) {\n"
+ "-\t\t\t\t/*\n"
+ "-\t\t\t\t * If we already have plenty of memory free for\n"
+ "-\t\t\t\t * compaction in this zone, don't free any more.\n"
+ "-\t\t\t\t * Even though compaction is invoked for any\n"
+ "-\t\t\t\t * non-zero order, only frequent costly order\n"
+ "-\t\t\t\t * reclamation is disruptive enough to become a\n"
+ "-\t\t\t\t * noticeable problem, like transparent huge\n"
+ "-\t\t\t\t * page allocations.\n"
+ "-\t\t\t\t */\n"
+ "-\t\t\t\tif ((zonelist_zone_idx(z) <= requested_highidx)\n"
+ "-\t\t\t\t    && compaction_ready(zone, sc)) {\n"
+ "-\t\t\t\t\taborted_reclaim = true;\n"
+ "-\t\t\t\t\tcontinue;\n"
+ "-\t\t\t\t}\n"
+ "+\n"
+ "+\t\t\t/*\n"
+ "+\t\t\t * If we already have plenty of memory free for\n"
+ "+\t\t\t * compaction in this zone, don't free any more.\n"
+ "+\t\t\t * Even though compaction is invoked for any\n"
+ "+\t\t\t * non-zero order, only frequent costly order\n"
+ "+\t\t\t * reclamation is disruptive enough to become a\n"
+ "+\t\t\t * noticeable problem, like transparent huge\n"
+ "+\t\t\t * page allocations.\n"
+ "+\t\t\t */\n"
+ "+\t\t\tif (IS_ENABLED(CONFIG_COMPACTION) &&\n"
+ "+\t\t\t    sc->order > PAGE_ALLOC_COSTLY_ORDER &&\n"
+ "+\t\t\t    zonelist_zone_idx(z) <= requested_highidx &&\n"
+ "+\t\t\t    compaction_ready(zone, sc->order)) {\n"
+ "+\t\t\t\tsc->compaction_ready = true;\n"
+ "+\t\t\t\tcontinue;\n"
+ " \t\t\t}\n"
+ "+\n"
+ " \t\t\t/*\n"
+ " \t\t\t * This steals pages from memory cgroups over softlimit\n"
+ " \t\t\t * and returns the number of reclaimed pages and\n"
+ "@@ -2444,8 +2439,6 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)\n"
+ " \t * promoted it to __GFP_HIGHMEM.\n"
+ " \t */\n"
+ " \tsc->gfp_mask = orig_mask;\n"
+ "-\n"
+ "-\treturn aborted_reclaim;\n"
+ " }\n"
+ " \n"
+ " /* All zones in zonelist are unreclaimable? */\n"
+ "@@ -2489,7 +2482,6 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,\n"
+ " {\n"
+ " \tunsigned long total_scanned = 0;\n"
+ " \tunsigned long writeback_threshold;\n"
+ "-\tbool aborted_reclaim;\n"
+ " \n"
+ " \tdelayacct_freepages_start();\n"
+ " \n"
+ "@@ -2500,12 +2492,15 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,\n"
+ " \t\tvmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup,\n"
+ " \t\t\t\tsc->priority);\n"
+ " \t\tsc->nr_scanned = 0;\n"
+ "-\t\taborted_reclaim = shrink_zones(zonelist, sc);\n"
+ "+\t\tshrink_zones(zonelist, sc);\n"
+ " \n"
+ " \t\ttotal_scanned += sc->nr_scanned;\n"
+ " \t\tif (sc->nr_reclaimed >= sc->nr_to_reclaim)\n"
+ " \t\t\tgoto out;\n"
+ " \n"
+ "+\t\tif (sc->compaction_ready)\n"
+ "+\t\t\tgoto out;\n"
+ "+\n"
+ " \t\t/*\n"
+ " \t\t * If we're getting trouble reclaiming, start doing\n"
+ " \t\t * writepage even in laptop mode.\n"
+ "@@ -2526,7 +2521,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,\n"
+ " \t\t\t\t\t\tWB_REASON_TRY_TO_FREE_PAGES);\n"
+ " \t\t\tsc->may_writepage = 1;\n"
+ " \t\t}\n"
+ "-\t} while (--sc->priority >= 0 && !aborted_reclaim);\n"
+ "+\t} while (--sc->priority >= 0);\n"
+ " \n"
+ " out:\n"
+ " \tdelayacct_freepages_end();\n"
+ "@@ -2535,7 +2530,7 @@ out:\n"
+ " \t\treturn sc->nr_reclaimed;\n"
+ " \n"
+ " \t/* Aborted reclaim to try compaction? don't OOM, then */\n"
+ "-\tif (aborted_reclaim)\n"
+ "+\tif (sc->compaction_ready)\n"
+ " \t\treturn 1;\n"
+ " \n"
+ " \t/* top priority shrink_zones still had more to do? don't OOM, then */\n"
+ "-- \n"
+ 2.0.0
 
-45d8c3a7d892faa76cc0669d72744a4ce5b0c3ca0f26117374de78201ef75222
+bd6ac563440101476deafe9788286defede4bfda94461d15e237104d46786b61

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.