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