[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <FCFCADD62FC0CA4FAEA05F13220975B01717C7F7@dggeml525-mbx.china.huawei.com>
Date: Thu, 26 Sep 2019 10:15:39 +0000
From: "wangxu (AE)" <wangxu72@...wei.com>
To: Peter Zijlstra <peterz@...radead.org>
CC: "mingo@...hat.com" <mingo@...hat.com>,
"acme@...nel.org" <acme@...nel.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"alexander.shishkin@...ux.intel.com"
<alexander.shishkin@...ux.intel.com>,
"namhyung@...nel.org" <namhyung@...nel.org>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"rfontana@...hat.com" <rfontana@...hat.com>,
"allison@...utok.net" <allison@...utok.net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] sample/hw_breakpoint: avoid sample hw_breakpoint
recursion for arm/arm64
-----Original Message-----
From: Peter Zijlstra [mailto:peterz@...radead.org]
Sent: Thursday, September 26, 2019 5:14 PM
To: wangxu (AE) <wangxu72@...wei.com>
Cc: mingo@...hat.com; acme@...nel.org; mark.rutland@....com; alexander.shishkin@...ux.intel.com; namhyung@...nel.org; gregkh@...uxfoundation.org; tglx@...utronix.de; rfontana@...hat.com; allison@...utok.net; linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sample/hw_breakpoint: avoid sample hw_breakpoint recursion for arm/arm64
On Mon, Sep 23, 2019 at 04:09:35PM +0800, wangxu wrote:
> From: Wang Xu <wangxu72@...wei.com>
>
> For x86/ppc, hw_breakpoint is triggered after the instruction is
> executed.
>
> For arm/arm64, which is triggered before the instruction executed.
> Arm/arm64 skips the instruction by using single step. But it only
> supports default overflow_handler.
Where is the recusion.. ?
For arm/arm64, hw_breakpoint is triggered before the instruction executed.
When instruction_A is triggered, watchpoint_handler() will deal with this exception, and after return instruction_A will be triggerd ...
One using samples/hw_breakpoint/data_breakpoint.c in arm/arm64 will meet this problem.
> This patch provides a chance to avoid sample hw_breakpoint recursion
> for arm/arm64 by adding 'struct perf_event_attr.bp_step'.
This patch also lacks justification for why this needs to come with ABI changes. There is also a distinct lack of comments.
I agree too. but have no better idea...
This problem is really a big pit, especially for one not familiar with implementation differences in hw breakpoint for different architectures.
> Signed-off-by: Wang Xu <wangxu72@...wei.com>
> ---
> include/linux/perf_event.h | 3 +++
> include/uapi/linux/perf_event.h | 3 ++-
> samples/hw_breakpoint/data_breakpoint.c | 1 +
> 3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 61448c1..f270eb7 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -1024,6 +1024,9 @@ extern int perf_event_output(struct perf_event *event,
> return true;
> if (unlikely(event->overflow_handler == perf_event_output_backward))
> return true;
> + /* avoid sample hw_breakpoint recursion */
> + if (unlikely(event->attr.bp_step))
> + return true;
This is just _wrong_.. it says that every event with bp_step set always is a 'default overflow handler', irrespective of what the overflow handler actually is.
Thanks for comments.
Function is_default_overflow_handler() was introduced in 1879445dfa7bbd6fe21b09c5cc72f4934798afed , which is only be called in arch/arm[64]/kernel/hw_breakpoint.c, and will never be used in other arch/ (I think).
But keeping is_default_overflow_handler() unchanged, changing ' if (is_default_overflow_handler(bp)) ' to ' if (is_default_overflow_handler(bp) || unlikely(event->attr.bp_step) ) ' will be better in arch/arm[64]/kernel/hw_breakpoint.c.
> return false;
> }
>
Powered by blists - more mailing lists