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>] [day] [month] [year] [list]
Date:   Fri,  3 Aug 2018 18:56:49 +0800
From:   Wei Wang <wei.w.wang@...el.com>
To:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        mhocko@...nel.org, akpm@...ux-foundation.org,
        penguin-kernel@...ove.SAKURA.ne.jp, chris@...is-wilson.co.uk,
        mst@...hat.com
Cc:     wei.w.wang@...el.com
Subject: [PATCH] mm/vmscan: adjust shrinkctl->nr_scanned after invoking scan_objects

Some shrinkers may free more than the requested nr_to_scan of pages
in one invocation of scan_objects, and some may free less than that.

Currently shrinkers can either return the actual number of pages that
have been freed via the return value of scan_objects or track that
actual number in shrinkctl->nr_scanned. But do_shrink_slab works on an
assumption that the actual number is always tracked via
shrinkctl->nr_scanned, which is not true. Having checked the shrinkers
used in the kernel, they basically return the actual number of freed
pages via the return value of scan_objects, and most of them leave
shrinkctl->nr_scanned unchanged after scan_objects is called.

So this patch adjusts shrinkctl->nr_scanned to the actual freed number
after scan_objects is called.

Signed-off-by: Wei Wang <wei.w.wang@...el.com>
Cc: Michal Hocko <mhocko@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Cc: Chris Wilson <chris@...is-wilson.co.uk>
Cc: Michael S. Tsirkin <mst@...hat.com>
---
 mm/vmscan.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 03822f8..78a75b9 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -447,9 +447,13 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
 		if (ret == SHRINK_STOP)
 			break;
 		freed += ret;
+		shrinkctl->nr_scanned = ret;
 
 		count_vm_events(SLABS_SCANNED, shrinkctl->nr_scanned);
-		total_scan -= shrinkctl->nr_scanned;
+		if (total_scan > shrinkctl->nr_scanned)
+			total_scan -= shrinkctl->nr_scanned;
+		else
+			total_scan = 0;
 		scanned += shrinkctl->nr_scanned;
 
 		cond_resched();
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ