All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Gushchin <roman.gushchin@linux.dev>
To: Dave Chinner <dchinner@redhat.com>
Cc: David Hildenbrand <david@redhat.com>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Shakeel Butt <shakeelb@google.com>,
	Yang Shi <shy828301@gmail.com>
Subject: Re: [PATCH] mm: do not call add_nr_deferred() with zero deferred
Date: Thu, 21 Apr 2022 19:36:45 -0700	[thread overview]
Message-ID: <YmIUvdjSlRD6udQg@carbon> (raw)
In-Reply-To: <YmICiX2DFSveY17Z@rh>

On Fri, Apr 22, 2022 at 11:19:05AM +1000, Dave Chinner wrote:
> On Tue, Apr 19, 2022 at 09:42:30AM -0700, Roman Gushchin wrote:
> > On Tue, Apr 19, 2022 at 02:56:06PM +0200, David Hildenbrand wrote:
> > > On 16.04.22 02:41, Roman Gushchin wrote:
> > > > 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.
> > > 
> > > Sufficient improvement to justify added complexity for anybody reading
> > > that code?
> > 
> > I don't have any numbers and really doubt the difference is significant,
> 
> Never been able to measure it myself.
> 
> HwoeverI'd much prefer the tracepoint output stays accurate - I've had to
> post-process and/or graph the shrinker progress as reported by the
> start/end tracpoints to find problems in the algorithms in the past.
> That's why there is the additional complexity in the code to make
> sure the coutners are accurate in the first place.

Sure, no problems.

Andrew, can you, please, drop this patch?

Thanks!

      reply	other threads:[~2022-04-22  2:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16  0:41 [PATCH] mm: do not call add_nr_deferred() with zero deferred Roman Gushchin
2022-04-19 12:56 ` David Hildenbrand
2022-04-19 16:42   ` Roman Gushchin
2022-04-19 16:57     ` David Hildenbrand
2022-04-20 23:30       ` Yang Shi
2022-04-22  1:19     ` Dave Chinner
2022-04-22  2:36       ` Roman Gushchin [this message]

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=YmIUvdjSlRD6udQg@carbon \
    --to=roman.gushchin@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=dchinner@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=shakeelb@google.com \
    --cc=shy828301@gmail.com \
    /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 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.