diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2016-08-16 16:35:12 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-08-16 16:35:12 -0700 |
| commit | d2113df12ae1604b3b0f4012ab723c090ba19d00 (patch) | |
| tree | 985030efef4d95b093c43e8052c75a6711bdbc6f /kernel | |
| parent | 2d546ee279b7e90a33100d05e5f01b17d582d465 (diff) | |
| parent | 573979dee2a76e4d7f61cb867c12afbaed7e1eb5 (diff) | |
Merge "perf: Add support for exclude_idle attribute"
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/events/core.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 96100cc046c5..32e2617d654f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -158,6 +158,7 @@ enum event_type_t { struct static_key_deferred perf_sched_events __read_mostly; static DEFINE_PER_CPU(atomic_t, perf_cgroup_events); static DEFINE_PER_CPU(int, perf_sched_cb_usages); +static DEFINE_PER_CPU(bool, is_idle); static atomic_t nr_mmap_events __read_mostly; static atomic_t nr_comm_events __read_mostly; @@ -3388,9 +3389,12 @@ static int perf_event_read(struct perf_event *event, bool group) .group = group, .ret = 0, }; - smp_call_function_single(event->oncpu, - __perf_event_read, &data, 1); - ret = data.ret; + if (!event->attr.exclude_idle || + !per_cpu(is_idle, event->oncpu)) { + smp_call_function_single(event->oncpu, + __perf_event_read, &data, 1); + ret = data.ret; + } } else if (event->state == PERF_EVENT_STATE_INACTIVE) { struct perf_event_context *ctx = event->ctx; unsigned long flags; @@ -9479,6 +9483,25 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) return NOTIFY_OK; } +static int event_idle_notif(struct notifier_block *nb, unsigned long action, + void *data) +{ + switch (action) { + case IDLE_START: + __this_cpu_write(is_idle, true); + break; + case IDLE_END: + __this_cpu_write(is_idle, false); + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block perf_event_idle_nb = { + .notifier_call = event_idle_notif, +}; + void __init perf_event_init(void) { int ret; @@ -9492,6 +9515,7 @@ void __init perf_event_init(void) perf_pmu_register(&perf_task_clock, NULL, -1); perf_tp_register(); perf_cpu_notifier(perf_cpu_notify); + idle_notifier_register(&perf_event_idle_nb); register_reboot_notifier(&perf_reboot_notifier); ret = init_hw_breakpoint(); |
