[lkml]   [2018]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [BUG] perf stat: hangs with -p and process completes
On Fri, Oct 12, 2018 at 02:26:09PM -0700, Stephane Eranian wrote:
> Hi,
> I am running into a perf stat issue with the -p option which allows you
> to attach to a running process. If that process happens to terminate
> while under monitoring
> perf hangs in there and never terminates. The proper behavior would be to stop.
> I can see the issue in that the attached process is not a child, so
> wait() would not work.
> To reproduce:
> $ sleep 10 &
> $ perf stat -p $!
> doing the same with perf record works, so there is a solution to this problem.

yea, we don't poll for the event state change in perf stat,
but we do that in perf record.. also because the perf poll
code in kernel is originaly meant for tracking the ring
buffer state

maybe we could return EPOLLIN for alive events without ring
buffer.. like below (totaly untested) and add polling for
event state into perf stat

cc-ing perf folks


diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5a97f34bc14c..b9ee7e7803bf 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4865,12 +4865,12 @@ static __poll_t perf_poll(struct file *file, poll_table *wait)
struct perf_event *event = file->private_data;
struct ring_buffer *rb;
- __poll_t events = EPOLLHUP;
+ __poll_t events = EPOLLIN;

poll_wait(file, &event->waitq, wait);

if (is_event_hup(event))
- return events;
+ return EPOLLHUP;

* Pin the event->rb by taking event->mmap_mutex; otherwise
 \ /
  Last update: 2018-10-16 13:05    [W:0.048 / U:5.500 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site