Skip to contentSkip to conversation

mbcache: Simplify the allocation of slab caches

PATCH Applied Kunwu Chan 3 participants 3 messages Feb 1, 2024 VFS

lore
Share & tools
lore

Kunwu Chan

author
#0 lore raw

PATCH 1/1 mbcache: Simplify the allocation of slab caches

Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches.

---
 fs/mbcache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/mbcache.c +2 -3
index 82aa7a35db26..fe2624e17253 100644
@@ -426,9 +426,8 @@ EXPORT_SYMBOL(mb_cache_destroy);
 
 static int __init mbcache_init(void)
 {
-	mb_entry_cache = kmem_cache_create("mbcache",
-				sizeof(struct mb_cache_entry), 0,
-				SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL);
+	mb_entry_cache = KMEM_CACHE(mb_cache_entry,
+					 SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD);
 	if (!mb_entry_cache)
 		return -ENOMEM;
 	return 0;
Signature · 1 line
2.39.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Kunwu Chan

Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches.

Looks good. Feel free to add:

Honza

Quoted 23 lines
---
 fs/mbcache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/mbcache.c +2 -3
index 82aa7a35db26..fe2624e17253 100644
@@ -426,9 +426,8 @@ EXPORT_SYMBOL(mb_cache_destroy);
 
 static int __init mbcache_init(void)
 {
-	mb_entry_cache = kmem_cache_create("mbcache",
-				sizeof(struct mb_cache_entry), 0,
-				SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL);
+	mb_entry_cache = KMEM_CACHE(mb_cache_entry,
+					 SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD);
 	if (!mb_entry_cache)
 		return -ENOMEM;
 	return 0;
Signature · 1 line
2.39.2
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
In reply to Kunwu Chan
Quoted 4 lines · Kunwu Chan

Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches.

Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/1] mbcache: Simplify the allocation of slab caches

      https://git.kernel.org/vfs/vfs/c/879fe799ad2b