All of lore.kernel.org
 help / color / mirror / Atom feed
* [for-next 0/3] simple sendzc cleanups
@ 2024-04-15 12:50 Pavel Begunkov
  2024-04-15 12:50 ` [for-next 1/3] io_uring/notif: refactor io_tx_ubuf_complete() Pavel Begunkov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pavel Begunkov @ 2024-04-15 12:50 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

Simple SENDZC notification cleanups that make sense by themselves
split out from the notif stacking series.

Pavel Begunkov (3):
  io_uring/notif: refactor io_tx_ubuf_complete()
  io_uring/notif: remove ctx var from io_notif_tw_complete
  io_uring/notif: shrink account_pages to u32

 io_uring/notif.c | 14 +++++++-------
 io_uring/notif.h |  3 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [for-next 1/3] io_uring/notif: refactor io_tx_ubuf_complete()
  2024-04-15 12:50 [for-next 0/3] simple sendzc cleanups Pavel Begunkov
@ 2024-04-15 12:50 ` Pavel Begunkov
  2024-04-15 12:50 ` [for-next 2/3] io_uring/notif: remove ctx var from io_notif_tw_complete Pavel Begunkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2024-04-15 12:50 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

Flip the dec_and_test "if", that makes the function extension easier in
the future.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/notif.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/io_uring/notif.c b/io_uring/notif.c
index b561bd763435..452c255de04a 100644
--- a/io_uring/notif.c
+++ b/io_uring/notif.c
@@ -37,10 +37,11 @@ static void io_tx_ubuf_callback(struct sk_buff *skb, struct ubuf_info *uarg,
 			WRITE_ONCE(nd->zc_copied, true);
 	}
 
-	if (refcount_dec_and_test(&uarg->refcnt)) {
-		notif->io_task_work.func = io_notif_tw_complete;
-		__io_req_task_work_add(notif, IOU_F_TWQ_LAZY_WAKE);
-	}
+	if (!refcount_dec_and_test(&uarg->refcnt))
+		return;
+
+	notif->io_task_work.func = io_notif_tw_complete;
+	__io_req_task_work_add(notif, IOU_F_TWQ_LAZY_WAKE);
 }
 
 struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [for-next 2/3] io_uring/notif: remove ctx var from io_notif_tw_complete
  2024-04-15 12:50 [for-next 0/3] simple sendzc cleanups Pavel Begunkov
  2024-04-15 12:50 ` [for-next 1/3] io_uring/notif: refactor io_tx_ubuf_complete() Pavel Begunkov
@ 2024-04-15 12:50 ` Pavel Begunkov
  2024-04-15 12:50 ` [for-next 3/3] io_uring/notif: shrink account_pages to u32 Pavel Begunkov
  2024-04-15 14:11 ` [for-next 0/3] simple sendzc cleanups Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2024-04-15 12:50 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

We don't need ctx in the hottest path, i.e. registered buffers,
let's get it only when we need it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/notif.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/io_uring/notif.c b/io_uring/notif.c
index 452c255de04a..3485437b207d 100644
--- a/io_uring/notif.c
+++ b/io_uring/notif.c
@@ -12,13 +12,12 @@
 void io_notif_tw_complete(struct io_kiocb *notif, struct io_tw_state *ts)
 {
 	struct io_notif_data *nd = io_notif_to_data(notif);
-	struct io_ring_ctx *ctx = notif->ctx;
 
 	if (unlikely(nd->zc_report) && (nd->zc_copied || !nd->zc_used))
 		notif->cqe.res |= IORING_NOTIF_USAGE_ZC_COPIED;
 
-	if (nd->account_pages && ctx->user) {
-		__io_unaccount_mem(ctx->user, nd->account_pages);
+	if (nd->account_pages && notif->ctx->user) {
+		__io_unaccount_mem(notif->ctx->user, nd->account_pages);
 		nd->account_pages = 0;
 	}
 	io_req_task_complete(notif, ts);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [for-next 3/3] io_uring/notif: shrink account_pages to u32
  2024-04-15 12:50 [for-next 0/3] simple sendzc cleanups Pavel Begunkov
  2024-04-15 12:50 ` [for-next 1/3] io_uring/notif: refactor io_tx_ubuf_complete() Pavel Begunkov
  2024-04-15 12:50 ` [for-next 2/3] io_uring/notif: remove ctx var from io_notif_tw_complete Pavel Begunkov
@ 2024-04-15 12:50 ` Pavel Begunkov
  2024-04-15 14:11 ` [for-next 0/3] simple sendzc cleanups Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2024-04-15 12:50 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

->account_pages is the number of pages we account against the user
derived from unsigned len, it definitely fits into unsigned, which saves
some space in struct io_notif_data.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/notif.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/io_uring/notif.h b/io_uring/notif.h
index 52e124a9957c..2e25a2fc77d1 100644
--- a/io_uring/notif.h
+++ b/io_uring/notif.h
@@ -13,7 +13,8 @@
 struct io_notif_data {
 	struct file		*file;
 	struct ubuf_info	uarg;
-	unsigned long		account_pages;
+
+	unsigned		account_pages;
 	bool			zc_report;
 	bool			zc_used;
 	bool			zc_copied;
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [for-next 0/3] simple sendzc cleanups
  2024-04-15 12:50 [for-next 0/3] simple sendzc cleanups Pavel Begunkov
                   ` (2 preceding siblings ...)
  2024-04-15 12:50 ` [for-next 3/3] io_uring/notif: shrink account_pages to u32 Pavel Begunkov
@ 2024-04-15 14:11 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2024-04-15 14:11 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov


On Mon, 15 Apr 2024 13:50:10 +0100, Pavel Begunkov wrote:
> Simple SENDZC notification cleanups that make sense by themselves
> split out from the notif stacking series.
> 
> Pavel Begunkov (3):
>   io_uring/notif: refactor io_tx_ubuf_complete()
>   io_uring/notif: remove ctx var from io_notif_tw_complete
>   io_uring/notif: shrink account_pages to u32
> 
> [...]

Applied, thanks!

[1/3] io_uring/notif: refactor io_tx_ubuf_complete()
      commit: 7e58d0af5a587e74f46f55b91a0197f750eba78c
[2/3] io_uring/notif: remove ctx var from io_notif_tw_complete
      commit: 2e730d8de45768810df4a6859cd64c5387cf0131
[3/3] io_uring/notif: shrink account_pages to u32
      commit: d6e295061f239bee48c9e49313f68042121e21c2

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-15 14:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15 12:50 [for-next 0/3] simple sendzc cleanups Pavel Begunkov
2024-04-15 12:50 ` [for-next 1/3] io_uring/notif: refactor io_tx_ubuf_complete() Pavel Begunkov
2024-04-15 12:50 ` [for-next 2/3] io_uring/notif: remove ctx var from io_notif_tw_complete Pavel Begunkov
2024-04-15 12:50 ` [for-next 3/3] io_uring/notif: shrink account_pages to u32 Pavel Begunkov
2024-04-15 14:11 ` [for-next 0/3] simple sendzc cleanups Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.