public inbox for [email protected]
 help / color / mirror / Atom feed
* IORING_OP_RECVMSG not respects non-blocking nature of the fd
@ 2021-03-16 14:00 Norman Maurer
  2021-03-16 14:23 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Norman Maurer @ 2021-03-16 14:00 UTC (permalink / raw)
  To: io-uring

Hi there,

I think I found a bug in the current io_uring implementation. It seems like recvmsg currently not respect when a fd is set to non-blocking.  At the moment recvmsg never returns in this case. I can work around this by using MSG_DONTWAIT but I don’t think this should be needed.

I am using the latest 5.12 code base atm.

Bye
Norman


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

* Re: IORING_OP_RECVMSG not respects non-blocking nature of the fd
  2021-03-16 14:00 IORING_OP_RECVMSG not respects non-blocking nature of the fd Norman Maurer
@ 2021-03-16 14:23 ` Jens Axboe
  2021-03-16 16:00   ` Stefan Metzmacher
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2021-03-16 14:23 UTC (permalink / raw)
  To: Norman Maurer, io-uring

On 3/16/21 8:00 AM, Norman Maurer wrote:
> Hi there,
> 
> I think I found a bug in the current io_uring implementation. It seems
> like recvmsg currently not respect when a fd is set to non-blocking.
> At the moment recvmsg never returns in this case. I can work around
> this by using MSG_DONTWAIT but I don’t think this should be needed.
> 
> I am using the latest 5.12 code base atm.

This is actually "by design" in that system calls that offer a "don't
block for this operation" (like MSG_DONTWAIT here) will not be looking
at the O_NONBLOCK flag. Though it is a bit confusing and potentially
inconsistent, my argument here is that this is the case for system calls
in general, where even O_NONBLOCK has very hazy semantics depending on
what system call you are looking at.

The issue is mostly around when to use -EAGAIN to arm async retry, and
when to return -EAGAIN to the application.

I'd like to hear from others here, but as far as io_uring is concerned,
we _should_ be consistent in how we treat O_NONBLOCK _depending_ on if
that system call allows a flags method of passing in nonblock behavior.

-- 
Jens Axboe


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

* Re: IORING_OP_RECVMSG not respects non-blocking nature of the fd
  2021-03-16 14:23 ` Jens Axboe
@ 2021-03-16 16:00   ` Stefan Metzmacher
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Metzmacher @ 2021-03-16 16:00 UTC (permalink / raw)
  To: Jens Axboe, Norman Maurer, io-uring


Am 16.03.21 um 15:23 schrieb Jens Axboe:
> On 3/16/21 8:00 AM, Norman Maurer wrote:
>> Hi there,
>>
>> I think I found a bug in the current io_uring implementation. It seems
>> like recvmsg currently not respect when a fd is set to non-blocking.
>> At the moment recvmsg never returns in this case. I can work around
>> this by using MSG_DONTWAIT but I don’t think this should be needed.
>>
>> I am using the latest 5.12 code base atm.
> 
> This is actually "by design" in that system calls that offer a "don't
> block for this operation" (like MSG_DONTWAIT here) will not be looking
> at the O_NONBLOCK flag. Though it is a bit confusing and potentially
> inconsistent, my argument here is that this is the case for system calls
> in general, where even O_NONBLOCK has very hazy semantics depending on
> what system call you are looking at.
> 
> The issue is mostly around when to use -EAGAIN to arm async retry, and
> when to return -EAGAIN to the application.
> 
> I'd like to hear from others here, but as far as io_uring is concerned,
> we _should_ be consistent in how we treat O_NONBLOCK _depending_ on if
> that system call allows a flags method of passing in nonblock behavior.

As ____sys_recvmsg() has this:

        if (sock->file->f_flags & O_NONBLOCK)
                flags |= MSG_DONTWAIT;

The difference is that we don't block in__sys_recvmsg() within a worker thread,
but instead handle it via io_arm_poll_handler()?

I think it should be documented, but I guess it might be useful to keep a way
to switch between the 3 available modes in order to find the one that
performances best depending on the workload.

metze

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

end of thread, other threads:[~2021-03-16 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-16 14:00 IORING_OP_RECVMSG not respects non-blocking nature of the fd Norman Maurer
2021-03-16 14:23 ` Jens Axboe
2021-03-16 16:00   ` Stefan Metzmacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox