Re: [PATCH RFC 6/8] mm/slab: allow changing sheaf_capacity at runtime
From: Harry Yoo (Oracle)
Date: Mon May 18 2026 - 02:54:26 EST
On 5/17/26 5:30 PM, Yeoreum Yun wrote:
Hi Harry,
Hi Yeoreum,
@@ -9111,7 +9309,39 @@ static ssize_t sheaf_capacity_show(struct kmem_cache *s, char *buf)
{
return sysfs_emit(buf, "%hu\n", s->sheaf_capacity);
}
-SLAB_ATTR_RO(sheaf_capacity);
+static ssize_t sheaf_capacity_store(struct kmem_cache *s,
+ const char *buf, size_t length)
+{
+ unsigned short capacity;
+ int err;
+
+ err = kstrtou16(buf, 10, &capacity);
+ if (err)
+ return err;
+
+ if (!cache_supports_sheaves(s))
+ return -EOPNOTSUPP;
+
+ cpus_read_lock();
+ mutex_lock(&slab_mutex);
This patchset looks good to me.
Thanks :)
However, I’m not sure why we need slab_mutex here, as using only
flush_lock seems sufficient
The main reason why I used slab_mutex was because both disabling sheaves
and shrinking the cache acquires flush_lock.
Some refactoring might be required, but it seems better to remove
the acquisition of slab_mutex here.
With some refactoring, we could teach those functions that the caller
already acquired the lock and use flush_lock instead of slab_mutex.
However, it won't improve things much... both are global locks, and
I doubt that it would cause visible latency issues when creating new slab caches.
I want to focus on refining the capacity change part for now.
--
Cheers,
Harry / Hyeonggon