public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: lizetao <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: [PATCH 1/6] io_uring/cancel: add generic remove_all helper
Date: Thu, 6 Feb 2025 07:07:42 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 2/6/25 5:46 AM, lizetao wrote:
> 
> 
>> -----Original Message-----
>> From: Jens Axboe <[email protected]>
>> Sent: Thursday, February 6, 2025 4:26 AM
>> To: [email protected]
>> Cc: Jens Axboe <[email protected]>
>> Subject: [PATCH 1/6] io_uring/cancel: add generic remove_all helper
>>
>> Any opcode that is cancelable ends up defining its own remove all helper, which
>> iterates the pending list and cancels matches. Add a generic helper for it, which
>> can be used by them.
>>
>> Signed-off-by: Jens Axboe <[email protected]>
>> ---
>>  io_uring/cancel.c | 20 ++++++++++++++++++++  io_uring/cancel.h |  4 ++++
>>  2 files changed, 24 insertions(+)
>>
>> diff --git a/io_uring/cancel.c b/io_uring/cancel.c index
>> 484193567839..0565dc0d7611 100644
>> --- a/io_uring/cancel.c
>> +++ b/io_uring/cancel.c
>> @@ -341,3 +341,23 @@ int io_sync_cancel(struct io_ring_ctx *ctx, void __user
>> *arg)
>>  		fput(file);
>>  	return ret;
>>  }
>> +
>> +bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,
>> +			  struct hlist_head *list, bool cancel_all,
>> +			  bool (*cancel)(struct io_kiocb *)) {
>> +	struct hlist_node *tmp;
>> +	struct io_kiocb *req;
>> +	bool found = false;
>> +
>> +	lockdep_assert_held(&ctx->uring_lock);
>> +
>> +	hlist_for_each_entry_safe(req, tmp, list, hash_node) {
>> +		if (!io_match_task_safe(req, tctx, cancel_all))
>> +			continue;
> 
> Should call hlist_del_init(&req->hash_node) here, just like the
> original code logic.

Indeed, good catch! I'll make the change.

-- 
Jens Axboe

  reply	other threads:[~2025-02-06 14:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 20:26 [PATCHSET 0/6] Cancelation cleanups Jens Axboe
2025-02-05 20:26 ` [PATCH 1/6] io_uring/cancel: add generic remove_all helper Jens Axboe
2025-02-06 12:46   ` lizetao
2025-02-06 14:07     ` Jens Axboe [this message]
2025-02-05 20:26 ` [PATCH 2/6] io_uring/futex: convert to io_cancel_remove_all() Jens Axboe
2025-02-05 20:26 ` [PATCH 3/6] io_uring/waitid: " Jens Axboe
2025-02-05 20:26 ` [PATCH 4/6] io_uring/cancel: add generic cancel helper Jens Axboe
2025-02-05 20:26 ` [PATCH 5/6] io_uring/futex: use generic io_cancel_remove() helper Jens Axboe
2025-02-06 12:56   ` lizetao
2025-02-06 14:10     ` Jens Axboe
2025-02-05 20:26 ` [PATCH 6/6] io_uring/waitid: " 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 \
    [email protected] \
    [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