public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Daniele Di Proietto <daniele.di.proietto@gmail.com>,
	Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring: Add IORING_OP_DUP
Date: Wed, 11 Mar 2026 11:30:33 +0000	[thread overview]
Message-ID: <086190ca-1c34-448f-a565-aa41f671971f@gmail.com> (raw)
In-Reply-To: <CAExiqTKBFeyxE4nwSxd3muOuZkP5YDSoweYwns4wb64w8efPVQ@mail.gmail.com>

On 3/10/26 18:42, Daniele Di Proietto wrote:
> On Tue, Mar 10, 2026 at 4:24 PM Jens Axboe <axboe@kernel.dk> wrote:
>>
>> On 3/10/26 9:49 AM, Daniele Di Proietto wrote:
>>> The new operation is like dup3(). The source file can be a regular file
>>> descriptor or a direct descriptor. The destination is a regular file
>>> descriptor.
>>>
>>> The direct descriptor variant is useful to move a descriptor to an fd
>>> and close the existing fd with a single acquisition of the `struct
>>> files_struct` `file_lock`. Combined with IORING_OP_ACCEPT or
>>> IORING_OP_OPENAT2 with direct descriptors, it can reduce lock contention
>>> for multithreaded applications.
>>
>> Overall comment - how does this interact with direct descriptors? Feels
>> like this should support both, rather than just normal file descriptors.
> 
> As implemented, the operation supports:
> 1. src: direct, dst: normal (this is the use case I mostly care about)
> 2. src: normal, dst: normal ()
> 
> I can extend it to also support
> 3. src: direct, dst: direct
> 4, src: normal, dst: direct
> 
> I can use IOSQE_FIXED_FILE to pick the source and I guess I can use a
> bit in dup_flags (something like IORING_DUP_DIRECT) to decide whether
> the destination is a direct descriptor or normal.
> 
> Does that make sense?

Let's not try to reuse IOSQE_FIXED_FILE for that. We may want to
operate with io_uring's filetable entries and not just files you get
from there. Two separate IORING_DUP_* flags should be better. And
you can extract a helper function out of

io_uring/splice.c::io_splice_get_file()

It might also be better to make it a part of IORING_OP_FILES_UPDATE
instead of wasting another opcode, and liburing can provide a
prep_dup helper for convenience.

-- 
Pavel Begunkov


      reply	other threads:[~2026-03-11 11:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 15:49 [PATCH] io_uring: Add IORING_OP_DUP Daniele Di Proietto
2026-03-10 16:14 ` Keith Busch
2026-03-10 18:42   ` Daniele Di Proietto
2026-03-10 16:24 ` Jens Axboe
2026-03-10 18:42   ` Daniele Di Proietto
2026-03-11 11:30     ` Pavel Begunkov [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=086190ca-1c34-448f-a565-aa41f671971f@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=daniele.di.proietto@gmail.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