From: Harry Yoo <harry@kernel.org>
To: hu.shengming@zte.com.cn, vbabka@kernel.org
Cc: akpm@linux-foundation.org, 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 23:27:39 +0900 [thread overview]
Message-ID: <85ddd27a-ade6-4f27-80ab-cb91caa4e171@kernel.org> (raw)
In-Reply-To: <20260721171753509I9L8xNy2kiOGQFKloTnrG@zte.com.cn>
[-- Attachment #1.1: Type: text/plain, Size: 2425 bytes --]
On 7/21/26 6:17 PM, hu.shengming@zte.com.cn wrote:
> Vlastimil 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")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
>>
>> Ah so per sashiko [1] we should consider adding also a __GFP_NORETRY to
>> avoid an OOM kill. Seems reasonable that an API for returning memory should
>> not cause an OOM kill... it's unusual enough that it takes gfp flags
Ideally the caller should not specify gfp flags that could invoke
OOMs.... but even GFP_KERNEL for non-costly order could invoke them.
> but I
> thought defaulting to GFP_NOWAIT would be an unnecessary limitation.
I think it's reasonable to drop gfp parameter and default to GFP_NOWAIT
rather than relying on the callers to avoid OOMs or implicitly
overriding the behavior.
It wouldn't be too limiting given that it's for returning memory (!) and
other free APIs don't take GFP flags and assume GFP_NOWAIT e.g.) when
allocating a new sheaf.
> I can add __GFP_NORETRY locally if others agree.
>
>> [1]
>> https://sashiko.dev/#/patchset/20260721084522552ZPa16p1SRj3PYat3sqxuN%40zte.com.cn
>
> Agreed, adding __GFP_NORETRY seems reasonable, since this best-effort
> refill should not trigger the OOM killer.
>
> However, I wonder whether the same scope consideration that Harry raised
> for __GFP_NOFAIL also applies here, and whether __GFP_NORETRY should be
> discussed separately rather than folded into this pfmemalloc fix.
Agreed that this is an independent issue.
> The earlier discussion is here:
>
> [2]
> https://lore.kernel.org/linux-mm/33a1cb67-8d23-4b51-b4d8-9e95e8de00c7@kernel.org/
>
> --
> With Best Regards,
> Shengming
--
Cheers,
Harry / Hyeonggon
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-07-21 14:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 0:45 [PATCH v3] mm/slub: prevent pfmemalloc objects from entering the barn 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)
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 [this message]
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=85ddd27a-ade6-4f27-80ab-cb91caa4e171@kernel.org \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cai.qu@zte.com.cn \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--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=vbabka@kernel.org \
--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