aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/hw_breakpoint.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-11-26 22:55:54 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-27 00:22:59 -0500
commitdd1853c3f493f6d22d9e5390b192a07b73d2ac0a (patch)
treeaf87226bcdc254ce2ab656530263e61f6552322b /kernel/hw_breakpoint.c
parent5fa10b28e57f94a90535cfeafe89dcee9f47d540 (diff)
hw-breakpoints: Use struct perf_event_attr to define kernel breakpoints
Kernel breakpoints are created using functions in which we pass breakpoint parameters as individual variables: address, length and type. Although it fits well for x86, this just does not scale across architectures that may support this api later as these may have more or different needs. Pass in a perf_event_attr structure instead because it is meant to evolve as much as possible into a generic hardware breakpoint parameter structure. Reported-by: K.Prasad <prasad@linux.vnet.ibm.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <1259294154-5197-2-git-send-regression-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/hw_breakpoint.c')
-rw-r--r--kernel/hw_breakpoint.c35
1 files changed, 4 insertions, 31 deletions
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 2a47514f12fd..cf5ee1628411 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -339,42 +339,16 @@ void unregister_hw_breakpoint(struct perf_event *bp)
339} 339}
340EXPORT_SYMBOL_GPL(unregister_hw_breakpoint); 340EXPORT_SYMBOL_GPL(unregister_hw_breakpoint);
341 341
342static struct perf_event *
343register_kernel_hw_breakpoint_cpu(unsigned long addr,
344 int len,
345 int type,
346 perf_callback_t triggered,
347 int cpu,
348 bool active)
349{
350 DEFINE_BREAKPOINT_ATTR(attr);
351
352 attr.bp_addr = addr;
353 attr.bp_len = len;
354 attr.bp_type = type;
355
356 if (!active)
357 attr.disabled = 1;
358
359 return perf_event_create_kernel_counter(&attr, cpu, -1, triggered);
360}
361
362/** 342/**
363 * register_wide_hw_breakpoint - register a wide breakpoint in the kernel 343 * register_wide_hw_breakpoint - register a wide breakpoint in the kernel
364 * @addr: is the memory address that triggers the breakpoint 344 * @attr: breakpoint attributes
365 * @len: the length of the access to the memory (1 byte, 2 bytes etc...)
366 * @type: the type of the access to the memory (read/write/exec)
367 * @triggered: callback to trigger when we hit the breakpoint 345 * @triggered: callback to trigger when we hit the breakpoint
368 * @active: should we activate it while registering it
369 * 346 *
370 * @return a set of per_cpu pointers to perf events 347 * @return a set of per_cpu pointers to perf events
371 */ 348 */
372struct perf_event ** 349struct perf_event **
373register_wide_hw_breakpoint(unsigned long addr, 350register_wide_hw_breakpoint(struct perf_event_attr *attr,
374 int len, 351 perf_callback_t triggered)
375 int type,
376 perf_callback_t triggered,
377 bool active)
378{ 352{
379 struct perf_event **cpu_events, **pevent, *bp; 353 struct perf_event **cpu_events, **pevent, *bp;
380 long err; 354 long err;
@@ -386,8 +360,7 @@ register_wide_hw_breakpoint(unsigned long addr,
386 360
387 for_each_possible_cpu(cpu) { 361 for_each_possible_cpu(cpu) {
388 pevent = per_cpu_ptr(cpu_events, cpu); 362 pevent = per_cpu_ptr(cpu_events, cpu);
389 bp = register_kernel_hw_breakpoint_cpu(addr, len, type, 363 bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered);
390 triggered, cpu, active);
391 364
392 *pevent = bp; 365 *pevent = bp;
393 366