Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Harry Yoo <harry@kernel.org>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
	 David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	 "David Hildenbrand (Arm)" <david@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 Chris Mason <mason@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 2/4] mm/slab: handle __GFP_NOFAIL better with prefilled sheaves
Date: Wed, 2 Dec 2026 15:06:15 +0000	[thread overview]
Message-ID: <axAzFC7EFPJZY3ZB@thinkstation> (raw)
In-Reply-To: <20261201-slab-ai-fixes-v2-2-7419dfbd3bac@kernel.org>

On Tue, Dec 01, 2026 at 07:16:03PM +0100, Vlastimil Babka (SUSE) wrote:
> If a prefilled sheaf is requested with __GFP_NOFAIL in a
> gfp_pfmemalloc_allowed() context, the following can happen in the
> initial __GFP_NOMEMALOC attempt.
> 
>     refill_objects()              __GFP_NOFAIL | __GFP_NOMEMALLOC
>       new_slab()
>         __alloc_pages_may_oom()
>           if (gfp_mask & __GFP_NOFAIL)
>             ALLOC_NO_WATERMARKS   the slab is pfmemalloc
>       alloc_from_new_slab()       its objects go into the sheaf
> 
> So the sheaf should be marked pfmemalloc, but isn't. Fix this by
> precisely determining in the refill path, whether a pfmemalloc slab was
> used to refill the sheaf, whether it was on the partial list or newly
> allocated.
> 
> Additionally, remove the __GFP_NOFAIL from the initial nomemalloc
> attempt so it really cannot end up with a pfmemalloc slab, as intended.
> 
> For consistency, also adjust kmem_cache_return_sheaf() in case somebody
> would hypothetically call it with __GFP_NOFAIL. Just drop it
> unconditionally and also add __GFP_NORETRY there to make returns
> cheaper - in a low memory situation, keeping the sheaf from being
> flushed isn't a priority.
> 
> Reported-by: Chris Mason <mason@kernel.org>
> Fixes: 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with sheaves")
> Cc: <stable@vger.kernel.orG>

s/orG/org/

I'll fix it when applying it :)

> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> ---

Looks good to me,
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>

-- 
Cheers,
Harry / Hyeonggon

  reply	other threads:[~2026-12-02 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 18:16 [PATCH v2 0/4] slab AI fixes Vlastimil Babka (SUSE)
2026-12-01 18:16 ` [PATCH v2 1/4] mm/slab: drop __GFP_NOFAIL when refilling sheaves Vlastimil Babka (SUSE)
2026-12-01 18:16 ` [PATCH v2 2/4] mm/slab: handle __GFP_NOFAIL better with prefilled sheaves Vlastimil Babka (SUSE)
2026-12-02 15:06   ` Harry Yoo [this message]
2026-12-01 18:16 ` [PATCH v2 3/4] mm/slab: keep caches that drop debug flags unmergeable Vlastimil Babka (SUSE)
2026-12-01 18:16 ` [PATCH v2 4/4] mm/slab: clear stale layout values in calculate_sizes() 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=axAzFC7EFPJZY3ZB@thinkstation \
    --to=harry@kernel.org \
    --cc=cl@gentwo.org \
    --cc=david@kernel.org \
    --cc=hao.li@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mason@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@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