hw-breakpoints: Simplify error handling in breakpoint creation requests

This simplifies the error handling when we create a breakpoint.
We don't need to check the NULL return value corner case anymore
since we have improved perf_event_create_kernel_counter() to
always return an error code in the failure case.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Prasad <prasad@linux.vnet.ibm.com>
LKML-Reference: <1259210142-5714-3-git-send-regression-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Frederic Weisbecker 2009-11-26 05:35:42 +01:00 committed by Ingo Molnar
parent c6567f642e
commit 605bfaee90
4 changed files with 8 additions and 25 deletions

View File

@ -657,10 +657,7 @@ restore:
tsk, true); tsk, true);
thread->ptrace_bps[i] = NULL; thread->ptrace_bps[i] = NULL;
if (!bp) { /* incorrect bp, or we have a bug in bp API */ /* Incorrect bp, or we have a bug in bp API */
rc = -EINVAL;
break;
}
if (IS_ERR(bp)) { if (IS_ERR(bp)) {
rc = PTR_ERR(bp); rc = PTR_ERR(bp);
bp = NULL; bp = NULL;
@ -729,9 +726,6 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,
tsk, tsk,
bp->attr.disabled); bp->attr.disabled);
} }
if (!bp)
return -EIO;
/* /*
* CHECKME: the previous code returned -EIO if the addr wasn't a * CHECKME: the previous code returned -EIO if the addr wasn't a
* valid task virtual addr. The new one will return -EINVAL in this * valid task virtual addr. The new one will return -EINVAL in this

View File

@ -442,7 +442,7 @@ register_wide_hw_breakpoint(unsigned long addr,
*pevent = bp; *pevent = bp;
if (IS_ERR(bp) || !bp) { if (IS_ERR(bp)) {
err = PTR_ERR(bp); err = PTR_ERR(bp);
goto fail; goto fail;
} }
@ -453,7 +453,7 @@ register_wide_hw_breakpoint(unsigned long addr,
fail: fail:
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
pevent = per_cpu_ptr(cpu_events, cpu); pevent = per_cpu_ptr(cpu_events, cpu);
if (IS_ERR(*pevent) || !*pevent) if (IS_ERR(*pevent))
break; break;
unregister_hw_breakpoint(*pevent); unregister_hw_breakpoint(*pevent);
} }

View File

@ -200,12 +200,9 @@ int process_new_ksym_entry(char *ksymname, int op, unsigned long addr)
entry->ksym_hbp = register_wide_hw_breakpoint(entry->ksym_addr, entry->ksym_hbp = register_wide_hw_breakpoint(entry->ksym_addr,
entry->len, entry->type, entry->len, entry->type,
ksym_hbp_handler, true); ksym_hbp_handler, true);
if (IS_ERR(entry->ksym_hbp)) {
entry->ksym_hbp = NULL;
ret = PTR_ERR(entry->ksym_hbp);
}
if (!entry->ksym_hbp) { if (IS_ERR(entry->ksym_hbp)) {
ret = PTR_ERR(entry->ksym_hbp);
printk(KERN_INFO "ksym_tracer request failed. Try again" printk(KERN_INFO "ksym_tracer request failed. Try again"
" later!!\n"); " later!!\n");
goto err; goto err;
@ -332,21 +329,16 @@ static ssize_t ksym_trace_filter_write(struct file *file,
if (changed) { if (changed) {
unregister_wide_hw_breakpoint(entry->ksym_hbp); unregister_wide_hw_breakpoint(entry->ksym_hbp);
entry->type = op; entry->type = op;
ret = 0;
if (op > 0) { if (op > 0) {
entry->ksym_hbp = entry->ksym_hbp =
register_wide_hw_breakpoint(entry->ksym_addr, register_wide_hw_breakpoint(entry->ksym_addr,
entry->len, entry->type, entry->len, entry->type,
ksym_hbp_handler, true); ksym_hbp_handler, true);
if (IS_ERR(entry->ksym_hbp)) if (IS_ERR(entry->ksym_hbp))
entry->ksym_hbp = NULL; ret = PTR_ERR(entry->ksym_hbp);
else
/* modified without problem */
if (entry->ksym_hbp) {
ret = 0;
goto out; goto out;
}
} else {
ret = 0;
} }
/* Error or "symbol:---" case: drop it */ /* Error or "symbol:---" case: drop it */
ksym_filter_entry_count--; ksym_filter_entry_count--;

View File

@ -61,9 +61,6 @@ static int __init hw_break_module_init(void)
if (IS_ERR(sample_hbp)) { if (IS_ERR(sample_hbp)) {
ret = PTR_ERR(sample_hbp); ret = PTR_ERR(sample_hbp);
goto fail; goto fail;
} else if (!sample_hbp) {
ret = -EINVAL;
goto fail;
} }
printk(KERN_INFO "HW Breakpoint for %s write installed\n", ksym_name); printk(KERN_INFO "HW Breakpoint for %s write installed\n", ksym_name);