perf: Avoid a useless pmu_disable() in the perf-tick
Commit-ID: 0f5a2601284237e2ba089389fd75d67f77626cef Gitweb: http://git.kernel.org/tip/0f5a2601284237e2ba089389fd75d67f77626cef Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 16 Nov 2011 14:38:16 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 6 Dec 2011 08:33:52 +0100
perf: Avoid a useless pmu_disable() in the perf-tick
Quoted 5 lines · Gleb
Currently pmu is disabled and re-enabled on each timer interrupt even when no rotation or frequency adjustment is needed. On Intel CPU this results in two writes into
PERF_GLOBAL_CTRLMSR per tick. On bare metal it does not cause significant slowdown, but when running perf in a virtual machine it leads to 20% slowdown on my machine.
Cure this by keeping a perf_event_context::nr_freq counter that counts the number of active events that require frequency adjustments and use this in a similar fashion to the already existing nr_events != nr_active test in perf_rotate_context().
By being able to exclude both rotation and frequency adjustments a-priory for the common case we can avoid the otherwise superfluous PMU disable.
--- include/linux/perf_event.h | 1 + kernel/events/core.c | 48 +++++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 16 deletions(-)
include/linux/perf_event.h +1 -0
@@ -890,6 +890,7 @@ struct perf_event_context {int nr_active;int is_active;int nr_stat; +int nr_freq;int rotate_disable;atomic_t refcount;struct task_struct *task;
kernel/events/core.c +32 -16
95 lines not on this page · raw message