LAZY_WAKE misuse fixes
cover LAZY_WAKE misuse fixes
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(-)
Signature · 1 line
2.44.0
PATCH 1/2 io_uring/net: fix sendzc lazy wake polling
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.
--- io_uring/net.c | 1 + 1 file changed, 1 insertion(+)
io_uring/net.c +1 -0
@@ -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 ;
Signature · 1 line
2.44.0
PATCH 2/2 io_uring/notif: disable LAZY_WAKE for linked notifs
In reply to Pavel BegunkovNotifications 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().
--- io_uring/notif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
io_uring/notif.c +4 -1
@@ -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)
Signature · 1 line
2.44.0
Quoted 9 lines · Pavel Begunkov
LAZY_WAKEcan'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 ofLAZY_WAKEwith sendzc.Pavel Begunkov (2):
io_uring/net: fix sendzc lazy wake pollingio_uring/notif: disableLAZY_WAKEfor 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: 19352a1d395424b5f8c03289a85fbd6622d6601aBest regards,
Signature · 1 line
Jens Axboe