Re: [PATCH 2/6] RFC perf_counter: singleshot support

From: Paul Mackerras
Date: Thu Apr 02 2009 - 17:24:06 EST


Ingo Molnar writes:

> Sure. One sidenote - the precision of sw clocks has dropped a bit
> lately:
>
> aldebaran:~/linux/linux/Documentation/perf_counter> ./perfstat -e
> 1:0 -e 1:0 -e 1:0 -e 1:0 -e 1:0 sleep 1
>
> Performance counter stats for 'sleep':
>
> 0.762664 cpu clock ticks (msecs)
> 0.761440 cpu clock ticks (msecs)
> 0.760977 cpu clock ticks (msecs)
> 0.760587 cpu clock ticks (msecs)
> 0.760287 cpu clock ticks (msecs)
>
> Wall-clock time elapsed: 1003.139373 msecs
>
> See that slight but noticeable skew? This used to work fine and we
> had the exact same value everywhere. Can we fix that while still
> keeping the code nice?

I suggest basing the software clock on counter->ctx->time_now, and
make get_context_time use cpu_clock() always. That way we will only
call cpu_clock() once even if we have multiple cpu clock counters, and
that will eliminate the skew as well as being more efficient.

Paul.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/