Re: [PATCH v5 09/12] rust: mm: sheaf: allow use of C initialized static caches
From: Andreas Hindborg
Date: Tue Nov 17 2026 - 10:28:39 EST
"Vlastimil Babka (SUSE)" <vbabka@xxxxxxxxxx> writes:
> On 9/2/26 15:26, Andreas Hindborg wrote:
>> Extend the sheaf abstraction to support caches initialized by C at kernel
>> boot time, in addition to dynamically created Rust caches.
>
> Nit: in C code caches can be also dynamically created :)
Right. But the Rust abstractions do not support interacting with those. Only
dynamic caches created through the Rust API or static ones created in C
are supported.
>
>> Introduce `KMemCache<T>` as a transparent wrapper around `kmem_cache` for
>> static caches with `'static` lifetime. Rename the previous `KMemCache<T>`
>> to `KMemCacheHandle<T>` to represent dynamically created, reference-counted
>> caches.
>>
>> Add `Static` and `Dynamic` marker types along with `StaticSheaf` and
>> `DynamicSheaf` type aliases to distinguish sheaves from each cache type.
>> The `Sheaf` type now carries lifetime and allocation mode type parameters.
>>
>> Add `SBox::into_ptr()` and `SBox::static_from_ptr()` methods for passing
>> allocations through C code via raw pointers.
>>
>> Add `KMemCache::from_raw()` for wrapping C-initialized static caches and
>> `Sheaf::refill()` for replenishing a sheaf to a minimum size.
>>
>> Export `kmem_cache_prefill_sheaf`, `kmem_cache_return_sheaf`,
>> `kmem_cache_refill_sheaf`, and `kmem_cache_alloc_from_sheaf_noprof` to
>> allow Rust module code to use the sheaf API.
>>
>> Cc: Vlastimil Babka <vbabka@xxxxxxx>
>> Cc: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>
>> Cc: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
>> Cc: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
>> Cc: linux-mm@xxxxxxxxx
>> Assisted-by: LLM
>> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
>
> Acked-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
Thanks!
Best regards,
Andreas Hindborg