mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: agxr <agxr@disroot.org>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Cc: agxr <agxr@disroot.org>,
	linux-kernel@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>
Subject: [PATCH 1/2] io_uring/cancel: count all canceled futex and waitid requests on CANCEL_ALL
Date: Sat, 24 Oct 2026 21:31:24 +0500	[thread overview]
Message-ID: <20261024163259.19372-2-agxr@disroot.org> (raw)
In-Reply-To: <20261024163259.19372-1-agxr@disroot.org>

With IORING_ASYNC_CANCEL_ALL, __io_async_cancel() calls io_try_cancel()
until it finds nothing more and adds 1 to the count for each call that
found something, which is correct for poll, io-wq and timeouts, which
cancel one request per call. io_futex_cancel() and io_waitid_cancel()
cancel all matches in a single call and return how many they canceled.
Three futex waits with the same user_data are all canceled by the first
call, which counts as one, and the cancel completes with 1, not 3.

Sum the return values of io_try_cancel() instead, so that the count is
the number of canceled requests, as io_uring_prep_cancel(3) documents.

Fixes: 194bb58c6090 ("io_uring: add support for futex wake and wait")
Fixes: f31ecf671ddc ("io_uring: add IORING_OP_WAITID support")
Signed-off-by: agxr <agxr@disroot.org>
---
 io_uring/cancel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io_uring/cancel.c b/io_uring/cancel.c
index 6f7a6cf356c2..e4b27b79b05c 100644
--- a/io_uring/cancel.c
+++ b/io_uring/cancel.c
@@ -198,7 +198,7 @@ static int __io_async_cancel(struct io_cancel_data *cd,
 			break;
 		if (!all)
 			return ret;
-		nr++;
+		nr += ret > 0 ? ret : 1;
 	} while (1);
 
 	/* slow path, try all io-wq's */
-- 
2.56.0


  reply	other threads:[~2026-10-24 16:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24 16:31 [PATCH 0/2] io_uring/cancel: futex and waitid cancel results agxr
2026-10-24 16:31 ` agxr [this message]
2026-10-24 16:31 ` [PATCH 2/2] io_uring/cancel: complete single futex or waitid cancel with 0 agxr
2026-10-25  3:23 ` [PATCH 0/2] io_uring/cancel: futex and waitid cancel results 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=20261024163259.19372-2-agxr@disroot.org \
    --to=agxr@disroot.org \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®