Re: [Patch 0/1] HW-BKPT: Allow per-cpu kernel-space Hardware Breakpoint requests

K.Prasad
2009-08-26T18:02:52Z

On Wed, Aug 26, 2009 at 01:49:57PM +0200, Frederic Weisbecker wrote:
> On Wed, Aug 26, 2009 at 11:16:42AM +0200, Ingo Molnar wrote:
> >
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> >
> > > On Fri, Aug 21, 2009 at 04:28:11PM +0200, Ingo Molnar wrote:
> > > >
> > > > * K.Prasad <prasad@linux.vnet.ibm.com> wrote:
> > > >
> > > > > > Providing those would let us build a pmu struct on top of this
> > > > > > high level API, hopefully.
> > > >
> > > > Note that there's a PMU struct already in
> > > > arch/x86/kernel/cpu/perf_counter.c. Could debug-register ops be
> > > > tacked on to it?
> > >
> > > No, we don't need to build an arch level pmu since the BP api
> > > already handles the arch abstraction (or well, it is planned to).
> > >
> > > Instead, what we need is a core pmu that relies on the BP api.
> > > Such pmu will be allocated dynamically while creating a hardware
> > > breakpoint counter.
> >
> > i'm not convinced at all we need all that layering of
> > perfcounters->pmu->BP. Why not add BP support to the PMU abstraction
> > and be done with it?
> >
> > That way we get hardware breakpoints via 'pinned, exclusive, per cpu
> > hw-breakpoint counters' for example and kernel/hw-breakpoint.c can
> > go away altogether.
> >
> > kernel/perf_counter.c already handles scheduling, conflict
> > resolution, enumeration, syscall exposure and more.
> >
> > Hm?
>
>
> What you are suggesting is a complete refactoring of the breakpoint API
> on top of pmus.
>
> Well, that's possible and would factorize the scheduling, conflict and so
> on. So that's theoretically a good point and I hope we'll come to such
> centralization, that looks like my suggestion to Peter to share the
> perfcounter layer that handles the scheduling of hardware registers.
>
> But the pmu handling is currently not ready for that.

I am not sure if pmus can handle, (or want to handle) all the intricacies
involved with the hw-breakpoint layer and let the other in-kernel users of
hw-breakpoint such as ptrace and ftrace (at the moment) operate over it.

The hw-breakpoint infrastructure has now grown to address nearly all
requirements of perf-tools (barring the facility to schedule
over-committed breakpoint requests, and a pending enable/disable
feature) while its interoperability allows co-existence of other users.

Given that there are multiple users of hw-breakpoint and that it is a
contended resource (with diversity in breakpoint characteristics)
wouldn't it be best to leave its management in a layer well below all
its users (including perf/pmu)?

That, in my opinion, would help the hw-breakpoint infrastructure evolve
continuously to help the users exploit the debug registers better.

Thanks,
K.Prasad