From: Davide Libenzi <davidel@xmailserver.org>
To: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Unexpected cascaded epoll behavior - my mistake or kernel bug
Date: Mon, 26 Jan 2009 12:36:04 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.1.10.0901261235000.26576@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <alpine.DEB.1.10.0901261152160.26576@alien.or.mcafeemobile.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1473 bytes --]
On Mon, 26 Jan 2009, Davide Libenzi wrote:
> On Mon, 26 Jan 2009, Pavel Pisa wrote:
>
> > Hello Davide,
> >
> > thanks for fast reply and effort.
> >
> > I have tested your patch with patched and unpatched 2.6.28.2 kernel.
> > The outputs are attached. The patched kernel passes all your tests.
> >
> > But I have bad news. My library code does not fall into busy loop
> > after your patching but my FIFO tests do not work even in
> > single level epoll scenario. The strace output is attached as well.
> > I try to do more testing tomorrow. I have returned from weekend trip
> > at the evening today and I have not much time for deeper analysis.
> >
> > But it looks like write level sensitive events are not triggering
> > for epoll at all. The pipe is not fill by any character and specified
> > timeout is triggered with next message as fail results.
> > @ pipe #X evptrig wr timeout
> > @ pipe #X evptrig rd timeout
> >
> > If you want to test the code on your box, download library
> >
> > http://cmp.felk.cvut.cz/~pisa/ulan/ul_evpoll-090123.tar.gz
> >
> > The simple "make" in the top directory should work.
>
> It'd be really great if you could spare me having to dig into few
> thousands lines of userspace library code, and you could isolate a little
> bit better what is the expected result, and the error result.
Never mind, I looked myself and I'm able to replicate it with the simple
attached test program. Looking into it ...
- Davide
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-csrc; name=epoll_pipe_pingpong.c, Size: 2757 bytes --]
/*
* epoll_pipe_pingpong by Davide Libenzi (Another epoll and pipes test)
* Copyright (C) 2009 Davide Libenzi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Davide Libenzi <davidel@xmailserver.org>
*
*/
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <limits.h>
#include <poll.h>
#include <sys/epoll.h>
#include <sys/wait.h>
#define EPWAIT_TIMEO (1 * 1000)
static int xepoll_create(int n) {
int epfd;
if ((epfd = epoll_create(n)) == -1) {
perror("epoll_create");
exit(2);
}
return epfd;
}
static void xepoll_ctl(int epfd, int cmd, int fd, struct epoll_event *evt) {
if (epoll_ctl(epfd, cmd, fd, evt) < 0) {
perror("epoll_ctl");
exit(3);
}
}
static void xpipe(int *fds) {
if (pipe(fds)) {
perror("pipe");
exit(4);
}
}
static int run_test(void) {
int n, epfd, loops;
int pfds[2];
char rdb[2];
struct epoll_event evt, evts[8];
epfd = xepoll_create(1);
xpipe(pfds);
fcntl(pfds[0], F_SETFL, fcntl(pfds[0], F_GETFL, 0) | O_NONBLOCK);
memset(&evt, 0, sizeof(evt));
evt.data.fd = pfds[0];
evt.events = EPOLLIN;
xepoll_ctl(epfd, EPOLL_CTL_ADD, pfds[0], &evt);
evt.data.fd = pfds[1];
evt.events = EPOLLOUT;
xepoll_ctl(epfd, EPOLL_CTL_ADD, pfds[1], &evt);
for (loops = 100; loops > 0; loops--) {
n = epoll_wait(epfd, evts, 8, EPWAIT_TIMEO);
if (n <= 0) {
fprintf(stderr, "Aiee!! Why no events?!\n");
break;
}
for (; n > 0; n--) {
struct epoll_event *pevt = &evts[n - 1];
if (pevt->data.fd == pfds[1] &&
pevt->events & EPOLLOUT) {
fprintf(stdout, "Write side, strong side!\n");
write(pfds[1], "w", 1);
} else if (pevt->data.fd == pfds[0] &&
pevt->events & EPOLLIN) {
fprintf(stdout, "Read side, strong side!\n");
while (read(pfds[0], rdb, sizeof(rdb)) > 0);
}
}
}
return 0;
}
int main(int ac, char **av) {
return run_test();
}
next prev parent reply other threads:[~2009-01-26 20:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-23 0:09 Pavel Pisa
2009-01-23 1:21 ` Davide Libenzi
2009-01-24 21:58 ` Davide Libenzi
2009-01-25 21:02 ` Davide Libenzi
2009-01-26 1:28 ` Pavel Pisa
2009-01-26 19:54 ` Davide Libenzi
2009-01-26 20:36 ` Davide Libenzi [this message]
2009-01-26 21:04 ` Davide Libenzi
2009-01-27 0:24 ` Pavel Pisa
2009-01-27 1:03 ` Davide Libenzi
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=alpine.DEB.1.10.0901261235000.26576@alien.or.mcafeemobile.com \
--to=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pisa@cmp.felk.cvut.cz \
/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
all inboxes | Powered by JetHome®