diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-11-25 23:35:42 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-26 03:29:21 -0500 |
commit | 605bfaee9078cd0b01d83402315389839ee4bb5c (patch) | |
tree | 35c3af269b37347b689b3b212fc99d4ae9f719e5 | |
parent | c6567f642e20bcc79abed030f44be5b0d6da2ded (diff) |
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>
-rw-r--r-- | arch/x86/kernel/ptrace.c | 8 | ||||
-rw-r--r-- | kernel/hw_breakpoint.c | 4 | ||||
-rw-r--r-- | kernel/trace/trace_ksym.c | 16 | ||||
-rw-r--r-- | samples/hw_breakpoint/data_breakpoint.c | 3 |
4 files changed, 7 insertions, 24 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index b25f8947ed7a..75e0cd847bd6 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -657,10 +657,7 @@ restore: | |||
657 | tsk, true); | 657 | tsk, true); |
658 | thread->ptrace_bps[i] = NULL; | 658 | thread->ptrace_bps[i] = NULL; |
659 | 659 | ||
660 | if (!bp) { /* incorrect bp, or we have a bug in bp API */ | 660 | /* Incorrect bp, or we have a bug in bp API */ |
661 | rc = -EINVAL; | ||
662 | break; | ||
663 | } | ||
664 | if (IS_ERR(bp)) { | 661 | if (IS_ERR(bp)) { |
665 | rc = PTR_ERR(bp); | 662 | rc = PTR_ERR(bp); |
666 | bp = NULL; | 663 | bp = NULL; |
@@ -729,9 +726,6 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr, | |||
729 | tsk, | 726 | tsk, |
730 | bp->attr.disabled); | 727 | bp->attr.disabled); |
731 | } | 728 | } |
732 | |||
733 | if (!bp) | ||
734 | return -EIO; | ||
735 | /* | 729 | /* |
736 | * CHECKME: the previous code returned -EIO if the addr wasn't a | 730 | * CHECKME: the previous code returned -EIO if the addr wasn't a |
737 | * valid task virtual addr. The new one will return -EINVAL in this | 731 | * valid task virtual addr. The new one will return -EINVAL in this |
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c index 06d372fc026d..dd3fb4a999d3 100644 --- a/kernel/hw_breakpoint.c +++ b/kernel/hw_breakpoint.c | |||
@@ -442,7 +442,7 @@ register_wide_hw_breakpoint(unsigned long addr, | |||
442 | 442 | ||
443 | *pevent = bp; | 443 | *pevent = bp; |
444 | 444 | ||
445 | if (IS_ERR(bp) || !bp) { | 445 | if (IS_ERR(bp)) { |
446 | err = PTR_ERR(bp); | 446 | err = PTR_ERR(bp); |
447 | goto fail; | 447 | goto fail; |
448 | } | 448 | } |
@@ -453,7 +453,7 @@ register_wide_hw_breakpoint(unsigned long addr, | |||
453 | fail: | 453 | fail: |
454 | for_each_possible_cpu(cpu) { | 454 | for_each_possible_cpu(cpu) { |
455 | pevent = per_cpu_ptr(cpu_events, cpu); | 455 | pevent = per_cpu_ptr(cpu_events, cpu); |
456 | if (IS_ERR(*pevent) || !*pevent) | 456 | if (IS_ERR(*pevent)) |
457 | break; | 457 | break; |
458 | unregister_hw_breakpoint(*pevent); | 458 | unregister_hw_breakpoint(*pevent); |
459 | } | 459 | } |
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c index 9f040e42f516..c538b15b95d6 100644 --- a/kernel/trace/trace_ksym.c +++ b/kernel/trace/trace_ksym.c | |||
@@ -200,12 +200,9 @@ int process_new_ksym_entry(char *ksymname, int op, unsigned long addr) | |||
200 | entry->ksym_hbp = register_wide_hw_breakpoint(entry->ksym_addr, | 200 | entry->ksym_hbp = register_wide_hw_breakpoint(entry->ksym_addr, |
201 | entry->len, entry->type, | 201 | entry->len, entry->type, |
202 | ksym_hbp_handler, true); | 202 | ksym_hbp_handler, true); |
203 | |||
203 | if (IS_ERR(entry->ksym_hbp)) { | 204 | if (IS_ERR(entry->ksym_hbp)) { |
204 | entry->ksym_hbp = NULL; | ||
205 | ret = PTR_ERR(entry->ksym_hbp); | 205 | ret = PTR_ERR(entry->ksym_hbp); |
206 | } | ||
207 | |||
208 | if (!entry->ksym_hbp) { | ||
209 | printk(KERN_INFO "ksym_tracer request failed. Try again" | 206 | printk(KERN_INFO "ksym_tracer request failed. Try again" |
210 | " later!!\n"); | 207 | " later!!\n"); |
211 | goto err; | 208 | goto err; |
@@ -332,21 +329,16 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
332 | if (changed) { | 329 | if (changed) { |
333 | unregister_wide_hw_breakpoint(entry->ksym_hbp); | 330 | unregister_wide_hw_breakpoint(entry->ksym_hbp); |
334 | entry->type = op; | 331 | entry->type = op; |
332 | ret = 0; | ||
335 | if (op > 0) { | 333 | if (op > 0) { |
336 | entry->ksym_hbp = | 334 | entry->ksym_hbp = |
337 | register_wide_hw_breakpoint(entry->ksym_addr, | 335 | register_wide_hw_breakpoint(entry->ksym_addr, |
338 | entry->len, entry->type, | 336 | entry->len, entry->type, |
339 | ksym_hbp_handler, true); | 337 | ksym_hbp_handler, true); |
340 | if (IS_ERR(entry->ksym_hbp)) | 338 | if (IS_ERR(entry->ksym_hbp)) |
341 | entry->ksym_hbp = NULL; | 339 | ret = PTR_ERR(entry->ksym_hbp); |
342 | 340 | else | |
343 | /* modified without problem */ | ||
344 | if (entry->ksym_hbp) { | ||
345 | ret = 0; | ||
346 | goto out; | 341 | goto out; |
347 | } | ||
348 | } else { | ||
349 | ret = 0; | ||
350 | } | 342 | } |
351 | /* Error or "symbol:---" case: drop it */ | 343 | /* Error or "symbol:---" case: drop it */ |
352 | ksym_filter_entry_count--; | 344 | ksym_filter_entry_count--; |
diff --git a/samples/hw_breakpoint/data_breakpoint.c b/samples/hw_breakpoint/data_breakpoint.c index 95063818bcf4..ee7f9fbaffbd 100644 --- a/samples/hw_breakpoint/data_breakpoint.c +++ b/samples/hw_breakpoint/data_breakpoint.c | |||
@@ -61,9 +61,6 @@ static int __init hw_break_module_init(void) | |||
61 | if (IS_ERR(sample_hbp)) { | 61 | if (IS_ERR(sample_hbp)) { |
62 | ret = PTR_ERR(sample_hbp); | 62 | ret = PTR_ERR(sample_hbp); |
63 | goto fail; | 63 | goto fail; |
64 | } else if (!sample_hbp) { | ||
65 | ret = -EINVAL; | ||
66 | goto fail; | ||
67 | } | 64 | } |
68 | 65 | ||
69 | printk(KERN_INFO "HW Breakpoint for %s write installed\n", ksym_name); | 66 | printk(KERN_INFO "HW Breakpoint for %s write installed\n", ksym_name); |