diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-01-26 07:09:48 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-01-29 02:35:33 -0500 |
commit | 45a0e07abf4933490a2d2f81b1a31fe267bd3561 (patch) | |
tree | 05230649ec051aaf15617543e6b7756a1f389211 /kernel/events | |
parent | 8ba289b8d4e4dbd1f971fbf0d2085e4776a4ba25 (diff) |
perf: Add flags argument to perf_remove_from_context()
In preparation to adding more options, convert the boolean argument
into a flags word.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 8c3d95195f05..4291a4d27664 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -1770,6 +1770,8 @@ group_sched_out(struct perf_event *group_event, | |||
1770 | cpuctx->exclusive = 0; | 1770 | cpuctx->exclusive = 0; |
1771 | } | 1771 | } |
1772 | 1772 | ||
1773 | #define DETACH_GROUP 0x01UL | ||
1774 | |||
1773 | /* | 1775 | /* |
1774 | * Cross CPU call to remove a performance event | 1776 | * Cross CPU call to remove a performance event |
1775 | * | 1777 | * |
@@ -1782,10 +1784,10 @@ __perf_remove_from_context(struct perf_event *event, | |||
1782 | struct perf_event_context *ctx, | 1784 | struct perf_event_context *ctx, |
1783 | void *info) | 1785 | void *info) |
1784 | { | 1786 | { |
1785 | bool detach_group = (unsigned long)info; | 1787 | unsigned long flags = (unsigned long)info; |
1786 | 1788 | ||
1787 | event_sched_out(event, cpuctx, ctx); | 1789 | event_sched_out(event, cpuctx, ctx); |
1788 | if (detach_group) | 1790 | if (flags & DETACH_GROUP) |
1789 | perf_group_detach(event); | 1791 | perf_group_detach(event); |
1790 | list_del_event(event, ctx); | 1792 | list_del_event(event, ctx); |
1791 | 1793 | ||
@@ -1808,12 +1810,11 @@ __perf_remove_from_context(struct perf_event *event, | |||
1808 | * When called from perf_event_exit_task, it's OK because the | 1810 | * When called from perf_event_exit_task, it's OK because the |
1809 | * context has been detached from its task. | 1811 | * context has been detached from its task. |
1810 | */ | 1812 | */ |
1811 | static void perf_remove_from_context(struct perf_event *event, bool detach_group) | 1813 | static void perf_remove_from_context(struct perf_event *event, unsigned long flags) |
1812 | { | 1814 | { |
1813 | lockdep_assert_held(&event->ctx->mutex); | 1815 | lockdep_assert_held(&event->ctx->mutex); |
1814 | 1816 | ||
1815 | event_function_call(event, __perf_remove_from_context, | 1817 | event_function_call(event, __perf_remove_from_context, (void *)flags); |
1816 | (void *)(unsigned long)detach_group); | ||
1817 | } | 1818 | } |
1818 | 1819 | ||
1819 | /* | 1820 | /* |
@@ -3800,7 +3801,7 @@ static void put_event(struct perf_event *event) | |||
3800 | */ | 3801 | */ |
3801 | ctx = perf_event_ctx_lock_nested(event, SINGLE_DEPTH_NESTING); | 3802 | ctx = perf_event_ctx_lock_nested(event, SINGLE_DEPTH_NESTING); |
3802 | WARN_ON_ONCE(ctx->parent_ctx); | 3803 | WARN_ON_ONCE(ctx->parent_ctx); |
3803 | perf_remove_from_context(event, true); | 3804 | perf_remove_from_context(event, DETACH_GROUP); |
3804 | perf_event_ctx_unlock(event, ctx); | 3805 | perf_event_ctx_unlock(event, ctx); |
3805 | 3806 | ||
3806 | _free_event(event); | 3807 | _free_event(event); |
@@ -3840,7 +3841,7 @@ static void orphans_remove_work(struct work_struct *work) | |||
3840 | if (!is_orphaned_child(event)) | 3841 | if (!is_orphaned_child(event)) |
3841 | continue; | 3842 | continue; |
3842 | 3843 | ||
3843 | perf_remove_from_context(event, true); | 3844 | perf_remove_from_context(event, DETACH_GROUP); |
3844 | 3845 | ||
3845 | mutex_lock(&parent_event->child_mutex); | 3846 | mutex_lock(&parent_event->child_mutex); |
3846 | list_del_init(&event->child_list); | 3847 | list_del_init(&event->child_list); |
@@ -8430,11 +8431,11 @@ SYSCALL_DEFINE5(perf_event_open, | |||
8430 | * See perf_event_ctx_lock() for comments on the details | 8431 | * See perf_event_ctx_lock() for comments on the details |
8431 | * of swizzling perf_event::ctx. | 8432 | * of swizzling perf_event::ctx. |
8432 | */ | 8433 | */ |
8433 | perf_remove_from_context(group_leader, false); | 8434 | perf_remove_from_context(group_leader, 0); |
8434 | 8435 | ||
8435 | list_for_each_entry(sibling, &group_leader->sibling_list, | 8436 | list_for_each_entry(sibling, &group_leader->sibling_list, |
8436 | group_entry) { | 8437 | group_entry) { |
8437 | perf_remove_from_context(sibling, false); | 8438 | perf_remove_from_context(sibling, 0); |
8438 | put_ctx(gctx); | 8439 | put_ctx(gctx); |
8439 | } | 8440 | } |
8440 | 8441 | ||
@@ -8614,7 +8615,7 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu) | |||
8614 | mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex); | 8615 | mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex); |
8615 | list_for_each_entry_safe(event, tmp, &src_ctx->event_list, | 8616 | list_for_each_entry_safe(event, tmp, &src_ctx->event_list, |
8616 | event_entry) { | 8617 | event_entry) { |
8617 | perf_remove_from_context(event, false); | 8618 | perf_remove_from_context(event, 0); |
8618 | unaccount_event_cpu(event, src_cpu); | 8619 | unaccount_event_cpu(event, src_cpu); |
8619 | put_ctx(src_ctx); | 8620 | put_ctx(src_ctx); |
8620 | list_add(&event->migrate_entry, &events); | 8621 | list_add(&event->migrate_entry, &events); |
@@ -9240,7 +9241,7 @@ static void __perf_event_exit_context(void *__info) | |||
9240 | 9241 | ||
9241 | raw_spin_lock(&ctx->lock); | 9242 | raw_spin_lock(&ctx->lock); |
9242 | list_for_each_entry(event, &ctx->event_list, event_entry) | 9243 | list_for_each_entry(event, &ctx->event_list, event_entry) |
9243 | __perf_remove_from_context(event, cpuctx, ctx, (void *)(unsigned long)true); | 9244 | __perf_remove_from_context(event, cpuctx, ctx, (void *)DETACH_GROUP); |
9244 | raw_spin_unlock(&ctx->lock); | 9245 | raw_spin_unlock(&ctx->lock); |
9245 | } | 9246 | } |
9246 | 9247 | ||