Skip to content

Commit 6b7f864

Browse files
isilenceaxboe
authored andcommitted
io_uring/net: get rid of io_notif_complete_tw_ext
io_notif_complete_tw_ext() can be removed and combined with io_notif_complete_tw to make it simpler without sacrificing anything. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/025a124a5e20e2474a57e2f04f16c422eb83063c.1712534031.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9986329 commit 6b7f864

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

io_uring/net.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,11 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
10181018
if (zc->flags & ~IO_ZC_FLAGS_VALID)
10191019
return -EINVAL;
10201020
if (zc->flags & IORING_SEND_ZC_REPORT_USAGE) {
1021-
io_notif_set_extended(notif);
1022-
io_notif_to_data(notif)->zc_report = true;
1021+
struct io_notif_data *nd = io_notif_to_data(notif);
1022+
1023+
nd->zc_report = true;
1024+
nd->zc_used = false;
1025+
nd->zc_copied = false;
10231026
}
10241027
}
10251028

@@ -1128,7 +1131,6 @@ static int io_send_zc_import(struct io_kiocb *req, struct io_async_msghdr *kmsg)
11281131
return ret;
11291132
kmsg->msg.sg_from_iter = io_sg_from_iter;
11301133
} else {
1131-
io_notif_set_extended(sr->notif);
11321134
ret = import_ubuf(ITER_SOURCE, sr->buf, sr->len, &kmsg->msg.msg_iter);
11331135
if (unlikely(ret))
11341136
return ret;
@@ -1217,8 +1219,6 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
12171219
unsigned flags;
12181220
int ret, min_ret = 0;
12191221

1220-
io_notif_set_extended(sr->notif);
1221-
12221222
sock = sock_from_file(req->file);
12231223
if (unlikely(!sock))
12241224
return -ENOTSOCK;

io_uring/notif.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#include "notif.h"
1010
#include "rsrc.h"
1111

12-
static void io_notif_complete_tw_ext(struct io_kiocb *notif, struct io_tw_state *ts)
12+
void io_notif_tw_complete(struct io_kiocb *notif, struct io_tw_state *ts)
1313
{
1414
struct io_notif_data *nd = io_notif_to_data(notif);
1515
struct io_ring_ctx *ctx = notif->ctx;
1616

17-
if (nd->zc_report && (nd->zc_copied || !nd->zc_used))
17+
if (unlikely(nd->zc_report) && (nd->zc_copied || !nd->zc_used))
1818
notif->cqe.res |= IORING_NOTIF_USAGE_ZC_COPIED;
1919

2020
if (nd->account_pages && ctx->user) {
@@ -37,17 +37,10 @@ static void io_tx_ubuf_callback(struct sk_buff *skb, struct ubuf_info *uarg,
3737
WRITE_ONCE(nd->zc_copied, true);
3838
}
3939

40-
if (refcount_dec_and_test(&uarg->refcnt))
40+
if (refcount_dec_and_test(&uarg->refcnt)) {
41+
notif->io_task_work.func = io_notif_tw_complete;
4142
__io_req_task_work_add(notif, IOU_F_TWQ_LAZY_WAKE);
42-
}
43-
44-
void io_notif_set_extended(struct io_kiocb *notif)
45-
{
46-
struct io_notif_data *nd = io_notif_to_data(notif);
47-
48-
nd->zc_used = false;
49-
nd->zc_copied = false;
50-
notif->io_task_work.func = io_notif_complete_tw_ext;
43+
}
5144
}
5245

5346
struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx)
@@ -64,7 +57,6 @@ struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx)
6457
notif->task = current;
6558
io_get_task_refs(1);
6659
notif->rsrc_node = NULL;
67-
notif->io_task_work.func = io_req_task_complete;
6860

6961
nd = io_notif_to_data(notif);
7062
nd->zc_report = false;

io_uring/notif.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct io_notif_data {
2020
};
2121

2222
struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx);
23-
void io_notif_set_extended(struct io_kiocb *notif);
23+
void io_notif_tw_complete(struct io_kiocb *notif, struct io_tw_state *ts);
2424

2525
static inline struct io_notif_data *io_notif_to_data(struct io_kiocb *notif)
2626
{
@@ -33,8 +33,10 @@ static inline void io_notif_flush(struct io_kiocb *notif)
3333
struct io_notif_data *nd = io_notif_to_data(notif);
3434

3535
/* drop slot's master ref */
36-
if (refcount_dec_and_test(&nd->uarg.refcnt))
36+
if (refcount_dec_and_test(&nd->uarg.refcnt)) {
37+
notif->io_task_work.func = io_notif_tw_complete;
3738
__io_req_task_work_add(notif, IOU_F_TWQ_LAZY_WAKE);
39+
}
3840
}
3941

4042
static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len)

0 commit comments

Comments
 (0)