From: Shantanu Goel <sgoel01@yahoo.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: [PATCH] vmscan: Skip slab scan when LRU size is zero
Date: Sat, 4 Feb 2017 13:53:01 +0000 (UTC) [thread overview]
Message-ID: <1837390276.846271.1486216381871@mail.yahoo.com> (raw)
In-Reply-To: 1837390276.846271.1486216381871.ref@mail.yahoo.com
[-- Attachment #1: Type: text/plain, Size: 1618 bytes --]
Hi,
I am running 4.9.7 and noticed the slab was being scanned very aggressively (200K objects scanned for 1K LRU pages). Turning on tracing in do_shrink_slab() revealed it was sometimes being called with a LRU size of zero causing the LRU scan ratio to be very large. The attached patch skips shrinking the slab when the LRU size is zero. After applying the patch the slab size I no longer see the extremely large object scan values.
Trace output when LRU size is 0:
kswapd0-93 [005] .... 49736.760169: mm_shrink_slab_start: scan_shadow_nodes+0x0/0x50 ffffffff94e6e460: nid: 0 objects to shrink 59291940 gfp_flags GFP_KERNEL pgs_scanned 32 lru_pgs 0 cache items 20 delta 1280 total_scan 40
kswapd0-93 [005] .... 49736.760207: mm_shrink_slab_start: super_cache_scan+0x0/0x1a0 ffff9d79ce488cc0: nid: 0 objects to shrink 22740669 gfp_flags GFP_KERNEL pgs_scanned 32 lru_pgs 0 cache items 1 delta 64 total_scan 2
kswapd0-93 [005] .... 49736.760216: mm_shrink_slab_start: super_cache_scan+0x0/0x1a0 ffff9d79db59ecc0: nid: 0 objects to shrink 79098834 gfp_flags GFP_KERNEL pgs_scanned 32 lru_pgs 0 cache items 642 delta 41088 total_scan 1284
kswapd0-93 [005] .... 49736.760769: mm_shrink_slab_start: super_cache_scan+0x0/0x1a0 ffff9d79ce488cc0: nid: 0 objects to shrink 22740729 gfp_flags GFP_KERNEL pgs_scanned 32 lru_pgs 0 cache items 1 delta 64 total_scan 2
kswapd0-93 [005] .... 49736.766125: mm_shrink_slab_start: scan_shadow_nodes+0x0/0x50 ffffffff94e6e460: nid: 0 objects to shrink 59293180 gfp_flags GFP_KERNEL pgs_scanned 32 lru_pgs 0 cache items 32 delta 2048 total_scan 64
Thanks,
Shantanu
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-vmscan-do-not-shrink-slab-if-LRU-size-is-0.patch --]
[-- Type: text/x-patch, Size: 815 bytes --]
From 97817fc71e1fd0e8fe3f385b00dd16ed64f655ab Mon Sep 17 00:00:00 2001
From: Shantanu Goel <sgoel01@yahoo.com>
Date: Fri, 3 Feb 2017 15:05:57 -0500
Subject: [PATCH] vmscan: do not shrink slab if LRU size is 0
Some memcg's may not have any LRU pages in them so
shrink_slab incorrectly ends up free'ing a huge portion
of the slab.
Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
---
mm/vmscan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4205b3e..7682469 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -445,6 +445,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)))
return 0;
+ if (nr_eligible == 0)
+ return 0;
+
if (nr_scanned == 0)
nr_scanned = SWAP_CLUSTER_MAX;
--
2.7.4
next parent reply other threads:[~2017-02-04 13:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1837390276.846271.1486216381871.ref@mail.yahoo.com>
2017-02-04 13:53 ` Shantanu Goel [this message]
2017-02-06 8:30 ` [PATCH] vmscan: Skip slab scan when LRU size is zero Michal Hocko
2017-02-07 0:47 ` Shantanu Goel
2017-02-08 13:37 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1837390276.846271.1486216381871@mail.yahoo.com \
--to=sgoel01@yahoo.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).