[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.11.1501210058090.21805@vincent-weaver-1.umelst.maine.edu>
Date: Wed, 21 Jan 2015 01:06:30 -0500 (EST)
From: Vince Weaver <vincent.weaver@...ne.edu>
To: Jiri Olsa <jolsa@...hat.com>
cc: Vince Weaver <vincent.weaver@...ne.edu>,
linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Ingo Molnar <mingo@...nel.org>,
Paul Mackerras <paulus@...ba.org>
Subject: Re: perf: behavior of poll() changed in 3.18
On Tue, 20 Jan 2015, Jiri Olsa wrote:
> I made this change to get notification that monitored
> process exited. We use it in 'perf record' to find out
> that we have nothing more to monitor and quit.
>
> The logic is to return POLLHUP (via poll syscall) when
> the monitored process exits for the event.
>
> Could you please share your test code?
My code does something like this to count the number of overflows
happening in a child:
/* fds contains one fd, which is a harware event */
/* attached to a child */
while(1) {
result=poll(fds,1,100);
if (result==0) {
waitpid(child,&status,WNOHANG);
if (WIFEXITED(status)) break;
if (WIFSIGNALED(status)) {
printf("Signalled %d!\n",WTERMSIG(status));
break;
}
}
if (fds[0].revents&POLLIN) count.in++;
if (fds[0].revents&POLLHUP) count.hup++;
if (fds[0].revents&POLLERR) break;
}
With the change you made this code hangs forever because poll no longer
returns "0" when the child exits, but instead returns "1" with
POLLHUP set.
I admit my code isn't the best out there, but it worked reliably up
until 3.18 when the change was made.
Part of why my code doesn't just exit on POLLHUP is because you can
get that result for reasons other than a process exit (for example,
if you are using ioctl(PERF_EVENT_IOC_REFRESH)
Vince
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists