From: Andreas Hindborg <a.hindborg@kernel.org>
To: Vlastimil Babka <vbabka@kernel.org>, Harry Yoo <harry@kernel.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
"Liam R. Howlett" <liam@infradead.org>,
Suren Baghdasaryan <surenb@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andreas Hindborg <a.hindborg@kernel.org>,
stable+noautosel@kernel.org
Subject: [PATCH 1/3] mm/slab: update the documentation of sheaf_capacity
Date: Wed, 25 Nov 2026 20:35:12 +0100 [thread overview]
Message-ID: <20261125-sheaf-doc-update-v1-1-4a579abaf0b8@kernel.org> (raw)
In-Reply-To: <20261125-sheaf-doc-update-v1-0-4a579abaf0b8@kernel.org>
The documentation of the sheaf_capacity member of struct kmem_cache_args
describes sheaves as an opt-in feature: a non-zero value enables sheaves of
the given capacity, and zero means that no sheaves are created.
This has not been the case since sheaves were added to most caches.
calculate_sheaf_capacity() now calculates a capacity from the object size
for all caches and returns the larger of that and the requested capacity.
The requested capacity is thus a minimum, and zero selects the calculated
capacity, as pointed out in [1].
Update the documentation to match. While at it, mention that a non-zero
value makes the cache unmergeable, that the requested capacity is also not
used when slab_tiny is enabled, and refer to the debugging parameter by its
current name, slab_debug.
The updated text refers to the slab_tiny boot parameter, which older
kernels do not have, so exclude the patch from stable autoselection.
Fixes: e47c897a2949 ("slab: add sheaves to most caches")
Cc: <stable+noautosel@kernel.org> # slab_tiny is not in older kernels
Link: https://lore.kernel.org/r/8a73da1c-0167-4aa5-a62c-4190327685cd@kernel.org [1]
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
include/linux/slab.h | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/include/linux/slab.h b/include/linux/slab.h
index ad645967a3ee..64daeb239f78 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -351,13 +351,12 @@ struct kmem_cache_args {
*/
void (*ctor)(void *);
/**
- * @sheaf_capacity: Enable sheaves of given capacity for the cache.
+ * @sheaf_capacity: Minimum capacity of the sheaves of the cache.
*
- * With a non-zero value, allocations from the cache go through caching
- * arrays called sheaves. Each cpu has a main sheaf that's always
- * present, and a spare sheaf that may be not present. When both become
- * empty, there's an attempt to replace an empty sheaf with a full sheaf
- * from the per-node barn.
+ * Allocations from the cache go through caching arrays called sheaves.
+ * Each cpu has a main sheaf that's always present, and a spare sheaf
+ * that may be not present. When both become empty, there's an attempt
+ * to replace an empty sheaf with a full sheaf from the per-node barn.
*
* When no full sheaf is available, and gfp flags allow blocking, a
* sheaf is allocated and filled from slab(s) using bulk allocation.
@@ -375,10 +374,19 @@ struct kmem_cache_args {
* Bulk allocation and free operations also try to use the cpu sheaves
* and barn, but fallback to using slab pages directly.
*
- * When slub_debug is enabled for the cache, the sheaf_capacity argument
- * is ignored.
+ * The allocator selects a default capacity for the sheaves based on the
+ * size of the objects in the cache, with larger objects giving a lower
+ * capacity. With a non-zero value, the capacity is at least the given
+ * value. Use this to match the expected maximum size passed to
+ * kmem_cache_prefill_sheaf(), to avoid low-performance oversize
+ * sheaves. A cache created with a non-zero value is not merged with
+ * other caches.
*
- * %0 means no sheaves will be created.
+ * When slab_tiny is enabled, or when slab_debug is enabled for the
+ * cache, no percpu sheaves are created and the requested capacity is
+ * not used. A non-zero value still prevents merging of the cache.
+ *
+ * %0 means the calculated capacity is used.
*/
unsigned int sheaf_capacity;
};
--
2.54.0
next prev parent reply other threads:[~2026-11-25 19:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 19:35 [PATCH 0/3] mm/slab: update the sheaf documentation in kmem_cache_args Andreas Hindborg
2026-11-25 19:35 ` Andreas Hindborg [this message]
2026-11-25 19:35 ` [PATCH 2/3] mm/slab: document that sheaf refill does not require blocking Andreas Hindborg
2026-11-25 19:35 ` [PATCH 3/3] mm/slab: document that local node allocations can use sheaves Andreas Hindborg
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=20261125-sheaf-doc-update-v1-1-4a579abaf0b8@kernel.org \
--to=a.hindborg@kernel.org \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=stable+noautosel@kernel.org \
--cc=surenb@google.com \
--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
all inboxes | Powered by JetHome®