All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Jann Horn <jannh@google.com>
Cc: io-uring <io-uring@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 2/3] eventpoll: support non-blocking do_epoll_ctl() calls
Date: Wed, 22 Jan 2020 09:23:48 -0700	[thread overview]
Message-ID: <b1dbe59e-fd25-d8da-e909-667d2a515e46@kernel.dk> (raw)
In-Reply-To: <CAG48ez0+wiY4i0nFFXpKvqpQDNYQvzHAJhAMVD0rv5cpEicWkw@mail.gmail.com>

On 1/22/20 9:20 AM, Jann Horn wrote:
> On Wed, Jan 22, 2020 at 5:02 PM Jens Axboe <axboe@kernel.dk> wrote:
>> Also make it available outside of epoll, along with the helper that
>> decides if we need to copy the passed in epoll_event.
> [...]
>> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
>> index cd848e8d08e2..162af749ea50 100644
>> --- a/fs/eventpoll.c
>> +++ b/fs/eventpoll.c
> [...]
>> -static int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds)
>> +static inline int epoll_mutex_lock(struct mutex *mutex, int depth,
>> +                                  bool nonblock)
>> +{
>> +       if (!nonblock) {
>> +               mutex_lock_nested(mutex, depth);
>> +               return 0;
>> +       }
>> +       if (!mutex_trylock(mutex))
>> +               return 0;
>> +       return -EAGAIN;
> 
> The documentation for mutex_trylock() says:
> 
>  * Try to acquire the mutex atomically. Returns 1 if the mutex
>  * has been acquired successfully, and 0 on contention.
> 
> So in the success case, this evaluates to:
> 
>     if (!1)
>       return 0;
>     return -EAGAIN;
> 
> which is
> 
>     if (0)
>       return 0;
>     return -EAGAIN;
> 
> which is
> 
>     return -EAGAIN;
> 
> I think you'll have to get rid of the negation.

Doh indeed. I'll rework and run the test case, just rebased this and I
think I inadvertently used an older version. Ditto for the below.

-- 
Jens Axboe


  reply	other threads:[~2020-01-22 16:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 16:02 [PATCHSET 0/3] Add io_uring support for epoll_ctl Jens Axboe
2020-01-22 16:02 ` [PATCH 1/3] eventpoll: abstract out epoll_ctl() handler Jens Axboe
2020-01-22 16:02 ` [PATCH 2/3] eventpoll: support non-blocking do_epoll_ctl() calls Jens Axboe
2020-01-22 16:20   ` Jann Horn
2020-01-22 16:23     ` Jens Axboe [this message]
2020-01-22 16:02 ` [PATCH 3/3] io_uring: add support for epoll_ctl(2) Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2020-01-22 16:42 [PATCHSET v2 0/3] Add io_uring support for epoll_ctl Jens Axboe
2020-01-22 16:42 ` [PATCH 2/3] eventpoll: support non-blocking do_epoll_ctl() calls Jens Axboe

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 \
    --in-reply-to=b1dbe59e-fd25-d8da-e909-667d2a515e46@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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 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.