aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2014-08-07 11:48:26 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-08-24 07:11:09 -0400
commit179033b3e064d2cd3f5f9945e76b0a0f0fbf4883 (patch)
tree7a470e9a799e4221fd4f319f4e190fd6e313e908
parent61b67684c4a4d04b30d9ed67aa2eadfa0089c590 (diff)
perf: Add PERF_EVENT_STATE_EXIT state for events with exited task
Adding new perf event state to indicate that the monitored task has exited. In this case the event stays alive until the owner task exits or close the event fd while providing the last data through the read syscall and ring buffer. Instead it needs to propagate the error info (monitored task has died) via poll and read syscalls by returning POLLHUP and 0 respectively. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20140811120102.GY9918@twins.programming.kicks-ass.net Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jean Pihet <jean.pihet@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-t5y3w8jjx6tfo5w8y6oajsjq@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--include/linux/perf_event.h1
-rw-r--r--kernel/events/core.c10
2 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f0a1036b1911..893a0d07986f 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -269,6 +269,7 @@ struct pmu {
269 * enum perf_event_active_state - the states of a event 269 * enum perf_event_active_state - the states of a event
270 */ 270 */
271enum perf_event_active_state { 271enum perf_event_active_state {
272 PERF_EVENT_STATE_EXIT = -3,
272 PERF_EVENT_STATE_ERROR = -2, 273 PERF_EVENT_STATE_ERROR = -2,
273 PERF_EVENT_STATE_OFF = -1, 274 PERF_EVENT_STATE_OFF = -1,
274 PERF_EVENT_STATE_INACTIVE = 0, 275 PERF_EVENT_STATE_INACTIVE = 0,
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4575dd6e59ea..d8cb4d21a346 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3600,7 +3600,8 @@ perf_read_hw(struct perf_event *event, char __user *buf, size_t count)
3600 * error state (i.e. because it was pinned but it couldn't be 3600 * error state (i.e. because it was pinned but it couldn't be
3601 * scheduled on to the CPU at some point). 3601 * scheduled on to the CPU at some point).
3602 */ 3602 */
3603 if (event->state == PERF_EVENT_STATE_ERROR) 3603 if ((event->state == PERF_EVENT_STATE_ERROR) ||
3604 (event->state == PERF_EVENT_STATE_EXIT))
3604 return 0; 3605 return 0;
3605 3606
3606 if (count < event->read_size) 3607 if (count < event->read_size)
@@ -3630,6 +3631,10 @@ static unsigned int perf_poll(struct file *file, poll_table *wait)
3630 unsigned int events = POLLHUP; 3631 unsigned int events = POLLHUP;
3631 3632
3632 poll_wait(file, &event->waitq, wait); 3633 poll_wait(file, &event->waitq, wait);
3634
3635 if (event->state == PERF_EVENT_STATE_EXIT)
3636 return events;
3637
3633 /* 3638 /*
3634 * Pin the event->rb by taking event->mmap_mutex; otherwise 3639 * Pin the event->rb by taking event->mmap_mutex; otherwise
3635 * perf_event_set_output() can swizzle our rb and make us miss wakeups. 3640 * perf_event_set_output() can swizzle our rb and make us miss wakeups.
@@ -7588,6 +7593,9 @@ __perf_event_exit_task(struct perf_event *child_event,
7588 if (child_event->parent) { 7593 if (child_event->parent) {
7589 sync_child_event(child_event, child); 7594 sync_child_event(child_event, child);
7590 free_event(child_event); 7595 free_event(child_event);
7596 } else {
7597 child_event->state = PERF_EVENT_STATE_EXIT;
7598 perf_event_wakeup(child_event);
7591 } 7599 }
7592} 7600}
7593 7601