public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: io-uring <io-uring@vger.kernel.org>
Subject: Re: [PATCH for-next] io_uring: add async data clear/free helpers
Date: Tue, 26 Aug 2025 12:40:57 -0600	[thread overview]
Message-ID: <5991889c-0028-4e60-988d-1b6cbef10f25@kernel.dk> (raw)
In-Reply-To: <CADUfDZonRMM5kKm-PvOzLwjsEUeRKWv08FN8tOwExS9UQCndsw@mail.gmail.com>

On 8/26/25 10:10 AM, Caleb Sander Mateos wrote:
> On Tue, Aug 26, 2025 at 9:04 AM Jens Axboe <axboe@kernel.dk> wrote:
>>
>> On 8/26/25 9:27 AM, Caleb Sander Mateos wrote:
>>>> diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
>>>> index 2e4f7223a767..86613b8224bd 100644
>>>> --- a/io_uring/io_uring.h
>>>> +++ b/io_uring/io_uring.h
>>>> @@ -281,6 +281,19 @@ static inline bool req_has_async_data(struct io_kiocb *req)
>>>>         return req->flags & REQ_F_ASYNC_DATA;
>>>>  }
>>>>
>>>> +static inline void io_req_async_data_clear(struct io_kiocb *req,
>>>> +                                          io_req_flags_t extra_flags)
>>>> +{
>>>> +       req->flags &= ~(REQ_F_ASYNC_DATA|extra_flags);
>>>> +       req->async_data = NULL;
>>>> +}
>>>> +
>>>> +static inline void io_req_async_data_free(struct io_kiocb *req)
>>>> +{
>>>> +       kfree(req->async_data);
>>>> +       io_req_async_data_clear(req, 0);
>>>> +}
>>>
>>> Would it make sense to also add a helper for assigning async_data that
>>> would also make sure to set REQ_F_ASYNC_DATA?
>>
>> I did consider that, but it's only futex that'd use it and just in those
>> two spots. So decided against it. At least for now.
> 
> Makes sense. I think it could also be used in
> io_uring_alloc_async_data(), but it's true there are fewer sites
> assigning to async_data than clearing it.

Indeed, most of the setting happens through the alloc async data
helper already. And yes it could get unified with that, but then
we'd probably want to extend that a bit more to return -ENOMEM
too for the cached case, and futex has one of each. IOW, I just
stopped at that point :-)

-- 
Jens Axboe


      reply	other threads:[~2025-08-26 18:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26 14:04 [PATCH for-next] io_uring: add async data clear/free helpers Jens Axboe
2025-08-26 15:27 ` Caleb Sander Mateos
2025-08-26 16:04   ` Jens Axboe
2025-08-26 16:10     ` Caleb Sander Mateos
2025-08-26 18:40       ` Jens Axboe [this message]

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=5991889c-0028-4e60-988d-1b6cbef10f25@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=io-uring@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