oprofile and ARM A9 hardware counter

Ming Lei ming.lei at canonical.com
Thu Feb 16 11:37:35 EST 2012


On Fri, Feb 17, 2012 at 12:19 AM, Peter Zijlstra <a.p.zijlstra at chello.nl> wrote:
> On Fri, 2012-02-17 at 00:12 +0800, Ming Lei wrote:
>> is triggered: u64 delta = 100 -  1000000 = 18446744073708551716.
>
> on x86 we do:
>
>  int shift = 64 - x86_pmu.cntval_bits;
>  s64 delta;
>
>  delta = (new_raw_count << shift) - (prev_raw_count << shift);
>  delta >>= shift;
>
> This deals with short overflows (on x86 the registers are typically 40
> or 48 bits wide). If the arm register is 32 you can of course also get
> there with some u32 casts.

Good idea, but it may not work if new_raw_count is bigger than prev_raw_count.

thanks
--
Ming Lei



More information about the linux-arm-kernel mailing list