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

From: Ingo Molnar
Date: Fri Aug 07 2009 - 06:31:44 EST



* Metzger, Markus T <markus.t.metzger@xxxxxxxxx> wrote:

> >-----Original Message-----
> >From: Peter Zijlstra [mailto:a.p.zijlstra@xxxxxxxxx]
> >Sent: Friday, August 07, 2009 10:21 AM
> >To: Metzger, Markus T
> >Cc: Ingo Molnar; tglx@xxxxxxxxxxxxx; hpa@xxxxxxxxx; markus.t.metzger@xxxxxxxxx; linux-
> >kernel@xxxxxxxxxxxxxxx
> >Subject: RE: [patch] x86, perf_counter, bts: add bts to perf_counter
> >
> >On Fri, 2009-08-07 at 08:29 +0100, Metzger, Markus T wrote:
> >
> >> I incorporated Peter's review comments, except that I would not enforce sample_period == 1
> >> when branch tracing is requested. There might be users who want to sample the IP every 100.000'th
> >> branch for profiling reasons.
> >
> >But in case you don't set sample_period==1 then you won't be able to
> >match the BTS counter:
> >
> >+ if (unlikely((event ==
> >+ x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS)) &&
> >+ (hwc->sample_period == 1)))
> >+ return X86_PMC_IDX_FIXED_BTS;
> >
> >Also,
> >
> >+ /*
> >+ * Try to use BTS for branch tracing. If that is not
> >+ * available, try to get a generic counter.
> >+ */
> >+ if (unlikely(!cpuc->ds))
> >+ goto try_generic;
> >
> >How will be use a generic counter for BTS, will it generate an NMI for
> >every encountered branch? That might very will hit the throttle as that
> >might be many.
> >
> >Would it not be better to force sample_period==1 usage onto the BTS and
> >simply fail if its not available?
>
> In case someone requests a bigger sample-period, we would use the
> normal counter - as we do without this patch. We would also use
> the normal counter in case BTS is not available.
>
> In that case, we won't have BTS, we will have normal performance
> monitoring. It will be throttled just like any other sampling
> request with small sample_period.
>
> If we forced sample_period = 1 for
> PERF_COUNT_HW_BRANCH_INSTRUCTIONS, we would remove functionality.

i'm inclined to agree with you.

period=1 branch execution sampling without BTS might be seriously
limited, but it could still be (borderline) applied to user mode
tasks and the result ought to be usable as a crude poor man's trace
of execution. So no matter how sucky it may be, we shouldnt limit
it.

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