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: <1511481899-20335-1-git-send-email-minchan@kernel.org>
Date:   Fri, 24 Nov 2017 09:04:59 +0900
From:   Minchan Kim <minchan@...nel.org>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        kernel-team <kernel-team@....com>,
        Minchan Kim <minchan@...nel.org>,
        Michal Hocko <mhocko@...e.com>,
        Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        Shakeel Butt <shakeelb@...gle.com>,
        Johannes Weiner <hannes@...xchg.org>
Subject: [PATCH] mm: Do not stall register_shrinker

Shakeel Butt reported, he have observed in production system that
the job loader gets stuck for 10s of seconds while doing mount
operation. It turns out that it was stuck in register_shrinker()
and some unrelated job was under memory pressure and spending time
in shrink_slab(). Machines have a lot of shrinkers registered and
jobs under memory pressure has to traverse all of those memcg-aware
shrinkers and do affect unrelated jobs which want to register their
own shrinkers.

To solve the issue, this patch simply bails out slab shrinking
once it found someone want to register shrinker in parallel.
A downside is it could cause unfair shrinking between shrinkers.
However, it should be rare and we can add compilcated logic once
we found it's not enough.

Link: http://lkml.kernel.org/r/20171115005602.GB23810@bbox
Cc: Michal Hocko <mhocko@...e.com>
Cc: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Acked-by: Johannes Weiner <hannes@...xchg.org>
Reported-and-tested-by: Shakeel Butt <shakeelb@...gle.com>
Signed-off-by: Shakeel Butt <shakeelb@...gle.com>
Signed-off-by: Minchan Kim <minchan@...nel.org>
---
 mm/vmscan.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6a5a72baccd5..6698001787bd 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -486,6 +486,14 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
 			sc.nid = 0;
 
 		freed += do_shrink_slab(&sc, shrinker, priority);
+		/*
+		 * bail out if someone want to register a new shrinker to
+		 * prevent long time stall by parallel ongoing shrinking.
+		 */
+		if (rwsem_is_contended(&shrinker_rwsem)) {
+			freed = freed ? : 1;
+			break;
+		}
 	}
 
 	up_read(&shrinker_rwsem);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ