From: tip-bot for Frederic Weisbecker <fweisbec@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, acme@redhat.com,
hpa@zytor.com, mingo@redhat.com, peterz@infradead.org,
fweisbec@gmail.com, tglx@linutronix.de, mingo@elte.hu,
prasad@linux.vnet.ibm.com
Subject: [tip:perf/core] hw-breakpoints: Improve in-kernel event creation error granularity
Date: Thu, 26 Nov 2009 08:44:56 GMT [thread overview]
Message-ID: <tip-c6567f642e20bcc79abed030f44be5b0d6da2ded@git.kernel.org> (raw)
In-Reply-To: <1259210142-5714-2-git-send-regression-fweisbec@gmail.com>
Commit-ID: c6567f642e20bcc79abed030f44be5b0d6da2ded
Gitweb: http://git.kernel.org/tip/c6567f642e20bcc79abed030f44be5b0d6da2ded
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Thu, 26 Nov 2009 05:35:41 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:29:21 +0100
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>
---
kernel/perf_event.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 35df94e..34a1b9d 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,
*/
ctx = find_get_context(pid, cpu);
- if (IS_ERR(ctx))
- return NULL;
+ if (IS_ERR(ctx)) {
+ err = PTR_ERR(ctx);
+ goto err_exit;
+ }
event = perf_event_alloc(attr, cpu, ctx, NULL,
NULL, callback, GFP_KERNEL);
- err = PTR_ERR(event);
- if (IS_ERR(event))
+ if (IS_ERR(event)) {
+ err = PTR_ERR(event);
goto err_put_context;
+ }
event->filp = NULL;
WARN_ON_ONCE(ctx->parent_ctx);
@@ -4804,11 +4807,10 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
return event;
-err_put_context:
- if (err < 0)
- put_ctx(ctx);
-
- return NULL;
+ err_put_context:
+ put_ctx(ctx);
+ err_exit:
+ return ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter);
next prev parent reply other threads:[~2009-11-26 8:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-26 4:35 [PATCH 1/3] ksym_tracer: Fix breakpoint removal after modification Frederic Weisbecker
2009-11-26 4:35 ` [PATCH 2/3] hw-breakpoints: Improve in-kernel event creation error granularity Frederic Weisbecker
2009-11-26 8:44 ` tip-bot for Frederic Weisbecker [this message]
2009-11-26 4:35 ` [PATCH 3/3] hw-breakpoints: Simplify error handling in breakpoint creation requests Frederic Weisbecker
2009-11-26 8:45 ` [tip:perf/core] " tip-bot for Frederic Weisbecker
2009-11-26 5:04 ` [PATCH 4/3] x86/hw-breakpoints: Don't lose GE flag while disabling a breakpoint Frederic Weisbecker
2009-11-26 8:45 ` [tip:perf/core] " tip-bot for Frederic Weisbecker
2009-11-26 8:44 ` [tip:perf/core] ksym_tracer: Fix breakpoint removal after modification tip-bot for Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-c6567f642e20bcc79abed030f44be5b0d6da2ded@git.kernel.org \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=prasad@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox