From: Namhyung Kim <namhyung@gmail.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] perf: Annotate lock context on perf_output_begin/end()
Date: Mon, 27 Sep 2010 19:39:54 +0900 [thread overview]
Message-ID: <1285583997-1262-3-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <1285583997-1262-1-git-send-email-namhyung@gmail.com>
perf_output_begin() conditionally grabs RCU read lock in case of
returning 0. Rename and wrap it using __cond_lock() to annotate
this. Although perf_output_begin() returns 0 or error code, IMHO
converting it to boolean will not be a problem since there is no
user takes account of the actual code. Annotate perf_output_end()
also.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
include/linux/perf_event.h | 6 +++++-
kernel/perf_event.c | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 716f99b..167dd3d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1009,9 +1009,13 @@ extern void perf_bp_event(struct perf_event *event, void *data);
#define perf_instruction_pointer(regs) instruction_pointer(regs)
#endif
-extern int perf_output_begin(struct perf_output_handle *handle,
+extern int __perf_output_begin(struct perf_output_handle *handle,
struct perf_event *event, unsigned int size,
int nmi, int sample);
+
+#define perf_output_begin(h, e, s, n, sp) \
+ (!__cond_lock(RCU, !__perf_output_begin(h, e, s, n, sp)))
+
extern void perf_output_end(struct perf_output_handle *handle);
extern void perf_output_copy(struct perf_output_handle *handle,
const void *buf, unsigned int len);
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index c058a42..bd5d750 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -3106,7 +3106,7 @@ __always_inline void perf_output_copy(struct perf_output_handle *handle,
} while (len);
}
-int perf_output_begin(struct perf_output_handle *handle,
+int __perf_output_begin(struct perf_output_handle *handle,
struct perf_event *event, unsigned int size,
int nmi, int sample)
{
@@ -3190,6 +3190,7 @@ out:
}
void perf_output_end(struct perf_output_handle *handle)
+ __releases(RCU)
{
struct perf_event *event = handle->event;
struct perf_buffer *buffer = handle->buffer;
--
1.7.2.2
next prev parent reply other threads:[~2010-09-27 10:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-27 10:39 [PATCH 0/5] perf cleanups Namhyung Kim
2010-09-27 10:39 ` [PATCH 1/5] perf: Wrap perf_lock_task_context using __cond_lock() Namhyung Kim
2010-09-27 13:46 ` Frederic Weisbecker
2010-09-27 14:40 ` Namhyung Kim
2010-09-30 11:38 ` Peter Zijlstra
2010-09-27 10:39 ` Namhyung Kim [this message]
2010-09-27 10:39 ` [PATCH 3/5] perf: Remove 'extern' on hw_perf_event_init() definition Namhyung Kim
2010-09-27 10:39 ` [PATCH 4/5] perf: Make perf_event_wakeup() static Namhyung Kim
2010-09-27 10:39 ` [PATCH 5/5] perf: Declare hw_perf_{dis,en}able() in perf_event.h Namhyung Kim
2010-09-30 11:22 ` Peter Zijlstra
2010-09-30 15:05 ` Namhyung Kim
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=1285583997-1262-3-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/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
Powered by JetHome