From: Olivier Langlois <[email protected]>
To: Jens Axboe <[email protected]>,Pavel Begunkov
<[email protected]>,[email protected]
Subject: [PATCH v2 2/3] io_uring/napi: fix io_napi_entry RCU accesses
Date: Mon, 16 Sep 2024 15:20:36 -0400 [thread overview]
Message-ID: <21f0dc072dce6699a8fe4ced734fed066dee09bf.1726354973.git.olivier@trillion01.com> (raw)
In-Reply-To: <[email protected]>
correct 3 RCU structures modifications that were not using the RCU
functions to make their update.
Signed-off-by: Olivier Langlois <[email protected]>
---
io_uring/napi.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/io_uring/napi.c b/io_uring/napi.c
index 1dd2df9da468..738d88bc050a 100644
--- a/io_uring/napi.c
+++ b/io_uring/napi.c
@@ -81,7 +81,7 @@ void __io_napi_add(struct io_ring_ctx *ctx, struct socket *sock)
}
hlist_add_tail_rcu(&e->node, hash_list);
- list_add_tail(&e->list, &ctx->napi_list);
+ list_add_tail_rcu(&e->list, &ctx->napi_list);
spin_unlock(&ctx->napi_lock);
}
@@ -91,9 +91,15 @@ static void __io_napi_remove_stale(struct io_ring_ctx *ctx)
unsigned int i;
spin_lock(&ctx->napi_lock);
+ /*
+ * hash_for_each_safe() is not required as long as:
+ * 1. hash_del_rcu() does not reset the deleted node next pointer
+ * 2. kfree_rcu() delays the memory freeing until the next quiescent
+ * state
+ */
hash_for_each(ctx->napi_ht, i, e, node) {
if (time_after(jiffies, READ_ONCE(e->timeout))) {
- list_del(&e->list);
+ list_del_rcu(&e->list);
hash_del_rcu(&e->node);
kfree_rcu(e, rcu);
}
@@ -207,6 +213,7 @@ void io_napi_free(struct io_ring_ctx *ctx)
unsigned int i;
spin_lock(&ctx->napi_lock);
+ INIT_LIST_HEAD_RCU(&ctx->napi_list);
hash_for_each(ctx->napi_ht, i, e, node) {
hash_del_rcu(&e->node);
kfree_rcu(e, rcu);
--
2.46.0
next prev parent reply other threads:[~2024-09-16 19:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 19:19 [PATCH v2 0/3] napi tracking strategy Olivier Langlois
2024-09-16 19:20 ` [PATCH v2 1/3] io_uring/napi: protect concurrent io_napi_entry timeout accesses Olivier Langlois
2024-09-16 19:20 ` Olivier Langlois [this message]
2024-09-16 19:20 ` [PATCH v2 3/3] io_uring/napi: add static napi tracking strategy Olivier Langlois
2024-09-17 3:09 ` Jens Axboe
2024-09-17 14:58 ` Olivier Langlois
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=21f0dc072dce6699a8fe4ced734fed066dee09bf.1726354973.git.olivier@trillion01.com \
[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