aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_event.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-11-25 23:35:41 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-26 03:29:21 -0500
commitc6567f642e20bcc79abed030f44be5b0d6da2ded (patch)
treeeff0dee5075d220b46019019f8e0d8e8a7bd30f3 /kernel/perf_event.c
parentd99be40aff88722ab03ee295e4f6c13a4cca9a3d (diff)
hw-breakpoints: Improve in-kernel event creation error granularity
In fail case, perf_event_create_kernel_counter() returns NULL instead of an error, which doesn't help us to inform the user about the origin of the problem from the outer most callers. Often we can just return -EINVAL, which doesn't help anyone when it's eventually about a memory allocation failure. Then, this patch makes perf_event_create_kernel_counter() always return a detailed error code. 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: Prasad <prasad@linux.vnet.ibm.com> LKML-Reference: <1259210142-5714-2-git-send-regression-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r--kernel/perf_event.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 35df94e344f2..34a1b9d7633e 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -4780,14 +4780,17 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
4780 */ 4780 */
4781 4781
4782 ctx = find_get_context(pid, cpu); 4782 ctx = find_get_context(pid, cpu);
4783 if (IS_ERR(ctx)) 4783 if (IS_ERR(ctx)) {
4784 return NULL; 4784 err = PTR_ERR(ctx);
4785 goto err_exit;
4786 }
4785 4787
4786 event = perf_event_alloc(attr, cpu, ctx, NULL, 4788 event = perf_event_alloc(attr, cpu, ctx, NULL,
4787 NULL, callback, GFP_KERNEL); 4789 NULL, callback, GFP_KERNEL);
4788 err = PTR_ERR(event); 4790 if (IS_ERR(event)) {
4789 if (IS_ERR(event)) 4791 err = PTR_ERR(event);
4790 goto err_put_context; 4792 goto err_put_context;
4793 }
4791 4794
4792 event->filp = NULL; 4795 event->filp = NULL;
4793 WARN_ON_ONCE(ctx->parent_ctx); 4796 WARN_ON_ONCE(ctx->parent_ctx);
@@ -4804,11 +4807,10 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
4804 4807
4805 return event; 4808 return event;
4806 4809
4807err_put_context: 4810 err_put_context:
4808 if (err < 0) 4811 put_ctx(ctx);
4809 put_ctx(ctx); 4812 err_exit:
4810 4813 return ERR_PTR(err);
4811 return NULL;
4812} 4814}
4813EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter); 4815EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter);
4814 4816