* [PATCH 0/2] LAZY_WAKE misuse fixes
@ 2024-04-30 15:42 Pavel Begunkov
2024-04-30 15:42 ` [PATCH 1/2] io_uring/net: fix sendzc lazy wake polling Pavel Begunkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2024-04-30 15:42 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
LAZY_WAKE can't be used with requests for which users expect >1 CQE,
otherwise wait(nr=2) may get stuck waiting for a tw that will never
arrive. Fix up invalid use of LAZY_WAKE with sendzc.
Pavel Begunkov (2):
io_uring/net: fix sendzc lazy wake polling
io_uring/notif: disable LAZY_WAKE for linked notifs
io_uring/net.c | 1 +
io_uring/notif.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
--
2.44.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] io_uring/net: fix sendzc lazy wake polling 2024-04-30 15:42 [PATCH 0/2] LAZY_WAKE misuse fixes Pavel Begunkov @ 2024-04-30 15:42 ` Pavel Begunkov 2024-04-30 15:42 ` [PATCH 2/2] io_uring/notif: disable LAZY_WAKE for linked notifs Pavel Begunkov 2024-04-30 19:06 ` [PATCH 0/2] LAZY_WAKE misuse fixes Jens Axboe 2 siblings, 0 replies; 4+ messages in thread From: Pavel Begunkov @ 2024-04-30 15:42 UTC (permalink / raw) To: io-uring; +Cc: Jens Axboe, asml.silence SEND[MSG]_ZC produces multiple CQEs via notifications, LAZY_WAKE doesn't handle it and so disable LAZY_WAKE for sendzc polling. It should be fine, sends are not likely to be polled in the first place. Fixes: 6ce4a93dbb5b ("io_uring/poll: use IOU_F_TWQ_LAZY_WAKE for wakeups") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- io_uring/net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/io_uring/net.c b/io_uring/net.c index 51c41d771c50..503debecad32 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1198,6 +1198,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) struct io_kiocb *notif; zc->done_io = 0; + req->flags |= REQ_F_POLL_NO_LAZY; if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3))) return -EINVAL; -- 2.44.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] io_uring/notif: disable LAZY_WAKE for linked notifs 2024-04-30 15:42 [PATCH 0/2] LAZY_WAKE misuse fixes Pavel Begunkov 2024-04-30 15:42 ` [PATCH 1/2] io_uring/net: fix sendzc lazy wake polling Pavel Begunkov @ 2024-04-30 15:42 ` Pavel Begunkov 2024-04-30 19:06 ` [PATCH 0/2] LAZY_WAKE misuse fixes Jens Axboe 2 siblings, 0 replies; 4+ messages in thread From: Pavel Begunkov @ 2024-04-30 15:42 UTC (permalink / raw) To: io-uring; +Cc: Jens Axboe, asml.silence Notifications may now be linked and thus a single tw can post multiple CQEs, it's not safe to use LAZY_WAKE with them. Disable LAZY_WAKE for now, if that'd prove to be a problem we can count them and pass the expected number of CQEs into __io_req_task_work_add(). Fixes: 6fe4220912d19 ("io_uring/notif: implement notification stacking") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- io_uring/notif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/io_uring/notif.c b/io_uring/notif.c index d58cdc01e691..28859ae3ee6e 100644 --- a/io_uring/notif.c +++ b/io_uring/notif.c @@ -38,6 +38,7 @@ void io_tx_ubuf_complete(struct sk_buff *skb, struct ubuf_info *uarg, { struct io_notif_data *nd = container_of(uarg, struct io_notif_data, uarg); struct io_kiocb *notif = cmd_to_io_kiocb(nd); + unsigned tw_flags; if (nd->zc_report) { if (success && !nd->zc_used && skb) @@ -53,8 +54,10 @@ void io_tx_ubuf_complete(struct sk_buff *skb, struct ubuf_info *uarg, io_tx_ubuf_complete(skb, &nd->head->uarg, success); return; } + + tw_flags = nd->next ? 0 : IOU_F_TWQ_LAZY_WAKE; notif->io_task_work.func = io_notif_tw_complete; - __io_req_task_work_add(notif, IOU_F_TWQ_LAZY_WAKE); + __io_req_task_work_add(notif, tw_flags); } static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg) -- 2.44.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] LAZY_WAKE misuse fixes 2024-04-30 15:42 [PATCH 0/2] LAZY_WAKE misuse fixes Pavel Begunkov 2024-04-30 15:42 ` [PATCH 1/2] io_uring/net: fix sendzc lazy wake polling Pavel Begunkov 2024-04-30 15:42 ` [PATCH 2/2] io_uring/notif: disable LAZY_WAKE for linked notifs Pavel Begunkov @ 2024-04-30 19:06 ` Jens Axboe 2 siblings, 0 replies; 4+ messages in thread From: Jens Axboe @ 2024-04-30 19:06 UTC (permalink / raw) To: io-uring, Pavel Begunkov On Tue, 30 Apr 2024 16:42:29 +0100, Pavel Begunkov wrote: > LAZY_WAKE can't be used with requests for which users expect >1 CQE, > otherwise wait(nr=2) may get stuck waiting for a tw that will never > arrive. Fix up invalid use of LAZY_WAKE with sendzc. > > Pavel Begunkov (2): > io_uring/net: fix sendzc lazy wake polling > io_uring/notif: disable LAZY_WAKE for linked notifs > > [...] Applied, thanks! [1/2] io_uring/net: fix sendzc lazy wake polling commit: ef42b85a5609cd822ca0a68dd2bef2b12b5d1ca3 [2/2] io_uring/notif: disable LAZY_WAKE for linked notifs commit: 19352a1d395424b5f8c03289a85fbd6622d6601a Best regards, -- Jens Axboe ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-30 19:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-04-30 15:42 [PATCH 0/2] LAZY_WAKE misuse fixes Pavel Begunkov 2024-04-30 15:42 ` [PATCH 1/2] io_uring/net: fix sendzc lazy wake polling Pavel Begunkov 2024-04-30 15:42 ` [PATCH 2/2] io_uring/notif: disable LAZY_WAKE for linked notifs Pavel Begunkov 2024-04-30 19:06 ` [PATCH 0/2] LAZY_WAKE misuse fixes 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.