Message ID | 20240903-work-kmem_cache_args-v2-11-76f97e9a4560@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | slab: add struct kmem_cache_args | expand |
On Tue, Sep 03, 2024 at 04:20:52PM +0200, Christian Brauner wrote: > Make KMEM_CACHE_USERCOPY() use struct kmem_cache_args. > > Signed-off-by: Christian Brauner <brauner@kernel.org> Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > --- > include/linux/slab.h | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index d9c2ed5bc02f..aced16a08700 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -294,12 +294,14 @@ int kmem_cache_shrink(struct kmem_cache *s); > * 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_create_args(#__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 > > -- > 2.45.2 >
diff --git a/include/linux/slab.h b/include/linux/slab.h index d9c2ed5bc02f..aced16a08700 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -294,12 +294,14 @@ int kmem_cache_shrink(struct kmem_cache *s); * 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_create_args(#__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
Make KMEM_CACHE_USERCOPY() use struct kmem_cache_args. Signed-off-by: Christian Brauner <brauner@kernel.org> --- include/linux/slab.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)