public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Jann Horn <[email protected]>
Cc: io-uring <[email protected]>
Subject: Re: [PATCH] io_uring: use TWA_SIGNAL for task_work related to eventfd
Date: Thu, 6 Aug 2020 19:10:51 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAG48ez0QE3+a1Gb8ovEv_54wG-HA=Ph7fM4MT8EU8Exti0c_SQ@mail.gmail.com>

On 8/6/20 7:00 PM, Jann Horn wrote:
> On Fri, Aug 7, 2020 at 1:57 AM Jens Axboe <[email protected]> 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


      reply	other threads:[~2020-08-07  1:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 23:57 [PATCH] io_uring: use TWA_SIGNAL for task_work related to eventfd Jens Axboe
2020-08-07  1:00 ` Jann Horn
2020-08-07  1:10   ` Jens Axboe [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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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