All of lore.kernel.org
 help / color / mirror / Atom feed
* Polling on an io_uring file descriptor
@ 2021-10-20  9:21 Drew DeVault
  2021-10-20 10:02 ` Drew DeVault
  2021-10-20 10:15 ` Pavel Begunkov
  0 siblings, 2 replies; 9+ messages in thread
From: Drew DeVault @ 2021-10-20  9:21 UTC (permalink / raw)
  To: io-uring

I would like to poll on an io_uring file descriptor to be notified when
CQE's are available, either via poll(2) or IORING_OP_POLL_ADD. This
doesn't seem to work on 5.10. Is this feasible to add support for?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-20  9:21 Polling on an io_uring file descriptor Drew DeVault
@ 2021-10-20 10:02 ` Drew DeVault
  2021-10-20 10:15 ` Pavel Begunkov
  1 sibling, 0 replies; 9+ messages in thread
From: Drew DeVault @ 2021-10-20 10:02 UTC (permalink / raw)
  To: Drew DeVault, io-uring

I found IOURING_REGISTER_EVENTFD, which does what I need. Pardon the
noise.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-20  9:21 Polling on an io_uring file descriptor Drew DeVault
  2021-10-20 10:02 ` Drew DeVault
@ 2021-10-20 10:15 ` Pavel Begunkov
  2021-10-20 11:44   ` Drew DeVault
  1 sibling, 1 reply; 9+ messages in thread
From: Pavel Begunkov @ 2021-10-20 10:15 UTC (permalink / raw)
  To: Drew DeVault, io-uring

On 10/20/21 10:21, Drew DeVault wrote:
> I would like to poll on an io_uring file descriptor to be notified when
> CQE's are available, either via poll(2) or IORING_OP_POLL_ADD. This
> doesn't seem to work on 5.10. Is this feasible to add support for?

Not a canonical way, but both should work (POLLIN for CQEs).
Do you have a simple test case for us to reproduce?

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-20 10:15 ` Pavel Begunkov
@ 2021-10-20 11:44   ` Drew DeVault
  2021-10-20 11:58     ` Pavel Begunkov
  0 siblings, 1 reply; 9+ messages in thread
From: Drew DeVault @ 2021-10-20 11:44 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On Wed Oct 20, 2021 at 12:15 PM CEST, Pavel Begunkov wrote:
> Not a canonical way, but both should work (POLLIN for CQEs).
> Do you have a simple test case for us to reproduce?

Hm, no, I cannot. I must have faced another bug, I was not able to
produce a minimal test case and my attempt to reproduce my earlier bug
in a larger test case was not succesful.

One issue which remains is that attempting to use REGISTER_FILES on
io_uring A with io_uring B's file descriptor returns EBADF. I saw a
comment in the kernel source explaining this, but it's a bit contrived
and the error case is not documented.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-20 11:44   ` Drew DeVault
@ 2021-10-20 11:58     ` Pavel Begunkov
  2021-10-20 12:00       ` Drew DeVault
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Begunkov @ 2021-10-20 11:58 UTC (permalink / raw)
  To: Drew DeVault, io-uring

On 10/20/21 12:44, Drew DeVault wrote:
> On Wed Oct 20, 2021 at 12:15 PM CEST, Pavel Begunkov wrote:
>> Not a canonical way, but both should work (POLLIN for CQEs).
>> Do you have a simple test case for us to reproduce?
> 
> Hm, no, I cannot. I must have faced another bug, I was not able to
> produce a minimal test case and my attempt to reproduce my earlier bug
> in a larger test case was not succesful.

Sounds like polling is ok, let us know if there is any problem

> 
> One issue which remains is that attempting to use REGISTER_FILES on
> io_uring A with io_uring B's file descriptor returns EBADF. I saw a
> comment in the kernel source explaining this, but it's a bit contrived
> and the error case is not documented.

Surely should be updated if not mentioned

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-20 11:58     ` Pavel Begunkov
@ 2021-10-20 12:00       ` Drew DeVault
  2021-10-22  7:59         ` Drew DeVault
  0 siblings, 1 reply; 9+ messages in thread
From: Drew DeVault @ 2021-10-20 12:00 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On Wed Oct 20, 2021 at 1:58 PM CEST, Pavel Begunkov wrote:
> > One issue which remains is that attempting to use REGISTER_FILES on
> > io_uring A with io_uring B's file descriptor returns EBADF. I saw a
> > comment in the kernel source explaining this, but it's a bit contrived
> > and the error case is not documented.
>
> Surely should be updated if not mentioned

That, or the constraint removed? The reasoning is a bit obscure and I
suspect that this case could be made possible.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-20 12:00       ` Drew DeVault
@ 2021-10-22  7:59         ` Drew DeVault
  2021-10-22  9:49           ` Pavel Begunkov
  0 siblings, 1 reply; 9+ messages in thread
From: Drew DeVault @ 2021-10-22  7:59 UTC (permalink / raw)
  To: Drew DeVault, Pavel Begunkov, io-uring

On Wed Oct 20, 2021 at 2:00 PM CEST, Drew DeVault wrote:
> > Surely should be updated if not mentioned
>
> That, or the constraint removed? The reasoning is a bit obscure and I
> suspect that this case could be made possible.

So I dug into this a bit more, and the constraint seems to be to avoid a
reference loop when CONFIG_UNIX=n. I grepped Google and SourceGraph for
"CONFIG_UNIX=n" and only found two kernel configs with Unix sockets
disabled, neither of which had io_uring enabled. Given the rather
arbitrary restriction on registering io_urings with each other, and the
apparent absence of a use-case for io_uring without Unix sockets, can we
just require CONFIG_UNIX for io_uring and remove the limitation?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-22  7:59         ` Drew DeVault
@ 2021-10-22  9:49           ` Pavel Begunkov
  2021-10-22 10:26             ` Drew DeVault
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Begunkov @ 2021-10-22  9:49 UTC (permalink / raw)
  To: Drew DeVault, io-uring

On 10/22/21 08:59, Drew DeVault wrote:
> On Wed Oct 20, 2021 at 2:00 PM CEST, Drew DeVault wrote:
>>> Surely should be updated if not mentioned
>>
>> That, or the constraint removed? The reasoning is a bit obscure and I
>> suspect that this case could be made possible.
> 
> So I dug into this a bit more, and the constraint seems to be to avoid a
> reference loop when CONFIG_UNIX=n. I grepped Google and SourceGraph for
> "CONFIG_UNIX=n" and only found two kernel configs with Unix sockets
> disabled, neither of which had io_uring enabled. Given the rather
> arbitrary restriction on registering io_urings with each other, and the
> apparent absence of a use-case for io_uring without Unix sockets, can we
> just require CONFIG_UNIX for io_uring and remove the limitation?

It's potentially problematic, even now we have a couple of other
spots relying on it. Is there a good reason why it's needed?

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Polling on an io_uring file descriptor
  2021-10-22  9:49           ` Pavel Begunkov
@ 2021-10-22 10:26             ` Drew DeVault
  0 siblings, 0 replies; 9+ messages in thread
From: Drew DeVault @ 2021-10-22 10:26 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On Fri Oct 22, 2021 at 11:49 AM CEST, Pavel Begunkov wrote:
> It's potentially problematic, even now we have a couple of other
> spots relying on it. Is there a good reason why it's needed?

Yes, I have an application which uses one io_uring to manage a second
io_uring. I can skip registering the fd (current approach) or I can use
a different mechanism for managing the second uring (e.g. poll), but it
seems awkward and poorly justified that this invariant would exist.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-22 10:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20  9:21 Polling on an io_uring file descriptor Drew DeVault
2021-10-20 10:02 ` Drew DeVault
2021-10-20 10:15 ` Pavel Begunkov
2021-10-20 11:44   ` Drew DeVault
2021-10-20 11:58     ` Pavel Begunkov
2021-10-20 12:00       ` Drew DeVault
2021-10-22  7:59         ` Drew DeVault
2021-10-22  9:49           ` Pavel Begunkov
2021-10-22 10:26             ` Drew DeVault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.