lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1448426900-2907-1-git-send-email-baiyaowei@cmss.chinamobile.com>
Date:	Wed, 25 Nov 2015 12:48:20 +0800
From:	Yaowei Bai <baiyaowei@...s.chinamobile.com>
To:	akpm@...ux-foundation.org, mgorman@...e.de, riel@...hat.com,
	mhocko@...e.cz, hannes@...xchg.org, kamezawa.hiroyu@...fujitsu.com,
	jslaby@...e.cz, Valdis.Kletnieks@...edu, zcalusic@...sync.net,
	vbabka@...e.cz, vdavydov@...allels.com
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [PATCH] mm: vmscan: Obey indeed proportional scanning for kswapd and memcg

Commit e82e0561dae9f3ae5 ("mm: vmscan: obey proportional scanning
requirements for kswapd") intended to preserve the proportional scanning
and reclaim what was requested by get_scan_count() for kswapd and memcg
by stopping reclaiming one type(anon or file) LRU and reducing the other's
amount of scanning proportional to the original scan target.

So the way to determine which LRU should be stopped reclaiming should be
comparing scanned/unscanned percentages to the original scan target of two
lru types instead of absolute values what implemented currently, because
larger absolute value doesn't mean larger percentage, there shall be
chance that larger absolute value with smaller percentage, for instance:

	target_file = 1000
	target_anon = 500
	nr_file = 500
	nr_anon = 400

in this case, because nr_file > nr_anon, according to current implement,
we will stop scanning anon lru and shrink file lru. This breaks
proportional scanning intent and makes more unproportional.

This patch changes to compare percentage to the original scan target to
determine which lru should be shrunk.

Signed-off-by: Yaowei Bai <baiyaowei@...s.chinamobile.com>
---
 mm/vmscan.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2aec424..09a37436 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2216,6 +2216,7 @@ static void shrink_lruvec(struct lruvec *lruvec, int swappiness,
 	while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
 					nr[LRU_INACTIVE_FILE]) {
 		unsigned long nr_anon, nr_file, percentage;
+		unsigned long percentage_anon, percentage_file;
 		unsigned long nr_scanned;
 
 		for_each_evictable_lru(lru) {
@@ -2250,16 +2251,17 @@ static void shrink_lruvec(struct lruvec *lruvec, int swappiness,
 		if (!nr_file || !nr_anon)
 			break;
 
-		if (nr_file > nr_anon) {
-			unsigned long scan_target = targets[LRU_INACTIVE_ANON] +
-						targets[LRU_ACTIVE_ANON] + 1;
+		percentage_anon = nr_anon * 100 / (targets[LRU_INACTIVE_ANON] +
+						targets[LRU_ACTIVE_ANON] + 1);
+		percentage_file = nr_file * 100 / (targets[LRU_INACTIVE_FILE] +
+						targets[LRU_ACTIVE_FILE] + 1);
+
+		if (percentage_file > percentage_anon) {
 			lru = LRU_BASE;
-			percentage = nr_anon * 100 / scan_target;
+			percentage = percentage_anon;
 		} else {
-			unsigned long scan_target = targets[LRU_INACTIVE_FILE] +
-						targets[LRU_ACTIVE_FILE] + 1;
 			lru = LRU_FILE;
-			percentage = nr_file * 100 / scan_target;
+			percentage = percentage_file;
 		}
 
 		/* Stop scanning the smaller of the LRU */
-- 
1.9.1



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ