[PATCH 0/6] hw_breakpoint: Breakpoint modification fixes

From: Jiri Olsa
Date: Mon Nov 27 2017 - 11:21:45 EST


hi,
Milind Chabbi introduced new ioctl interface to change
live breakpoint [1]. It allows to change its bp_addr,
bp_len and bp_type throught new ioctl for perf breakpoint
event.

We already have a kernel interface for this via
modify_user_hw_breakpoint function. This function however
does not update the breakpoint slot counts.

So when the same functionality was exposed to user space
(Milind's change), with simple test program I could put wrong
slots count on arm server [2] and ended up with no breakpoints
available on the system. Note it's not an issue on x86, because
it shares slot single counter for both data and inst types
(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS).

This patchset contains my fixes for keeping breakpoint slots
count updated. On top of it there's Milind's change for new
_IOC_MODIFY_ATTRIBUTES ioctl interface to change a breakpoint.

As I mentioned above there're kernel users of
modify_user_hw_breakpoint function, all ptrace related
AFAICS, which could got broken.. so cc-ing Oleg ;-)

I ran gdb and strace tests suites and got same amount of
skip/fail tests as when I run them on unpatched machine,
so I assume nothing new got broken.

It's also available in here:
https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/bp

thanks,
jirka


[1] https://marc.info/?l=linux-kernel&m=151012255331565&w=2
[2] https://marc.info/?l=linux-man&m=151172469807302&w=2
---
Jiri Olsa (5):
hw_breakpoint: Pass bp_type directly as find_slot_idx argument
hw_breakpoint: Pass bp_type argument to __reserve_bp_slot|__release_bp_slot
hw_breakpoint: Add modify_bp_slot function
hw_breakpoint: Factor out __modify_user_hw_breakpoint function
perf tests: Add breakpoint accounting/modify test

Milind Chabbi (1):
perf/core: fast breakpoint modification via _IOC_MODIFY_ATTRIBUTES.

include/linux/hw_breakpoint.h | 6 ++++
include/uapi/linux/perf_event.h | 2 ++
kernel/events/core.c | 47 ++++++++++++++++++++++++++++++
kernel/events/hw_breakpoint.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++---------------------
tools/include/uapi/linux/perf_event.h | 2 ++
tools/perf/tests/Build | 1 +
tools/perf/tests/bp_account.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/tests/builtin-test.c | 4 +++
tools/perf/tests/tests.h | 1 +
9 files changed, 335 insertions(+), 33 deletions(-)
create mode 100644 tools/perf/tests/bp_account.c