Message ID | 20240903-work-kmem_cache_args-v2-10-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:51PM +0200, Christian Brauner wrote: > Make KMEM_CACHE() 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 | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 79d8c8bca4a4..d9c2ed5bc02f 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -283,9 +283,12 @@ 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_create(#__struct, sizeof(struct __struct), \ > - __alignof__(struct __struct), (__flags), NULL) > +#define KMEM_CACHE(__struct, __flags) \ > + __kmem_cache_create_args(#__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 > > -- > 2.45.2 >
diff --git a/include/linux/slab.h b/include/linux/slab.h index 79d8c8bca4a4..d9c2ed5bc02f 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -283,9 +283,12 @@ 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_create(#__struct, sizeof(struct __struct), \ - __alignof__(struct __struct), (__flags), NULL) +#define KMEM_CACHE(__struct, __flags) \ + __kmem_cache_create_args(#__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
Make KMEM_CACHE() use struct kmem_cache_args. Signed-off-by: Christian Brauner <brauner@kernel.org> --- include/linux/slab.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)