diff mbox series

[RFC,3/6] slab: port KMEM_CACHE_USERCOPY() to kmem_cache_setup()

Message ID 20240902-work-kmem_cache_args-v1-3-27d05bc05128@kernel.org (mailing list archive)
State New
Headers show
Series slab: add kmem_cache_setup() | expand

Commit Message

Christian Brauner Sept. 2, 2024, 3:31 p.m. UTC
Make KMEM_CACHE_USERCOPY() use kmem_cache_setup().

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 include/linux/slab.h | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 79f4799b7083..52928474e6a1 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -283,24 +283,29 @@  int kmem_cache_shrink(struct kmem_cache *s);
  * f.e. add ____cacheline_aligned_in_smp to the struct declaration
  * then the objects will be properly aligned in SMP configurations.
  */
-#define KMEM_CACHE(__struct, __flags)                                   \
-	kmem_cache_setup(#__struct, sizeof(struct __struct),            \
-			 &(struct kmem_cache_args){                     \
-				 .align = __alignof__(struct __struct), \
-				 .ctor = NULL,                          \
-			 },                                             \
+#define KMEM_CACHE(__struct, __flags)						\
+	kmem_cache_setup(#__struct,						\
+			sizeof(struct __struct),				\
+			 &(struct kmem_cache_args) {				\
+				 .align = __alignof__(struct __struct),		\
+				 .ctor = NULL,					\
+			 },							\
 			 (__flags))
 
 /*
  * To whitelist a single field for copying to/from usercopy, use this
  * macro instead for KMEM_CACHE() above.
  */
-#define KMEM_CACHE_USERCOPY(__struct, __flags, __field)			\
-		kmem_cache_create_usercopy(#__struct,			\
-			sizeof(struct __struct),			\
-			__alignof__(struct __struct), (__flags),	\
-			offsetof(struct __struct, __field),		\
-			sizeof_field(struct __struct, __field), NULL)
+#define KMEM_CACHE_USERCOPY(__struct, __flags, __field)					\
+	kmem_cache_setup(#__struct,							\
+			sizeof(struct __struct),					\
+			&(struct kmem_cache_args) {					\
+				.align = __alignof__(struct __struct),			\
+				.useroffset = offsetof(struct __struct, __field),	\
+				.usersize = sizeof_field(struct __struct, __field),	\
+				.ctor = NULL,						\
+			},								\
+			(__flags))
 
 /*
  * Common kmalloc functions provided by all allocators