Skip to content

Commit f67b150

Browse files
torvaldsIngo Molnar
authored andcommitted
perf/hwbp: Simplify the perf-hwbp code, fix documentation
Annoyingly, modify_user_hw_breakpoint() unnecessarily complicates the modification of a breakpoint - simplify it and remove the pointless local variables. Also update the stale Docbook while at it. Signed-off-by: Linus Torvalds <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Cc: <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Vince Weaver <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 71eb9ee commit f67b150

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

kernel/events/hw_breakpoint.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -427,16 +427,9 @@ EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
427427
* modify_user_hw_breakpoint - modify a user-space hardware breakpoint
428428
* @bp: the breakpoint structure to modify
429429
* @attr: new breakpoint attributes
430-
* @triggered: callback to trigger when we hit the breakpoint
431-
* @tsk: pointer to 'task_struct' of the process to which the address belongs
432430
*/
433431
int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr)
434432
{
435-
u64 old_addr = bp->attr.bp_addr;
436-
u64 old_len = bp->attr.bp_len;
437-
int old_type = bp->attr.bp_type;
438-
int err = 0;
439-
440433
/*
441434
* modify_user_hw_breakpoint can be invoked with IRQs disabled and hence it
442435
* will not be possible to raise IPIs that invoke __perf_event_disable.
@@ -451,27 +444,18 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
451444
bp->attr.bp_addr = attr->bp_addr;
452445
bp->attr.bp_type = attr->bp_type;
453446
bp->attr.bp_len = attr->bp_len;
447+
bp->attr.disabled = 1;
454448

455-
if (attr->disabled)
456-
goto end;
457-
458-
err = validate_hw_breakpoint(bp);
459-
if (!err)
460-
perf_event_enable(bp);
449+
if (!attr->disabled) {
450+
int err = validate_hw_breakpoint(bp);
461451

462-
if (err) {
463-
bp->attr.bp_addr = old_addr;
464-
bp->attr.bp_type = old_type;
465-
bp->attr.bp_len = old_len;
466-
if (!bp->attr.disabled)
467-
perf_event_enable(bp);
452+
if (err)
453+
return err;
468454

469-
return err;
455+
perf_event_enable(bp);
456+
bp->attr.disabled = 0;
470457
}
471458

472-
end:
473-
bp->attr.disabled = attr->disabled;
474-
475459
return 0;
476460
}
477461
EXPORT_SYMBOL_GPL(modify_user_hw_breakpoint);

0 commit comments

Comments
 (0)