Re: [PATCH 8/9] perf/breakpoint: Split breakpoint "check" and "commit"
From: Frederic Weisbecker
Date: Tue May 15 2018 - 13:39:06 EST
On Tue, May 15, 2018 at 08:57:47AM +0200, Ingo Molnar wrote:
>
> * Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> > On Sun, May 06, 2018 at 09:19:54PM +0200, Frederic Weisbecker wrote:
> > > arch/arm/include/asm/hw_breakpoint.h | 5 ++++-
> > > arch/arm/kernel/hw_breakpoint.c | 22 +++-------------------
> > > arch/arm64/include/asm/hw_breakpoint.h | 5 ++++-
> > > arch/arm64/kernel/hw_breakpoint.c | 22 +++-------------------
> > > arch/powerpc/include/asm/hw_breakpoint.h | 5 ++++-
> > > arch/powerpc/kernel/hw_breakpoint.c | 22 +++-------------------
> > > arch/sh/include/asm/hw_breakpoint.h | 5 ++++-
> > > arch/sh/kernel/hw_breakpoint.c | 22 +++-------------------
> > > arch/x86/include/asm/hw_breakpoint.h | 5 ++++-
> > > arch/x86/kernel/hw_breakpoint.c | 23 +++--------------------
> > > arch/xtensa/include/asm/hw_breakpoint.h | 5 ++++-
> > > arch/xtensa/kernel/hw_breakpoint.c | 22 +++-------------------
> >
> > Because of those ^,
> >
> > > kernel/events/hw_breakpoint.c | 11 ++++++-----
> >
> > would it not make sense to have a prelimenary patch doing something
> > like:
> >
> > __weak int hw_breakpoint_arch_check(struct perf_event *bp)
> > {
> > return arch_validate_hwbkpt_settings(bp);
> > }
> >
> > __weak void hw_breakpoint_arch_commit(struct perf_event *bp)
> > {
> > }
> >
> > combined with this bit:
> >
> > > diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
> > > index 6e28d28..6896ceeb 100644
> > > --- a/kernel/events/hw_breakpoint.c
> > > +++ b/kernel/events/hw_breakpoint.c
> > > @@ -402,11 +402,12 @@ int dbg_release_bp_slot(struct perf_event *bp)
> > >
> > > static int validate_hw_breakpoint(struct perf_event *bp)
> > > {
> > > - int ret;
> > > + int err;
> > >
> > > - ret = arch_validate_hwbkpt_settings(bp);
> > > - if (ret)
> > > - return ret;
> > > + err = hw_breakpoint_arch_check(bp, &bp->attr);
> > > + if (err)
> > > + return err;
> > > + hw_breakpoint_arch_commit(bp);
> > >
> > > if (arch_check_bp_in_kernelspace(bp)) {
> > > if (bp->attr.exclude_kernel)
> >
> > And then convert the archs over one by one, and at the end remove the
> > weak thingies entirely?
>
> Makes sense.
>
> The rest looks good to me - Frederic, once you implement Peter's uggestion I
> suspect this series can be applied.
Right, I'll try to do a smoother transition as in Peterz suggestion.
I'm just going to pass around the struct arch_hw_breakpoint to avoid code
duplication in check and commit. The end result may look like:
struct arch_hw_breakpoint hw;
int err;
err = hw_breakpoint_arch_parse(bp, attr, &hw);
if (err)
return err;
.....
bp->hw.info = hw;