From: Jiri Olsa <jolsa@redhat.com>
To: Stephane Eranian <eranian@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: Re: [BUG] perf stat: hangs with -p and process completes
Date: Tue, 16 Oct 2018 13:03:41 +0200 [thread overview]
Message-ID: <20181016110341.GB18450@krava> (raw)
In-Reply-To: <CABPqkBTEOwKrq6ZJo3W-rZQi56OWorWo3VcOTwV17QxZBckS0Q@mail.gmail.com>
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
jirka
---
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
next prev parent reply other threads:[~2018-10-16 11:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 21:26 [BUG] perf stat: hangs with -p and process completes Stephane Eranian
2018-10-16 11:03 ` Jiri Olsa [this message]
2018-10-16 16:25 ` Jiri Olsa
2018-10-16 18:10 ` Stephane Eranian
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=20181016110341.GB18450@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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).