From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: hu.shengming@zte.com.cn, harry@kernel.org, akpm@linux-foundation.org
Cc: hao.li@linux.dev, cl@gentwo.org, rientjes@google.com,
roman.gushchin@linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, zhang.run@zte.com.cn,
cai.qu@zte.com.cn
Subject: Re: [PATCH v3] mm/slub: prevent pfmemalloc objects from entering the barn
Date: Tue, 21 Jul 2026 09:41:36 +0200 [thread overview]
Message-ID: <234c56b7-4036-4d03-8d8d-6298d16c3a77@kernel.org> (raw)
In-Reply-To: <01ea11f8-65b4-4941-adf7-423c3f000292@kernel.org>
On 7/21/26 09:34, Vlastimil Babka (SUSE) wrote:
> On 7/21/26 02:45, hu.shengming@zte.com.cn wrote:
>> From: Shengming Hu <hu.shengming@zte.com.cn>
>>
>> kmem_cache_return_sheaf() may refill a partially consumed sheaf before
>> placing it in the barn. Without an explicit restriction, this refill may
>> draw objects from pfmemalloc slabs and consume emergency reserves.
>>
>> Add __GFP_NOMEMALLOC so that returned sheaves are refilled only from
>> non-pfmemalloc slabs. Also add __GFP_NOWARN, as suggested by Hao Li,
>> because this refill is a best-effort attempt and failure is acceptable.
>> If the refill fails, flush and free the sheaf instead.
>>
>> Fixes: 3c1ea5c5019f ("slab: sheaf prefilling for guaranteed allocations")
>
> Wonder if 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with
> sheaves") is a better match. Until that commit we just didn't care, and it
> seems like this is a case that commit missed?
Added to slab/for-next with changed Fixes: per above, but can adjust it
further if it was wrong. Thanks!
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
>> ---
>> Changes in v3:
>> - Replace “normal memory” with the more precise “non-pfmemalloc slabs”,
>> and add Fixes: and Cc: stable@vger.kernel.org, as suggested by Harry.
>> - Link to v2: https://lore.kernel.org/all/20260720211127124sYtTNbvsxCXN9_pDh-pwt@zte.com.cn/
>>
>> Changes in v2:
>> - Add __GFP_NOWARN as suggested by Hao.
>> - Link to v1: https://lore.kernel.org/all/20260719113701797vZ3R8NxiqYt8dEfeUxtON@zte.com.cn/
>>
>> ---
>> mm/slub.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 53b4976d3831..357b7522c817 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -5123,7 +5123,7 @@ void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp,
>> * simply flush and free it.
>> */
>> if (!barn || data_race(barn->nr_full) >= MAX_FULL_SHEAVES ||
>> - refill_sheaf(s, sheaf, gfp)) {
>> + refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
>> sheaf_flush_unused(s, sheaf);
>> free_empty_sheaf(s, sheaf);
>> return;
>
next prev parent reply other threads:[~2026-07-21 7:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 0:45 hu.shengming
2026-07-21 5:03 ` Harry Yoo
2026-07-21 6:10 ` Hao Li
2026-07-21 7:34 ` Vlastimil Babka (SUSE)
2026-07-21 7:41 ` Vlastimil Babka (SUSE) [this message]
2026-07-21 9:04 ` hu.shengming
2026-07-21 15:42 ` Harry Yoo
2026-07-21 8:06 ` Vlastimil Babka (SUSE)
2026-07-21 9:17 ` hu.shengming
2026-07-21 14:27 ` Harry Yoo
2026-07-21 14:43 ` Vlastimil Babka (SUSE)
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=234c56b7-4036-4d03-8d8d-6298d16c3a77@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cai.qu@zte.com.cn \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=hu.shengming@zte.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=zhang.run@zte.com.cn \
/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
all inboxes | Powered by JetHome®