All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harry Yoo <harry@kernel.org>
To: Qing Wang <wangqing7171@gmail.com>
Cc: Vlastimil Babka <vbabka@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
	 David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/slab: only require the requested size when refilling prefilled sheaves
Date: Fri, 23 Oct 2026 15:22:09 +0100	[thread overview]
Message-ID: <attrLy_Q-53FnjhL@thinkstation> (raw)
In-Reply-To: <20261023094401.2042862-1-wangqing7171@gmail.com>

On Fri, Oct 23, 2026 at 05:44:01PM +0800, Qing Wang wrote:
> kmem_cache_prefill_sheaf() and kmem_cache_refill_sheaf() only guarantee
> @size objects, but for standard capacity sheaves
> __prefill_sheaf_pfmemalloc() uses refill_sheaf(), which actually fills
> the sheaf up to s->sheaf_capacity.
>
> The call thus fails with -ENOMEM > whenever the sheaf cannot be filled
> completely, even when @size objects were already obtained.

This is extremely rare condition to happen, and so...

> This leads to needless flushing of the partially
> filled sheaf in kmem_cache_prefill_sheaf(),

It doesn't make much sense to micro-optimize slab in low or out of
memory situations.

> and may use pfmemalloc
> reserves to fill the sheaf beyond what was requested.

But the request size itself is a speculation and unused objects will be
returned back to the allocator anyway.

> Pass the @size from kmem_cache_prefill_sheaf() and
> kmem_cache_refill_sheaf() down to __prefill_sheaf_pfmemalloc(), and have
> it use the newly added refill_sheaf_min(), which returns success once
> the sheaf holds @min_size objects while still trying to fill it up to
> s->sheaf_capacity.
> 
> refill_sheaf() remains the full-capacity variant for
> __pcs_replace_empty_main() and kmem_cache_return_sheaf(), because sheaves
> on the barn's full list must be full.
>
> Signed-off-by: Qing Wang <wangqing7171@gmail.com>

-- 
Cheers,
Harry / Hyeonggon


  reply	other threads:[~2026-10-23 14:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  9:44 [PATCH] mm/slab: only require the requested size when refilling prefilled sheaves Qing Wang
2026-10-23 14:22 ` Harry Yoo [this message]
2026-10-26  9:29   ` [PATCH] mm/slab: only require the requested size when refilling Qing Wang

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=attrLy_Q-53FnjhL@thinkstation \
    --to=harry@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=hao.li@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=wangqing7171@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.