All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, Shakeel Butt <shakeelb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>, <kernel-team@fb.com>,
	<linux-kernel@vger.kernel.org>, Michal Hocko <mhocko@suse.com>
Subject: Re: [PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure
Date: Thu, 3 Sep 2020 22:02:47 -0700	[thread overview]
Message-ID: <20200904050205.GA483835@carbon.lan> (raw)
In-Reply-To: <20200903211059.7dc9530e6d988eaeefe53cf7@linux-foundation.org>

On Thu, Sep 03, 2020 at 09:10:59PM -0700, Andrew Morton wrote:
> On Thu, 3 Sep 2020 16:00:55 -0700 Roman Gushchin <guro@fb.com> wrote:
> 
> > In the memcg case count_shadow_nodes() sums the number of pages in lru
> > lists and the amount of slab memory (reclaimable and non-reclaimable)
> > as a baseline for the allowed number of shadow entries.
> > 
> > It seems to be a good analogy for the !memcg case, where
> > node_present_pages() is used. However, it's not quite true, as there
> > two problems:
> > 
> > 1) Due to slab reparenting introduced by commit fb2f2b0adb98 ("mm:
> > memcg/slab: reparent memcg kmem_caches on cgroup removal") local
> > per-lruvec slab counters might be inaccurate on non-leaf levels.
> > It's the only place where local slab counters are used.
> > 
> > 2) Shadow nodes by themselves are backed by slabs. So there is a loop
> > dependency: the more shadow entries are there, the less pressure the
> > kernel applies to reclaim them.
> > 
> > Fortunately, there is a simple way to solve both problems: slab
> > counters shouldn't be taken into the account by count_shadow_nodes().
> > 
> > ...
> >
> > --- a/mm/workingset.c
> > +++ b/mm/workingset.c
> > @@ -495,10 +495,6 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
> >  		for (pages = 0, i = 0; i < NR_LRU_LISTS; i++)
> >  			pages += lruvec_page_state_local(lruvec,
> >  							 NR_LRU_BASE + i);
> > -		pages += lruvec_page_state_local(
> > -			lruvec, NR_SLAB_RECLAIMABLE_B) >> PAGE_SHIFT;
> > -		pages += lruvec_page_state_local(
> > -			lruvec, NR_SLAB_UNRECLAIMABLE_B) >> PAGE_SHIFT;
> >  	} else
> >  #endif
> >  		pages = node_present_pages(sc->nid);
> 
> Did this have any observable runtime effects?

Most likely not.

I maybe saw the second effect once, but it was backed up by a bug in the inode
reclaim path in the exact kernel version I used (not an upstream one).

The first problem is pure theoretical, I'm just not comfortable with using these
counters, which are known to be inaccurate after reparenting.

That's why I didn't add stable@.

Thanks!


  reply	other threads:[~2020-09-04  5:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 23:00 [PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure Roman Gushchin
2020-09-04  4:10 ` Andrew Morton
2020-09-04  5:02   ` Roman Gushchin [this message]
2020-09-09 14:55 ` Johannes Weiner
2020-09-09 16:55   ` Roman Gushchin
2020-09-10 17:50     ` Johannes Weiner

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=20200904050205.GA483835@carbon.lan \
    --to=guro@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=shakeelb@google.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.