* + mm-do-not-call-add_nr_deferred-with-zero-deferred.patch added to -mm tree
@ 2022-04-19 4:22 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-04-19 4:22 UTC (permalink / raw)
To: mm-commits, shy828301, shakeelb, mhocko, hannes, dchinner,
roman.gushchin, akpm
The patch titled
Subject: mm: do not call add_nr_deferred() with zero deferred
has been added to the -mm tree. Its filename is
mm-do-not-call-add_nr_deferred-with-zero-deferred.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-do-not-call-add_nr_deferred-with-zero-deferred.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-do-not-call-add_nr_deferred-with-zero-deferred.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Roman Gushchin <roman.gushchin@linux.dev>
Subject: mm: do not call add_nr_deferred() with zero deferred
add_nr_deferred() is often called with next_deferred equal to 0.
For instance, it's happening under low memory pressure for any
shrinkers with a low number of cached objects. A corresponding trace
looks like:
<...>-619914 [005] .... 467456.345160: mm_shrink_slab_end: \
super_cache_scan+0x0/0x1a0 0000000087027f06: nid: 1 \
unused scan count 0 new scan count 0 total_scan 0 \
last shrinker return val 0
<...>-619914 [005] .... 467456.345371: mm_shrink_slab_end: \
super_cache_scan+0x0/0x1a0 0000000087027f06: nid: 1 \
unused scan count 0 new scan count 0 total_scan 0 \
last shrinker return val 0
<...>-619914 [005] .... 467456.345380: mm_shrink_slab_end: \
super_cache_scan+0x0/0x1a0 0000000087027f06: nid: 1 unused \
scan count 0 new scan count 0 total_scan 0 \
last shrinker return val 0
This lead to unnecessary checks and atomic operations, which can be
avoided by checking next_deferred for not being zero before calling
add_nr_deferred(). In this case the mm_shrink_slab_end trace point will
get a potentially slightly outdated "new scan count" value, but it's
totally fine.
Link: https://lkml.kernel.org/r/20220416004104.4089743-1-roman.gushchin@linux.dev
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Yang Shi <shy828301@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/vmscan.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/mm/vmscan.c~mm-do-not-call-add_nr_deferred-with-zero-deferred
+++ a/mm/vmscan.c
@@ -808,7 +808,10 @@ static unsigned long do_shrink_slab(stru
* move the unused scan count back into the shrinker in a
* manner that handles concurrent updates.
*/
- new_nr = add_nr_deferred(next_deferred, shrinker, shrinkctl);
+ if (next_deferred)
+ new_nr = add_nr_deferred(next_deferred, shrinker, shrinkctl);
+ else
+ new_nr = nr;
trace_mm_shrink_slab_end(shrinker, shrinkctl->nid, freed, nr, new_nr, total_scan);
return freed;
_
Patches currently in -mm which might be from roman.gushchin@linux.dev are
mm-do-not-call-add_nr_deferred-with-zero-deferred.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-19 4:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 4:22 + mm-do-not-call-add_nr_deferred-with-zero-deferred.patch added to -mm tree Andrew Morton
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.