From: Jens Axboe <[email protected]>
To: io-uring <[email protected]>
Cc: Guenter Roeck <[email protected]>
Subject: [PATCH] io_uring: add separate freeptr type for slab
Date: Tue, 19 Nov 2024 19:05:01 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
io_uring: add separate freeptr type for slab
A previous commit used io_kiocb->work as the free pointer space. Which
is completely fine, but apparently m68k does odd alignment and the
struct ends up being 2-byte aligned rather than 4-byte aligned.
Add a union around io_kiocb->work, and add a specific freeptr_t type in
there to be used for slab. Mark it as needing sizeof(type) alignment, to
force m68k to do so. On anything normal, this won't change sizing or
alignment at all.
Reported-by: Guenter Roeck <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Fixes: aaa736b18623 ("io_uring: specify freeptr usage for SLAB_TYPESAFE_BY_RCU io_kiocb cache")
Signed-off-by: Jens Axboe <[email protected]>
---
diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index aa5f5ea98076..91efc7e6bf3f 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -673,7 +673,16 @@ struct io_kiocb {
struct io_kiocb *link;
/* custom credentials, valid IFF REQ_F_CREDS is set */
const struct cred *creds;
- struct io_wq_work work;
+
+ /*
+ * Use separate freeptr for slab, but overlay it with work as that
+ * part is long done by the time the request is freed. Due to an m68k
+ * quirk, ensure it's aligned to at least the size of the type.
+ */
+ union {
+ struct io_wq_work work;
+ freeptr_t freeptr __aligned(sizeof(freeptr_t));
+ };
struct {
u64 extra1;
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index da8fd460977b..4bf25b9e5105 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3813,7 +3813,7 @@ static int __init io_uring_init(void)
struct kmem_cache_args kmem_args = {
.useroffset = offsetof(struct io_kiocb, cmd.data),
.usersize = sizeof_field(struct io_kiocb, cmd.data),
- .freeptr_offset = offsetof(struct io_kiocb, work),
+ .freeptr_offset = offsetof(struct io_kiocb, freeptr),
.use_freeptr_offset = true,
};
--
Jens Axboe
reply other threads:[~2024-11-20 2:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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