public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-6.1 2/4] io_uring: fix tw losing poll events
Date: Thu, 17 Nov 2022 18:40:15 +0000	[thread overview]
Message-ID: <00344d60f8b18907171178d7cf598de71d127b0b.1668710222.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

We may never try to process a poll wake and its mask if there was
multiple wake ups racing for queueing up a tw. Force
io_poll_check_events() to update the mask by vfs_poll().

Cc: [email protected]
Fixes: aa43477b04025 ("io_uring: poll rework")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/poll.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/io_uring/poll.c b/io_uring/poll.c
index 90920abf91ff..c34019b18211 100644
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -228,6 +228,13 @@ static int io_poll_check_events(struct io_kiocb *req, bool *locked)
 			return IOU_POLL_DONE;
 		if (v & IO_POLL_CANCEL_FLAG)
 			return -ECANCELED;
+		/*
+		 * cqe.res contains only events of the first wake up
+		 * and all others are be lost. Redo vfs_poll() to get
+		 * up to date state.
+		 */
+		if ((v & IO_POLL_REF_MASK) != 1)
+			req->cqe.res = 0;
 
 		/* the mask was stashed in __io_poll_execute */
 		if (!req->cqe.res) {
-- 
2.38.1


  parent reply	other threads:[~2022-11-17 18:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 18:40 [PATCH for-6.1 0/4] minor poll fixes Pavel Begunkov
2022-11-17 18:40 ` [PATCH for-6.1 1/4] io_uring: update res mask in io_poll_check_events Pavel Begunkov
2022-11-17 20:31   ` Gabriel Krisman Bertazi
2022-11-17 18:40 ` Pavel Begunkov [this message]
2022-11-17 18:40 ` [PATCH for-6.1 3/4] io_uring: fix multishot accept request leaks Pavel Begunkov
2022-11-17 18:40 ` [PATCH for-6.1 4/4] io_uring: fix multishot recv " Pavel Begunkov
2022-11-17 19:46 ` [PATCH for-6.1 0/4] minor poll fixes Jens Axboe

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=00344d60f8b18907171178d7cf598de71d127b0b.1668710222.git.asml.silence@gmail.com \
    [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