Re: perf: wrong event->count report (Was: perf basic-test-aarch64 failures)

From: Oleg Nesterov
Date: Wed Feb 17 2016 - 14:34:50 EST


On 02/17, Peter Zijlstra wrote:
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3173,6 +3173,10 @@ static void perf_event_enable_on_exec(in
>
> cpuctx = __get_cpu_context(ctx);
> perf_ctx_lock(cpuctx, ctx);
> +
> + update_context_time(ctx);
> + update_cgrp_time_from_cpuctx(cpuctx);
> +

Even if I don't really understand this change I agree, probably we need to update
the counters for enable_on_exec events somehow. But I don't see how this change can
make total_time_running == total_time_enabled.

And probably this is fine. In fact I do not understand why they should be equal.
I inserted printf() into perf_counts_values__scale() to verify that /usr/bin/perf
always sees count->run < count->ena even if I do, say,

# perf stat -x- -e module:module_load -a sleep 1

0--module:module_load-1007397333-100.00

the kernel reports run=1007397333 ena=1007397573. Close but not equal. Again, I
do not think this is wrong, I am only saying that I don't understand this logic
because this always means "scaled" for perf.

Nevermind, I never looked into tools/perf before, most probably I simply do not
understand it at all.

Oleg.