All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <20140616234608.GB18790@bbox>

diff --git a/a/1.txt b/N1/1.txt
index d6ff591..3249f46 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -54,3 +54,153 @@ On Mon, Jun 16, 2014 at 08:57:54PM +0800, Chen Yucong wrote:
 
 Yes, 3 changed old behavior. I'm ashamed but wanted to clean it up.
 Is it worth to clean it up?
+
+>From aedf8288e28a07bdd6c459a403f21cc2615ecc4e Mon Sep 17 00:00:00 2001
+From: Minchan Kim <minchan@kernel.org>
+Date: Tue, 17 Jun 2014 08:36:56 +0900
+Subject: [PATCH] mm: proportional scanning cleanup
+
+It aims for clean up, not changing behaivor so if anyone doesn't
+looks it's more readable or not enough for readability, it should
+really drop.
+
+Signed-off-by: Minchan Kim <minchan@kernel.org>
+---
+ mm/vmscan.c | 69 ++++++++++++++++++++++++++++++++-----------------------------
+ 1 file changed, 36 insertions(+), 33 deletions(-)
+
+diff --git a/mm/vmscan.c b/mm/vmscan.c
+index 0f16ffe8eb67..acc29315bad0 100644
+--- a/mm/vmscan.c
++++ b/mm/vmscan.c
+@@ -2054,19 +2054,18 @@ out:
+  */
+ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
+ {
+-	unsigned long nr[NR_LRU_LISTS];
+ 	unsigned long targets[NR_LRU_LISTS];
+-	unsigned long nr_to_scan;
++	unsigned long remains[NR_LRU_LISTS];
+ 	enum lru_list lru;
+ 	unsigned long nr_reclaimed = 0;
+ 	unsigned long nr_to_reclaim = sc->nr_to_reclaim;
+ 	struct blk_plug plug;
+ 	bool scan_adjusted;
+ 
+-	get_scan_count(lruvec, sc, nr);
++	get_scan_count(lruvec, sc, targets);
+ 
+-	/* Record the original scan target for proportional adjustments later */
+-	memcpy(targets, nr, sizeof(nr));
++	/* Keep the original scan target for proportional adjustments later */
++	memcpy(remains, targets, sizeof(targets));
+ 
+ 	/*
+ 	 * Global reclaiming within direct reclaim at DEF_PRIORITY is a normal
+@@ -2083,19 +2082,21 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
+ 			 sc->priority == DEF_PRIORITY);
+ 
+ 	blk_start_plug(&plug);
+-	while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
+-					nr[LRU_INACTIVE_FILE]) {
+-		unsigned long nr_anon, nr_file, percentage;
+-		unsigned long nr_scanned;
++	while (remains[LRU_INACTIVE_ANON] || remains[LRU_ACTIVE_FILE] ||
++					remains[LRU_INACTIVE_FILE]) {
++		unsigned long target, remain_anon, remain_file;
++		unsigned long percentage;
++		unsigned long nr_scanned, nr_to_scan;
+ 
+ 		for_each_evictable_lru(lru) {
+-			if (nr[lru]) {
+-				nr_to_scan = min(nr[lru], SWAP_CLUSTER_MAX);
+-				nr[lru] -= nr_to_scan;
++			if (!remains[lru])
++				continue;
+ 
+-				nr_reclaimed += shrink_list(lru, nr_to_scan,
+-							    lruvec, sc);
+-			}
++			nr_to_scan = min(remains[lru], SWAP_CLUSTER_MAX);
++			remains[lru] -= nr_to_scan;
++
++			nr_reclaimed += shrink_list(lru, nr_to_scan,
++						    lruvec, sc);
+ 		}
+ 
+ 		if (nr_reclaimed < nr_to_reclaim || scan_adjusted)
+@@ -2108,8 +2109,10 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
+ 		 * stop reclaiming one LRU and reduce the amount scanning
+ 		 * proportional to the original scan target.
+ 		 */
+-		nr_file = nr[LRU_INACTIVE_FILE] + nr[LRU_ACTIVE_FILE];
+-		nr_anon = nr[LRU_INACTIVE_ANON] + nr[LRU_ACTIVE_ANON];
++		remain_file = remains[LRU_INACTIVE_FILE] +
++				remains[LRU_ACTIVE_FILE];
++		remain_anon = remains[LRU_INACTIVE_ANON] +
++				remains[LRU_ACTIVE_ANON];
+ 
+ 		/*
+ 		 * It's just vindictive to attack the larger once the smaller
+@@ -2117,38 +2120,38 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
+ 		 * smaller below, this makes sure that we only make one nudge
+ 		 * towards proportionality once we've got nr_to_reclaim.
+ 		 */
+-		if (!nr_file || !nr_anon)
++		if (!remain_file || !remain_anon)
+ 			break;
+ 
+-		if (nr_file > nr_anon) {
+-			unsigned long scan_target = targets[LRU_INACTIVE_ANON] +
+-						targets[LRU_ACTIVE_ANON] + 1;
++		if (remain_file > remain_anon) {
++			target = targets[LRU_ACTIVE_ANON] +
++						targets[LRU_INACTIVE_ANON] + 1;
++			percentage = 100 * (target - remain_anon) / target;
+ 			lru = LRU_BASE;
+-			percentage = nr_anon * 100 / scan_target;
+ 		} else {
+-			unsigned long scan_target = targets[LRU_INACTIVE_FILE] +
+-						targets[LRU_ACTIVE_FILE] + 1;
++			target = targets[LRU_ACTIVE_FILE] +
++						targets[LRU_INACTIVE_FILE] + 1;
++			percentage = 100 * (target - remain_file) / target;
+ 			lru = LRU_FILE;
+-			percentage = nr_file * 100 / scan_target;
+ 		}
+ 
+ 		/* Stop scanning the smaller of the LRU */
+-		nr[lru] = 0;
+-		nr[lru + LRU_ACTIVE] = 0;
++		remains[lru] = 0;
++		remains[lru + LRU_ACTIVE] = 0;
+ 
+ 		/*
+ 		 * Recalculate the other LRU scan count based on its original
+ 		 * scan target and the percentage scanning already complete
+ 		 */
+ 		lru = (lru == LRU_FILE) ? LRU_BASE : LRU_FILE;
+-		nr_scanned = targets[lru] - nr[lru];
+-		nr[lru] = targets[lru] * (100 - percentage) / 100;
+-		nr[lru] -= min(nr[lru], nr_scanned);
++		nr_scanned = targets[lru] - remains[lru];
++		remains[lru] = targets[lru] * percentage / 100;
++		remains[lru] -= min(remains[lru], nr_scanned);
+ 
+ 		lru += LRU_ACTIVE;
+-		nr_scanned = targets[lru] - nr[lru];
+-		nr[lru] = targets[lru] * (100 - percentage) / 100;
+-		nr[lru] -= min(nr[lru], nr_scanned);
++		nr_scanned = targets[lru] - remains[lru];
++		remains[lru] = targets[lru] * percentage / 100;
++		remains[lru] -= min(remains[lru], nr_scanned);
+ 
+ 		scan_adjusted = true;
+ 	}
+-- 
+2.0.0
+
+
+-- 
+Kind regards,
+Minchan Kim
diff --git a/a/content_digest b/N1/content_digest
index c9ddaf2..271037f 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -66,6 +66,156 @@
  "> qualitative difference between FILE and ANON that is very small.\n"
  "\n"
  "Yes, 3 changed old behavior. I'm ashamed but wanted to clean it up.\n"
- Is it worth to clean it up?
+ "Is it worth to clean it up?\n"
+ "\n"
+ ">From aedf8288e28a07bdd6c459a403f21cc2615ecc4e Mon Sep 17 00:00:00 2001\n"
+ "From: Minchan Kim <minchan@kernel.org>\n"
+ "Date: Tue, 17 Jun 2014 08:36:56 +0900\n"
+ "Subject: [PATCH] mm: proportional scanning cleanup\n"
+ "\n"
+ "It aims for clean up, not changing behaivor so if anyone doesn't\n"
+ "looks it's more readable or not enough for readability, it should\n"
+ "really drop.\n"
+ "\n"
+ "Signed-off-by: Minchan Kim <minchan@kernel.org>\n"
+ "---\n"
+ " mm/vmscan.c | 69 ++++++++++++++++++++++++++++++++-----------------------------\n"
+ " 1 file changed, 36 insertions(+), 33 deletions(-)\n"
+ "\n"
+ "diff --git a/mm/vmscan.c b/mm/vmscan.c\n"
+ "index 0f16ffe8eb67..acc29315bad0 100644\n"
+ "--- a/mm/vmscan.c\n"
+ "+++ b/mm/vmscan.c\n"
+ "@@ -2054,19 +2054,18 @@ out:\n"
+ "  */\n"
+ " static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)\n"
+ " {\n"
+ "-\tunsigned long nr[NR_LRU_LISTS];\n"
+ " \tunsigned long targets[NR_LRU_LISTS];\n"
+ "-\tunsigned long nr_to_scan;\n"
+ "+\tunsigned long remains[NR_LRU_LISTS];\n"
+ " \tenum lru_list lru;\n"
+ " \tunsigned long nr_reclaimed = 0;\n"
+ " \tunsigned long nr_to_reclaim = sc->nr_to_reclaim;\n"
+ " \tstruct blk_plug plug;\n"
+ " \tbool scan_adjusted;\n"
+ " \n"
+ "-\tget_scan_count(lruvec, sc, nr);\n"
+ "+\tget_scan_count(lruvec, sc, targets);\n"
+ " \n"
+ "-\t/* Record the original scan target for proportional adjustments later */\n"
+ "-\tmemcpy(targets, nr, sizeof(nr));\n"
+ "+\t/* Keep the original scan target for proportional adjustments later */\n"
+ "+\tmemcpy(remains, targets, sizeof(targets));\n"
+ " \n"
+ " \t/*\n"
+ " \t * Global reclaiming within direct reclaim at DEF_PRIORITY is a normal\n"
+ "@@ -2083,19 +2082,21 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)\n"
+ " \t\t\t sc->priority == DEF_PRIORITY);\n"
+ " \n"
+ " \tblk_start_plug(&plug);\n"
+ "-\twhile (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||\n"
+ "-\t\t\t\t\tnr[LRU_INACTIVE_FILE]) {\n"
+ "-\t\tunsigned long nr_anon, nr_file, percentage;\n"
+ "-\t\tunsigned long nr_scanned;\n"
+ "+\twhile (remains[LRU_INACTIVE_ANON] || remains[LRU_ACTIVE_FILE] ||\n"
+ "+\t\t\t\t\tremains[LRU_INACTIVE_FILE]) {\n"
+ "+\t\tunsigned long target, remain_anon, remain_file;\n"
+ "+\t\tunsigned long percentage;\n"
+ "+\t\tunsigned long nr_scanned, nr_to_scan;\n"
+ " \n"
+ " \t\tfor_each_evictable_lru(lru) {\n"
+ "-\t\t\tif (nr[lru]) {\n"
+ "-\t\t\t\tnr_to_scan = min(nr[lru], SWAP_CLUSTER_MAX);\n"
+ "-\t\t\t\tnr[lru] -= nr_to_scan;\n"
+ "+\t\t\tif (!remains[lru])\n"
+ "+\t\t\t\tcontinue;\n"
+ " \n"
+ "-\t\t\t\tnr_reclaimed += shrink_list(lru, nr_to_scan,\n"
+ "-\t\t\t\t\t\t\t    lruvec, sc);\n"
+ "-\t\t\t}\n"
+ "+\t\t\tnr_to_scan = min(remains[lru], SWAP_CLUSTER_MAX);\n"
+ "+\t\t\tremains[lru] -= nr_to_scan;\n"
+ "+\n"
+ "+\t\t\tnr_reclaimed += shrink_list(lru, nr_to_scan,\n"
+ "+\t\t\t\t\t\t    lruvec, sc);\n"
+ " \t\t}\n"
+ " \n"
+ " \t\tif (nr_reclaimed < nr_to_reclaim || scan_adjusted)\n"
+ "@@ -2108,8 +2109,10 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)\n"
+ " \t\t * stop reclaiming one LRU and reduce the amount scanning\n"
+ " \t\t * proportional to the original scan target.\n"
+ " \t\t */\n"
+ "-\t\tnr_file = nr[LRU_INACTIVE_FILE] + nr[LRU_ACTIVE_FILE];\n"
+ "-\t\tnr_anon = nr[LRU_INACTIVE_ANON] + nr[LRU_ACTIVE_ANON];\n"
+ "+\t\tremain_file = remains[LRU_INACTIVE_FILE] +\n"
+ "+\t\t\t\tremains[LRU_ACTIVE_FILE];\n"
+ "+\t\tremain_anon = remains[LRU_INACTIVE_ANON] +\n"
+ "+\t\t\t\tremains[LRU_ACTIVE_ANON];\n"
+ " \n"
+ " \t\t/*\n"
+ " \t\t * It's just vindictive to attack the larger once the smaller\n"
+ "@@ -2117,38 +2120,38 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)\n"
+ " \t\t * smaller below, this makes sure that we only make one nudge\n"
+ " \t\t * towards proportionality once we've got nr_to_reclaim.\n"
+ " \t\t */\n"
+ "-\t\tif (!nr_file || !nr_anon)\n"
+ "+\t\tif (!remain_file || !remain_anon)\n"
+ " \t\t\tbreak;\n"
+ " \n"
+ "-\t\tif (nr_file > nr_anon) {\n"
+ "-\t\t\tunsigned long scan_target = targets[LRU_INACTIVE_ANON] +\n"
+ "-\t\t\t\t\t\ttargets[LRU_ACTIVE_ANON] + 1;\n"
+ "+\t\tif (remain_file > remain_anon) {\n"
+ "+\t\t\ttarget = targets[LRU_ACTIVE_ANON] +\n"
+ "+\t\t\t\t\t\ttargets[LRU_INACTIVE_ANON] + 1;\n"
+ "+\t\t\tpercentage = 100 * (target - remain_anon) / target;\n"
+ " \t\t\tlru = LRU_BASE;\n"
+ "-\t\t\tpercentage = nr_anon * 100 / scan_target;\n"
+ " \t\t} else {\n"
+ "-\t\t\tunsigned long scan_target = targets[LRU_INACTIVE_FILE] +\n"
+ "-\t\t\t\t\t\ttargets[LRU_ACTIVE_FILE] + 1;\n"
+ "+\t\t\ttarget = targets[LRU_ACTIVE_FILE] +\n"
+ "+\t\t\t\t\t\ttargets[LRU_INACTIVE_FILE] + 1;\n"
+ "+\t\t\tpercentage = 100 * (target - remain_file) / target;\n"
+ " \t\t\tlru = LRU_FILE;\n"
+ "-\t\t\tpercentage = nr_file * 100 / scan_target;\n"
+ " \t\t}\n"
+ " \n"
+ " \t\t/* Stop scanning the smaller of the LRU */\n"
+ "-\t\tnr[lru] = 0;\n"
+ "-\t\tnr[lru + LRU_ACTIVE] = 0;\n"
+ "+\t\tremains[lru] = 0;\n"
+ "+\t\tremains[lru + LRU_ACTIVE] = 0;\n"
+ " \n"
+ " \t\t/*\n"
+ " \t\t * Recalculate the other LRU scan count based on its original\n"
+ " \t\t * scan target and the percentage scanning already complete\n"
+ " \t\t */\n"
+ " \t\tlru = (lru == LRU_FILE) ? LRU_BASE : LRU_FILE;\n"
+ "-\t\tnr_scanned = targets[lru] - nr[lru];\n"
+ "-\t\tnr[lru] = targets[lru] * (100 - percentage) / 100;\n"
+ "-\t\tnr[lru] -= min(nr[lru], nr_scanned);\n"
+ "+\t\tnr_scanned = targets[lru] - remains[lru];\n"
+ "+\t\tremains[lru] = targets[lru] * percentage / 100;\n"
+ "+\t\tremains[lru] -= min(remains[lru], nr_scanned);\n"
+ " \n"
+ " \t\tlru += LRU_ACTIVE;\n"
+ "-\t\tnr_scanned = targets[lru] - nr[lru];\n"
+ "-\t\tnr[lru] = targets[lru] * (100 - percentage) / 100;\n"
+ "-\t\tnr[lru] -= min(nr[lru], nr_scanned);\n"
+ "+\t\tnr_scanned = targets[lru] - remains[lru];\n"
+ "+\t\tremains[lru] = targets[lru] * percentage / 100;\n"
+ "+\t\tremains[lru] -= min(remains[lru], nr_scanned);\n"
+ " \n"
+ " \t\tscan_adjusted = true;\n"
+ " \t}\n"
+ "-- \n"
+ "2.0.0\n"
+ "\n"
+ "\n"
+ "-- \n"
+ "Kind regards,\n"
+ Minchan Kim
 
-59bf5406fa8ce57c8f0437df78d5328de50920ae1e36bc106404ba1157102d62
+f30f3baaecc90ce18b20d0cf60d7a2e9fb5d78f4e1a95a0d2fb07fea3f384375

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.