Re: [patch] x86, perf_counter, bts: add bts to perf_counter

From: Peter Zijlstra
Date: Fri Aug 07 2009 - 12:40:01 EST


On Fri, 2009-08-07 at 09:22 +0200, Markus Metzger wrote:
> Implement a performance counter with:
> attr.type = PERF_TYPE_HARDWARE
> attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS
> attr.sample_period = 1
>
> using branch trace store (BTS) on x86 hardware, if available.
>
> The from and to address for each branch can be sampled using:
> PERF_SAMPLE_IP for the from address
> PERF_SAMPLE_ADDR for the to address


The patch seems to forget one fundamental aspect, it doesn't provide a
counter.

The 'fake' fixed purpose counter we create only provides event samples,
but it does not provide a counter abstraction, so people who'd expect
read() to return the current count of things will get 0.

We could fix this by keeping a software counter along with it that
counts the number of BTS entries processed so far.



--
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/