Keep track of toggle events within the toggled event. It'll be handy for toggle inherit support.
Signed-off-by: Jiri Olsa <jo...@redhat.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Corey Ashford <cjash...@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweis...@gmail.com> Cc: Ingo Molnar <mi...@elte.hu> Cc: Paul Mackerras <pau...@samba.org> Cc: Peter Zijlstra <a.p.zijls...@chello.nl> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> --- include/linux/perf_event.h | 1 + kernel/events/core.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 6ede25c..801ff22 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -423,6 +423,7 @@ struct perf_event { struct perf_event *toggled_event; enum perf_event_toggle_flag toggle_flag; int paused; + atomic_t toggled_cnt; #endif /* CONFIG_PERF_EVENTS */ }; diff --git a/kernel/events/core.c b/kernel/events/core.c index f5f00a6..7df7a21 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1372,6 +1372,7 @@ static void __perf_event_toggle_detach(struct perf_event *event) event->overflow_handler = NULL; event->toggled_event = NULL; + atomic_dec(&toggled_event->toggled_cnt); put_event(toggled_event); } @@ -7064,6 +7065,8 @@ static int perf_event_set_toggle_fd(struct perf_event *event, u64 __user *arg) err = perf_event_set_toggle(event, toggled_event, event->ctx, flag); if (err) put_event(toggled_event); + else + atomic_inc(&toggled_event->toggled_cnt); fdput(toggled_fd); return err; @@ -7251,6 +7254,8 @@ SYSCALL_DEFINE5(perf_event_open, if (!atomic_long_inc_not_zero(&toggled_event->refcount)) goto err_context; + atomic_inc(&toggled_event->toggled_cnt); + err = perf_event_set_toggle(event, toggled_event, ctx, flags); if (err) goto err_toggle; @@ -7328,8 +7333,10 @@ SYSCALL_DEFINE5(perf_event_open, return event_fd; err_toggle: - if (toggled_event) + if (toggled_event) { + atomic_dec(&toggled_event->toggled_cnt); put_event(toggled_event); + } err_context: perf_unpin_context(ctx); put_ctx(ctx); -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/