From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Sustrik Subject: Re: [PATCH 1/1] eventfd: implementation of EFD_MASK flag Date: Sat, 09 Feb 2013 04:26:47 +0100 Message-ID: <5115C1F7.8000705@250bpm.com> References: <1360219292-19754-1-git-send-email-sustrik@250bpm.com> <5113FCA7.4020207@mit.edu> <51140A60.4070705@250bpm.com> <20130208220817.GA4256@dcvr.yhbt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Andy Lutomirski , Alexander Viro , Andrew Morton , Sha Zhengju , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Eric Wong Return-path: In-Reply-To: <20130208220817.GA4256@dcvr.yhbt.net> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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