* [PATCH] mm: do not stall register_shrinker()
@ 2019-05-02 20:09 Robert Kolchmeyer
2019-05-05 13:17 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Robert Kolchmeyer @ 2019-05-02 20:09 UTC (permalink / raw)
To: stable
Cc: Minchan Kim, Shakeel Butt, Johannes Weiner, Michal Hocko,
Tetsuo Handa, Anshuman Khandual, Robert Kolchmeyer
From: Minchan Kim <minchan@kernel.org>
commit e496612c5130567fc9d5f1969ca4b86665aa3cbb upstream.
Shakeel Butt reported he has observed in production systems that the job
loader gets stuck for 10s of seconds while doing a mount operation. It
turns out that it was stuck in register_shrinker() because some
unrelated job was under memory pressure and was spending time in
shrink_slab(). Machines have a lot of shrinkers registered and jobs
under memory pressure have to traverse all of those memcg-aware
shrinkers and affect unrelated jobs which want to register their own
shrinkers.
To solve the issue, this patch simply bails out slab shrinking if it is
found that someone wants to register a shrinker in parallel. A downside
is it could cause unfair shrinking between shrinkers. However, it
should be rare and we can add compilcated logic if we find it's not
enough.
[akpm@linux-foundation.org: tweak code comment]
Link: http://lkml.kernel.org/r/20171115005602.GB23810@bbox
Link: http://lkml.kernel.org/r/1511481899-20335-1-git-send-email-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Reported-by: Shakeel Butt <shakeelb@google.com>
Tested-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[rkolchmeyer: Backported to 4.14: adjusted context]
Signed-off-by: Robert Kolchmeyer <rkolchmeyer@google.com>
---
Backport of commit e496612c5130567fc9d5f1969ca4b86665aa3cbb upstream.
We would like to apply this to linux-4.14.y.
I needed to change the patch context for the patch to apply to linux-4.14.y.
The actual fix remains unchanged.
mm/vmscan.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9734e62654fa..99837e931f53 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -502,6 +502,15 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
sc.nid = 0;
freed += do_shrink_slab(&sc, shrinker, nr_scanned, nr_eligible);
+ /*
+ * Bail out if someone want to register a new shrinker to
+ * prevent the regsitration from being stalled for long periods
+ * by parallel ongoing shrinking.
+ */
+ if (rwsem_is_contended(&shrinker_rwsem)) {
+ freed = freed ? : 1;
+ break;
+ }
}
up_read(&shrinker_rwsem);
--
2.21.0.593.g511ec345e18-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm: do not stall register_shrinker()
2019-05-02 20:09 [PATCH] mm: do not stall register_shrinker() Robert Kolchmeyer
@ 2019-05-05 13:17 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-05-05 13:17 UTC (permalink / raw)
To: Robert Kolchmeyer
Cc: stable, Minchan Kim, Shakeel Butt, Johannes Weiner, Michal Hocko,
Tetsuo Handa, Anshuman Khandual
On Thu, May 02, 2019 at 01:09:05PM -0700, Robert Kolchmeyer wrote:
> From: Minchan Kim <minchan@kernel.org>
>
> commit e496612c5130567fc9d5f1969ca4b86665aa3cbb upstream.
>
> Shakeel Butt reported he has observed in production systems that the job
> loader gets stuck for 10s of seconds while doing a mount operation. It
> turns out that it was stuck in register_shrinker() because some
> unrelated job was under memory pressure and was spending time in
> shrink_slab(). Machines have a lot of shrinkers registered and jobs
> under memory pressure have to traverse all of those memcg-aware
> shrinkers and affect unrelated jobs which want to register their own
> shrinkers.
>
> To solve the issue, this patch simply bails out slab shrinking if it is
> found that someone wants to register a shrinker in parallel. A downside
> is it could cause unfair shrinking between shrinkers. However, it
> should be rare and we can add compilcated logic if we find it's not
> enough.
>
> [akpm@linux-foundation.org: tweak code comment]
> Link: http://lkml.kernel.org/r/20171115005602.GB23810@bbox
> Link: http://lkml.kernel.org/r/1511481899-20335-1-git-send-email-minchan@kernel.org
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> Reported-by: Shakeel Butt <shakeelb@google.com>
> Tested-by: Shakeel Butt <shakeelb@google.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> [rkolchmeyer: Backported to 4.14: adjusted context]
> Signed-off-by: Robert Kolchmeyer <rkolchmeyer@google.com>
> ---
> Backport of commit e496612c5130567fc9d5f1969ca4b86665aa3cbb upstream.
> We would like to apply this to linux-4.14.y.
> I needed to change the patch context for the patch to apply to linux-4.14.y.
> The actual fix remains unchanged.
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-05 13:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-02 20:09 [PATCH] mm: do not stall register_shrinker() Robert Kolchmeyer
2019-05-05 13:17 ` Greg KH
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.