Re: [PATCH] io_uring: use TWA_SIGNAL for task_work related to eventfd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/6/20 7:00 PM, Jann Horn wrote:
> On Fri, Aug 7, 2020 at 1:57 AM Jens Axboe <axboe@xxxxxxxxx> wrote:
>> An earlier commit:
>>
>> b7db41c9e03b ("io_uring: fix regression with always ignoring signals in io_cqring_wait()")
>>
>> ensured that we didn't get stuck waiting for eventfd reads when it's
>> registered with the io_uring ring for event notification, but that didn't
>> cover the general case of waiting on eventfd and having that dependency
>> between io_uring and eventfd.
>>
>> Ensure that we use signaled notification for anything related to eventfd.
> [...]
>> @@ -1720,7 +1720,7 @@ static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
>>          */
>>         if (ctx->flags & IORING_SETUP_SQPOLL)
>>                 notify = 0;
>> -       else if (ctx->cq_ev_fd)
>> +       else if (ctx->cq_ev_fd || (req->file && eventfd_file(req->file)))
>>                 notify = TWA_SIGNAL;
> 
> Is the idea here that you want "polling an eventfd" to have different
> UAPI semantics compared to e.g. "polling a pipe"? Or is there
> something in-kernel that makes eventfds special?

I looked more at this after sending it out, and I actually think we want
the logic to be something ala:

else if (ctx->cq_ev_fd || (tsk->state != TASK_RUNNING))
        notify = TWA_SIGNAL;

instead, or something like that. Basically if the task is currently
waiting in the kernel, then the wakeup logic isn't enough, while
TWA_SIGNAL will do the right thing.

Looking into if we have a better way to tell if that's the case outside
of checking the targeted task state (and even if TASK_RUNNING is the
right one, vs checking if it's TASK_INTERRUPTIBLE/TASK_UNINTERRUPTIBLE
specifically).

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux