linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 David Rientjes <rientjes@google.com>,
	Christoph Lameter <cl@linux.com>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	 Imran Khan <imran.f.khan@oracle.com>
Subject: Re: Question about freeing of empty per-CPU partial slabs in SLUB
Date: Fri, 13 Sep 2024 15:27:01 +0200	[thread overview]
Message-ID: <CA+fCnZfc5yhxkE+DQeOWcstH9P6g7T96eyCF4wzYXWNVfFrQ1A@mail.gmail.com> (raw)
In-Reply-To: <c71a884d-714f-4741-906f-4df162bde303@suse.cz>

On Thu, Sep 12, 2024 at 10:34 AM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> > "If the partial slab becomes an empty slab after freeing up the
> > object, it will be left in its current list if the number of partial
> > slabs for the concerned node is within the limits (i.e < slab cache’s
> > min_partial). This applies to both slabs belonging to a per-cpu
> > partial slab list and slabs belonging to a per-node partial slab list.
> > If the number of partial slabs are outside the limit (i.e >= slab
> > cache’s min partial) then the newly available empty slab is freed and
> > is removed from the corresponding partial slab list."
> >
> > The part that seems wrong to me here is the statement that this
> > applies to the per-CPU partial list. Based on the code in __slab_free,
> > it looks like it cannot reach the slab_empty label for a slab that is
> > on the per-CPU partial list.
> >
> > (I know that an empty per-CPU partial slab can be freed when the list
> > overflows or via shrinking, the question is about the slab being freed
> > directly by __slab_free.)
> >
> > Is the article wrong with regards to this case? Or did this behavior
> > change recently (I failed found any traces of this)?
>
> I don't think the behavior changed recently in this aspect, only in some
> other details like tracking on_node_partial with a page flag for better
> performance, and slabs on per-cpu partial list are no longer frozen.
>
> I think the paragraph you quoted can be interpreted together with this part
> of the preceding one: "However while putting this partial slab on a per-cpu
> partial slab list if it is found that the per-cpu partial slab list is
> already full, then all slabs from the per-cpu partial slab list are unfrozen
> i.e they are moved to a per-node partial slab list and this new partial slab
> is put on the per-cpu partial slab list."
>
> So while flushing the per-cpu partial list, the per-cpu partial slabs are
> moved to per-node partial list, and when __put_partials() finds some of them
> are empty, it applies the same s->min_partial threshold to decide whether to
> keep them in node partial list or free them. So in that sense "This applies
> to both..." part is correct, although as you say it cannot immediately
> affect a slab on partial list we are freeing to.

Ack, thank you for the response!


      reply	other threads:[~2024-09-13 13:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 16:38 Andrey Konovalov
2024-09-12  8:34 ` Vlastimil Babka
2024-09-13 13:27   ` Andrey Konovalov [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=CA+fCnZfc5yhxkE+DQeOWcstH9P6g7T96eyCF4wzYXWNVfFrQ1A@mail.gmail.com \
    --to=andreyknvl@gmail.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=cl@linux.com \
    --cc=imran.f.khan@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /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