From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Harry Yoo <harry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Jesper Dangaard Brouer <hawk@kernel.org>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, io-uring@vger.kernel.org,
kasan-dev@googlegroups.com, bpf@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: improve the kmem_cache_alloc_bulk API
Date: Wed, 27 May 2026 11:11:31 +0200 [thread overview]
Message-ID: <ee817070-cc7a-40d5-92a4-2bd8e9e65fbe@kernel.org> (raw)
In-Reply-To: <20260527070239.2252948-1-hch@lst.de>
On 5/27/26 09:02, Christoph Hellwig wrote:
> Hi all,
>
> kmem_cache_alloc_bulk has a very unintuitive and undocumented return
> value convention. Fix that and add documentation.
>
> Note that the few comments explaining it mention that the gfp flags
> must allow "spinning". That's not really a term used in the memory
> allocator, is this supposed to mean "block" or "sleep"?
Page allocator now has alloc_pages_nolock() for when no spinning is
possible, and it uses ALLOC_TRYLOCK internally.
Slab has kmalloc_nolock() relying on that when it needs new pages.
In terms of gfp flags, such context is currently indicated by lack of
__GFP_KSWAPD_RECLAIM, where lack of __GFP_DIRECT_RECLAIM only means "no
sleeping" - see gfpflags_allow_spinning(). Slab uses it internally as
there's no ALLOC_TRYLOCK, but also there are callers from memcg and stackdepot.
Like the rest of gfp flags it's far from ideal, maybe we'll figure out a
better design eventually.
> Diffstat:
> drivers/gpu/drm/msm/msm_iommu.c | 6 +--
> drivers/gpu/drm/panthor/panthor_mmu.c | 12 ++-----
> include/linux/slab.h | 6 ++-
> io_uring/io_uring.c | 23 +++++--------
> lib/test_meminit.c | 19 +++++------
> mm/kasan/kasan_test_c.c | 5 +-
> mm/kfence/kfence_test.c | 9 ++---
> mm/slub.c | 58 ++++++++++++++++++----------------
> net/bpf/test_run.c | 7 +---
> net/core/skbuff.c | 23 +++++++------
> tools/include/linux/slab.h | 2 -
> tools/testing/shared/linux.c | 19 ++++-------
> 12 files changed, 92 insertions(+), 97 deletions(-)
next prev parent reply other threads:[~2026-05-27 9:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 7:02 improve the kmem_cache_alloc_bulk API Christoph Hellwig
2026-05-27 7:02 ` [PATCH] mm/slab: improve kmem_cache_alloc_bulk Christoph Hellwig
2026-05-27 7:53 ` bot+bpf-ci
2026-05-27 8:51 ` Jesper Dangaard Brouer
2026-05-27 13:56 ` Alexander Lobakin
2026-05-27 14:07 ` Christoph Hellwig
2026-05-27 9:38 ` Vlastimil Babka (SUSE)
2026-05-27 12:20 ` Christoph Hellwig
2026-05-27 9:11 ` Vlastimil Babka (SUSE) [this message]
2026-05-27 12:21 ` improve the kmem_cache_alloc_bulk API Christoph Hellwig
2026-05-27 14:07 ` 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=ee817070-cc7a-40d5-92a4-2bd8e9e65fbe@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bpf@vger.kernel.org \
--cc=cl@gentwo.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=hawk@kernel.org \
--cc=hch@lst.de \
--cc=io-uring@vger.kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
/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