* [PATCH 0/2] Fix some arm64 perf issues
@ 2020-02-03 22:26 Bhupesh Sharma
2020-02-03 22:26 ` [PATCH 1/2] hw_breakpoint: Remove unused '__register_perf_hw_breakpoint' declaration Bhupesh Sharma
2020-02-03 22:26 ` [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints Bhupesh Sharma
0 siblings, 2 replies; 5+ messages in thread
From: Bhupesh Sharma @ 2020-02-03 22:26 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, bhsharma,
linux-kernel, bhupesh.linux, Will Deacon
This patchset tries to address some arm64 perf issues.
While the 1st patch is a generic one and just removes a dead/left-over
declaration:
[PATCH 1/2]: hw_breakpoint: Remove unused '__register_perf_hw_breakpoint' declaration
the 2nd patch addresses 'perf stat -e' like use-cases on arm64 which
allow per-task address execution h/w breakpoints:
[PATCH 2/2]: perf/arm64: Allow per-task kernel breakpoints
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Bhupesh Sharma (2):
hw_breakpoint: Remove unused '__register_perf_hw_breakpoint'
declaration
perf/arm64: Allow per-task kernel breakpoints
arch/arm64/kernel/hw_breakpoint.c | 7 -------
include/linux/hw_breakpoint.h | 3 ---
2 files changed, 10 deletions(-)
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/2] hw_breakpoint: Remove unused '__register_perf_hw_breakpoint' declaration 2020-02-03 22:26 [PATCH 0/2] Fix some arm64 perf issues Bhupesh Sharma @ 2020-02-03 22:26 ` Bhupesh Sharma 2020-02-03 22:26 ` [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints Bhupesh Sharma 1 sibling, 0 replies; 5+ messages in thread From: Bhupesh Sharma @ 2020-02-03 22:26 UTC (permalink / raw) To: linux-arm-kernel Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, bhsharma, linux-kernel, bhupesh.linux, Will Deacon commit b326e9560a28 ("hw-breakpoints: Use overflow handler instead of the event callback") removed '__register_perf_hw_breakpoint' function usage and replaced it with 'register_perf_hw_breakpoint' function. Remove the left-over unused '__register_perf_hw_breakpoint' declaration from 'hw_breakpoint.h' as well. Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com> --- include/linux/hw_breakpoint.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index 6058c3844a76..fe1302da8e0f 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -72,7 +72,6 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, void *context); extern int register_perf_hw_breakpoint(struct perf_event *bp); -extern int __register_perf_hw_breakpoint(struct perf_event *bp); extern void unregister_hw_breakpoint(struct perf_event *bp); extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events); @@ -115,8 +114,6 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, void *context) { return NULL; } static inline int register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } -static inline int -__register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } static inline void unregister_hw_breakpoint(struct perf_event *bp) { } static inline void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { } -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints 2020-02-03 22:26 [PATCH 0/2] Fix some arm64 perf issues Bhupesh Sharma 2020-02-03 22:26 ` [PATCH 1/2] hw_breakpoint: Remove unused '__register_perf_hw_breakpoint' declaration Bhupesh Sharma @ 2020-02-03 22:26 ` Bhupesh Sharma 2020-02-06 10:38 ` Will Deacon 1 sibling, 1 reply; 5+ messages in thread From: Bhupesh Sharma @ 2020-02-03 22:26 UTC (permalink / raw) To: linux-arm-kernel Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, bhsharma, linux-kernel, bhupesh.linux, Will Deacon commit 478fcb2cdb23 ("arm64: Debugging support") disallowed per-task kernel breakpoints on arm64 since these would have potentially complicated the stepping code. However, we now have several use-cases (for e.g. perf) which require per-task address execution h/w breakpoint to be exercised/set on arm64: For e.g. we can set address execution h/w breakpoints, using the format prescribed by 'perf-list' command: mem:<addr>[/len][:access] [Hardware breakpoint] Without this patch, currently 'perf stat -e' reports that per-task address execution h/w breakpoints are 'not supported' on arm64. See below: $ TEST_FUNC="vfs_read" $ ADDR=0x`cat /proc/kallsyms | grep -P "\\s$TEST_FUNC\$" | cut -f1 -d' '` $ perf stat -e mem:$ADDR:x -x';' -- cat /proc/cpuinfo > /dev/null <not supported>;;mem:0xffff00001031dd68:x;0;100.00;; After this patch, this use-case can be supported: $ TEST_FUNC="vfs_read" $ ADDR=0x`cat /proc/kallsyms | grep -P "\\s$TEST_FUNC\$" | cut -f1 -d' '` $ perf stat -e mem:$ADDR:x -x';' -- cat /proc/cpuinfo > /dev/null 5;;mem:0xfffffe0010361d20:x;912200;100.00;; Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com> --- arch/arm64/kernel/hw_breakpoint.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 0b727edf4104..c28f04e02845 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -562,13 +562,6 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, hw->address &= ~alignment_mask; hw->ctrl.len <<= offset; - /* - * Disallow per-task kernel breakpoints since these would - * complicate the stepping code. - */ - if (hw->ctrl.privilege == AARCH64_BREAKPOINT_EL1 && bp->hw.target) - return -EINVAL; - return 0; } -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints 2020-02-03 22:26 ` [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints Bhupesh Sharma @ 2020-02-06 10:38 ` Will Deacon 2020-02-07 7:22 ` Bhupesh Sharma 0 siblings, 1 reply; 5+ messages in thread From: Will Deacon @ 2020-02-06 10:38 UTC (permalink / raw) To: Bhupesh Sharma Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, linux-kernel, bhupesh.linux, linux-arm-kernel On Tue, Feb 04, 2020 at 03:56:24AM +0530, Bhupesh Sharma wrote: > commit 478fcb2cdb23 ("arm64: Debugging support") disallowed per-task > kernel breakpoints on arm64 since these would have potentially > complicated the stepping code. > > However, we now have several use-cases (for e.g. perf) which require > per-task address execution h/w breakpoint to be exercised/set on arm64: To be honest, the perf interface to hw_breakpoint is an abomination and I think we should remove it entirely for arm64. It's flakey, complicated, adds code to context-switch and reduces the capabilities available to ptrace. > For e.g. we can set address execution h/w breakpoints, using the > format prescribed by 'perf-list' command: > mem:<addr>[/len][:access] [Hardware breakpoint] > > Without this patch, currently 'perf stat -e' reports that per-task > address execution h/w breakpoints are 'not supported' on arm64. See > below: > > $ TEST_FUNC="vfs_read" > $ ADDR=0x`cat /proc/kallsyms | grep -P "\\s$TEST_FUNC\$" | cut -f1 -d' '` > $ perf stat -e mem:$ADDR:x -x';' -- cat /proc/cpuinfo > /dev/null > > <not supported>;;mem:0xffff00001031dd68:x;0;100.00;; > > After this patch, this use-case can be supported: > > $ TEST_FUNC="vfs_read" > $ ADDR=0x`cat /proc/kallsyms | grep -P "\\s$TEST_FUNC\$" | cut -f1 -d' '` > $ perf stat -e mem:$ADDR:x -x';' -- cat /proc/cpuinfo > /dev/null > > 5;;mem:0xfffffe0010361d20:x;912200;100.00;; > > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: Will Deacon <will@kernel.org> > Cc: Catalin Marinas <catalin.marinas@arm.com> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> > Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com> > --- > arch/arm64/kernel/hw_breakpoint.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c > index 0b727edf4104..c28f04e02845 100644 > --- a/arch/arm64/kernel/hw_breakpoint.c > +++ b/arch/arm64/kernel/hw_breakpoint.c > @@ -562,13 +562,6 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, > hw->address &= ~alignment_mask; > hw->ctrl.len <<= offset; > > - /* > - * Disallow per-task kernel breakpoints since these would > - * complicate the stepping code. > - */ > - if (hw->ctrl.privilege == AARCH64_BREAKPOINT_EL1 && bp->hw.target) > - return -EINVAL; > - Sorry, but this is broken; the check is there for a reason, not just for fun! Look at how the step handler toggles the bp registers. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints 2020-02-06 10:38 ` Will Deacon @ 2020-02-07 7:22 ` Bhupesh Sharma 0 siblings, 0 replies; 5+ messages in thread From: Bhupesh Sharma @ 2020-02-07 7:22 UTC (permalink / raw) To: Will Deacon Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, Linux Kernel Mailing List, Bhupesh SHARMA, linux-arm-kernel Hi Will, Thanks for your inputs. On Thu, Feb 6, 2020 at 4:09 PM Will Deacon <will@kernel.org> wrote: > > On Tue, Feb 04, 2020 at 03:56:24AM +0530, Bhupesh Sharma wrote: > > commit 478fcb2cdb23 ("arm64: Debugging support") disallowed per-task > > kernel breakpoints on arm64 since these would have potentially > > complicated the stepping code. > > > > However, we now have several use-cases (for e.g. perf) which require > > per-task address execution h/w breakpoint to be exercised/set on arm64: > > To be honest, the perf interface to hw_breakpoint is an abomination and > I think we should remove it entirely for arm64. It's flakey, complicated, > adds code to context-switch and reduces the capabilities available to > ptrace. Sure, I agree. > > For e.g. we can set address execution h/w breakpoints, using the > > format prescribed by 'perf-list' command: > > mem:<addr>[/len][:access] [Hardware breakpoint] > > > > Without this patch, currently 'perf stat -e' reports that per-task > > address execution h/w breakpoints are 'not supported' on arm64. See > > below: > > > > $ TEST_FUNC="vfs_read" > > $ ADDR=0x`cat /proc/kallsyms | grep -P "\\s$TEST_FUNC\$" | cut -f1 -d' '` > > $ perf stat -e mem:$ADDR:x -x';' -- cat /proc/cpuinfo > /dev/null > > > > <not supported>;;mem:0xffff00001031dd68:x;0;100.00;; > > > > After this patch, this use-case can be supported: > > > > $ TEST_FUNC="vfs_read" > > $ ADDR=0x`cat /proc/kallsyms | grep -P "\\s$TEST_FUNC\$" | cut -f1 -d' '` > > $ perf stat -e mem:$ADDR:x -x';' -- cat /proc/cpuinfo > /dev/null > > > > 5;;mem:0xfffffe0010361d20:x;912200;100.00;; > > > > Cc: Mark Rutland <mark.rutland@arm.com> > > Cc: Will Deacon <will@kernel.org> > > Cc: Catalin Marinas <catalin.marinas@arm.com> > > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> > > Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com> > > --- > > arch/arm64/kernel/hw_breakpoint.c | 7 ------- > > 1 file changed, 7 deletions(-) > > > > diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c > > index 0b727edf4104..c28f04e02845 100644 > > --- a/arch/arm64/kernel/hw_breakpoint.c > > +++ b/arch/arm64/kernel/hw_breakpoint.c > > @@ -562,13 +562,6 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, > > hw->address &= ~alignment_mask; > > hw->ctrl.len <<= offset; > > > > - /* > > - * Disallow per-task kernel breakpoints since these would > > - * complicate the stepping code. > > - */ > > - if (hw->ctrl.privilege == AARCH64_BREAKPOINT_EL1 && bp->hw.target) > > - return -EINVAL; > > - > > Sorry, but this is broken; the check is there for a reason, not just for > fun! > > Look at how the step handler toggles the bp registers. Not sure I follow. Can you please give me some pointers. All the perf tests I have from test-suite run fine with this chunk removed. Thanks for your help. Regards, Bhupesh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-07 7:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-02-03 22:26 [PATCH 0/2] Fix some arm64 perf issues Bhupesh Sharma 2020-02-03 22:26 ` [PATCH 1/2] hw_breakpoint: Remove unused '__register_perf_hw_breakpoint' declaration Bhupesh Sharma 2020-02-03 22:26 ` [PATCH 2/2] perf/arm64: Allow per-task kernel breakpoints Bhupesh Sharma 2020-02-06 10:38 ` Will Deacon 2020-02-07 7:22 ` Bhupesh Sharma
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).