From: Pavel Begunkov <[email protected]>
To: [email protected], [email protected]
Cc: Jens Axboe <[email protected]>,
"David S . Miller" <[email protected]>,
Jakub Kicinski <[email protected]>,
[email protected], [email protected],
[email protected], Wei Liu <[email protected]>,
Paul Durrant <[email protected]>,
[email protected], [email protected],
"Michael S . Tsirkin" <[email protected]>,
Jason Wang <[email protected]>,
Pavel Begunkov <[email protected]>
Subject: [RFC net-next io_uring 09/11] io_uring/notif: add helper for flushing refs
Date: Wed, 10 Aug 2022 16:49:17 +0100 [thread overview]
Message-ID: <a68ff48da5a52be8f64b058c30d7076fbec41beb.1660124059.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Add a helper for dropping notification references during flush. It's a
preparation patch, currently it's only one master ref, but we're going
to add ref caching.
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/notif.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/io_uring/notif.c b/io_uring/notif.c
index a2ba1e35a59f..5661681b3b44 100644
--- a/io_uring/notif.c
+++ b/io_uring/notif.c
@@ -73,6 +73,13 @@ struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
return notif;
}
+static inline bool io_notif_drop_refs(struct io_notif_data *nd)
+{
+ int refs = 1;
+
+ return refcount_sub_and_test(refs, &nd->uarg.refcnt);
+}
+
void io_notif_slot_flush(struct io_notif_slot *slot)
__must_hold(&ctx->uring_lock)
{
@@ -81,8 +88,7 @@ void io_notif_slot_flush(struct io_notif_slot *slot)
slot->notif = NULL;
- /* drop slot's master ref */
- if (refcount_dec_and_test(&nd->uarg.refcnt))
+ if (io_notif_drop_refs(nd))
io_notif_complete(notif);
}
@@ -97,13 +103,11 @@ __cold int io_notif_unregister(struct io_ring_ctx *ctx)
for (i = 0; i < ctx->nr_notif_slots; i++) {
struct io_notif_slot *slot = &ctx->notif_slots[i];
struct io_kiocb *notif = slot->notif;
- struct io_notif_data *nd;
if (!notif)
continue;
- nd = io_kiocb_to_cmd(notif);
slot->notif = NULL;
- if (!refcount_dec_and_test(&nd->uarg.refcnt))
+ if (!io_notif_drop_refs(io_kiocb_to_cmd(notif)))
continue;
notif->io_task_work.func = __io_notif_complete_tw;
io_req_task_work_add(notif);
--
2.37.0
next prev parent reply other threads:[~2022-08-10 15:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-10 15:49 [RFC net-next io_uring 00/11] improve io_uring's ubuf_info refcounting Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 01/11] net: introduce struct ubuf_info_msgzc Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 02/11] xen/netback: use " Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 03/11] vhost/net: " Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 04/11] net: shrink struct ubuf_info Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 05/11] net: rename ubuf_info's flags Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 06/11] net: add flags for controlling ubuf_info Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 07/11] net/tcp: optimise tcp ubuf refcounting Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 08/11] net: let callers provide ->msg_ubuf refs Pavel Begunkov
2022-08-10 15:49 ` Pavel Begunkov [this message]
2022-08-10 15:49 ` [RFC net-next io_uring 10/11] io_uring/notif: mark notifs with UARGFL_CALLER_PINNED Pavel Begunkov
2022-08-10 15:49 ` [RFC net-next io_uring 11/11] io_uring/notif: add ubuf_info ref caching Pavel Begunkov
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=a68ff48da5a52be8f64b058c30d7076fbec41beb.1660124059.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[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