linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Sustrik <sustrik@250bpm.com>
To: Eric Wong <normalperson@yhbt.net>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sha Zhengju <handai.szj@taobao.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] eventfd: implementation of EFD_MASK flag
Date: Sat, 09 Feb 2013 04:26:47 +0100	[thread overview]
Message-ID: <5115C1F7.8000705@250bpm.com> (raw)
In-Reply-To: <20130208220817.GA4256@dcvr.yhbt.net>

On 08/02/13 23:08, Eric Wong wrote:

>>>>> poll(2) function (POLLIN, POLLOUT, POLLERR, POLLHUP etc.) Specified
>>>>> events will
>>>>> be signaled when polling (select, poll, epoll) on the eventfd is done
>>>>> later on.
>>>>> 'ptr' is an opaque pointer that is not interpreted by eventfd object.
>>>>
>>>> How does this interact with EPOLLET?
>>>
>>> That's an interesting question. The original eventfd code doesn't do
>>> anything specific to either edge or level mode. Neither does my patch.
>>>
>>> Inspection of the code seems to suggest that edge vs. level distinction is
>>> handled elsewhere (ep_send_events_proc) where there is a separate list of
>>> ready events and the function, after returning the event, decides whether to
>>> leave the event in the list (level) or delete it from the list (edge).
>
> Right, the edge vs. level distinction is internal to epoll.

I wrote a test program for EFD_MASK+EPOLLET and it seems to behave in 
intuitive kind of way:

int main ()
{
     int fd;
     struct efd_mask mask;
     ssize_t nbytes;
     int rc;
     int ep;
     struct epoll_event epe;

     fd = eventfd (0, EFD_MASK);

     ep = epoll_create (10);
     assert (ep != -1);
     epe.events = EPOLLIN | EPOLLET;
     rc = epoll_ctl (ep, EPOLL_CTL_ADD, fd, &epe);
     assert (rc != -1);

     mask.events = 0;
     nbytes = write (fd, &mask, sizeof (mask));
     assert (nbytes == sizeof (mask));
     rc = epoll_wait (ep, &epe, 1, 100);
     assert (rc == 0);

     mask.events = POLLIN;
     nbytes = write (fd, &mask, sizeof (mask));
     assert (nbytes == sizeof (mask));
     rc = epoll_wait (ep, &epe, 1, 100);
     assert (rc == 1 && epe.events == EPOLLIN);
     rc = epoll_wait (ep, &epe, 1, 100);
     assert (rc == 0);

     mask.events = POLLIN;
     nbytes = write (fd, &mask, sizeof (mask));
     mask.events = 0;
     nbytes = write (fd, &mask, sizeof (mask));
     rc = epoll_wait (ep, &epe, 1, 100);
     assert (rc == 0);

     rc = close (ep);
     assert (rc == 0);
     rc = close (fd);
     assert (rc == 0);

     return 0;
}

Martin

  reply	other threads:[~2013-02-09  3:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07  6:41 [PATCH 1/1] eventfd: implementation of EFD_MASK flag Martin Sustrik
2013-02-07 19:12 ` Andy Lutomirski
2013-02-07 20:11   ` Martin Sustrik
2013-02-08  1:03     ` Andy Lutomirski
2013-02-08  5:26       ` Martin Sustrik
2013-02-08  6:36         ` Andy Lutomirski
2013-02-08  6:55           ` Martin Sustrik
2013-02-08 22:08       ` Eric Wong
2013-02-09  3:26         ` Martin Sustrik [this message]
2013-02-07 22:44 ` Andrew Morton
2013-02-07 23:30   ` Martin Sustrik
2013-02-08 12:43   ` Martin Sustrik
2013-02-08 22:21     ` Eric Wong
2013-02-09  2:40       ` Martin Sustrik
2013-02-09  3:54         ` Eric Wong
2013-02-09  7:36           ` Martin Sustrik
2013-02-09 11:51             ` Eric Wong
2013-02-09 12:04               ` Martin Sustrik
  -- strict thread matches above, loose matches on Subject: below --
2013-02-07 23:29 Martin Sustrik
2013-02-15  2:45 ` Michał Mirosław

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=5115C1F7.8000705@250bpm.com \
    --to=sustrik@250bpm.com \
    --cc=akpm@linux-foundation.org \
    --cc=handai.szj@taobao.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=normalperson@yhbt.net \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).