From: Shakeel Butt <shakeelb@google.com>
To: David Rientjes <rientjes@google.com>
Cc: Jason@zx2c4.com, Linux MM <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] slub: fix __kmem_cache_empty for !CONFIG_SLUB_DEBUG
Date: Tue, 19 Jun 2018 18:24:32 -0700 [thread overview]
Message-ID: <CALvZod7A+QC5OqYNx-kQcJYOQmeSm8ie9JGnh3_-CUfYn7jpOA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1806191748040.25812@chino.kir.corp.google.com>
On Tue, Jun 19, 2018 at 5:49 PM David Rientjes <rientjes@google.com> wrote:
>
> On Tue, 19 Jun 2018, Shakeel Butt wrote:
>
> > diff --git a/mm/slub.c b/mm/slub.c
> > index a3b8467c14af..731c02b371ae 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -3673,9 +3673,23 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
> >
> > bool __kmem_cache_empty(struct kmem_cache *s)
> > {
> > - int node;
> > + int cpu, node;
>
> Nit: wouldn't cpu be unused if CONFIG_SLUB_DEBUG is disabled?
>
I think I didn't get the warning as I didn't use #ifdef.
> > struct kmem_cache_node *n;
> >
> > + /*
> > + * slabs_node will always be 0 for !CONFIG_SLUB_DEBUG. So, manually
> > + * check slabs for all cpus.
> > + */
> > + if (!IS_ENABLED(CONFIG_SLUB_DEBUG)) {
> > + for_each_online_cpu(cpu) {
> > + struct kmem_cache_cpu *c;
> > +
> > + c = per_cpu_ptr(s->cpu_slab, cpu);
> > + if (c->page || slub_percpu_partial(c))
> > + return false;
> > + }
> > + }
> > +
> > for_each_kmem_cache_node(s, node, n)
> > if (n->nr_partial || slabs_node(s, node))
> > return false;
>
> Wouldn't it just be better to allow {inc,dec}_slabs_node() to adjust the
> nr_slabs counter instead of doing the per-cpu iteration on every shutdown?
Yes that is doable as the functions {inc,dec}_slabs_node() are called
in slow path. I can move them out of CONFIG_SLUB_DEBUG. I think the
reason 0f389ec63077 ("slub: No need for per node slab counters if
!SLUB_DEBUG") put them under CONFIG_SLUB_DEBUG is because these
counters were only read through sysfs API which were disabled on
!CONFIG_SLUB_DEBUG. However we have a usecase other than sysfs API.
Please let me know if there is any objection to this conversion. For
large machines I think this is preferable approach.
thanks,
Shakeel
next prev parent reply other threads:[~2018-06-20 1:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 21:33 Shakeel Butt
2018-06-19 21:38 ` Shakeel Butt
2018-06-19 21:53 ` Jason A. Donenfeld
2018-06-19 22:21 ` Andrew Morton
2018-06-20 0:49 ` David Rientjes
2018-06-20 1:24 ` Shakeel Butt [this message]
2018-06-20 12:09 ` Andrey Ryabinin
2018-06-20 21:36 ` Shakeel Butt
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=CALvZod7A+QC5OqYNx-kQcJYOQmeSm8ie9JGnh3_-CUfYn7jpOA@mail.gmail.com \
--to=shakeelb@google.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=stable@vger.kernel.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