From: Christian Brauner <brauner@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>, Jens Axboe <axboe@kernel.dk>,
Jann Horn <jannh@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org, Christian Brauner <brauner@kernel.org>
Subject: [PATCH RFC 3/6] slab: port KMEM_CACHE_USERCOPY() to kmem_cache_setup()
Date: Mon, 02 Sep 2024 17:31:13 +0200 [thread overview]
Message-ID: <20240902-work-kmem_cache_args-v1-3-27d05bc05128@kernel.org> (raw)
In-Reply-To: <20240902-work-kmem_cache_args-v1-0-27d05bc05128@kernel.org>
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 --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
--
2.45.2
next prev parent reply other threads:[~2024-09-02 15:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 15:31 [PATCH RFC 0/6] slab: add kmem_cache_setup() Christian Brauner
2024-09-02 15:31 ` [PATCH RFC 1/6] slab: introduce kmem_cache_setup() Christian Brauner
2024-09-02 15:31 ` [PATCH RFC 2/6] slab: port KMEM_CACHE() to kmem_cache_setup() Christian Brauner
2024-09-02 15:31 ` Christian Brauner [this message]
2024-09-02 15:31 ` [PATCH RFC 4/6] file: port " Christian Brauner
2024-09-02 15:31 ` [PATCH RFC 5/6] slab: remove kmem_cache_create_rcu() Christian Brauner
2024-09-02 15:31 ` [PATCH RFC 6/6] io_uring: port to kmem_cache_setup() Christian Brauner
2024-09-02 18:15 ` [PATCH RFC 0/6] slab: add kmem_cache_setup() Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240902-work-kmem_cache_args-v1-3-27d05bc05128@kernel.org \
--to=brauner@kernel.org \
--cc=axboe@kernel.dk \
--cc=jannh@google.com \
--cc=linux-mm@kvack.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox