[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <cb9a0db4c0dcda0f020bf6390f9d6dcb7c25b13f.1497353130.git.naveen.n.rao@linux.vnet.ibm.com>
Date: Tue, 13 Jun 2017 17:03:43 +0530
From: "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>
To: Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: [RFC PATCH v2 2/2] kernel/events: Add option to enable counting sideband events in wakeup_events
Many sideband events are interesting by themselves. When profiling only
for sideband events, it is useful to be able to control process wakeup
(wakeup_events) based on sideband events alone. Add a new option
'count_sb_events' to do the same.
Signed-off-by: Naveen N. Rao <naveen.n.rao@...ux.vnet.ibm.com>
---
include/uapi/linux/perf_event.h | 3 ++-
kernel/events/core.c | 2 +-
kernel/events/ring_buffer.c | 13 +++++++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index e5810b1d74a4..ab4dc9a02151 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -346,7 +346,8 @@ struct perf_event_attr {
write_backward : 1, /* Write ring buffer from end to beginning */
namespaces : 1, /* include namespaces data */
signal_on_wakeup : 1, /* send signal on wakeup */
- __reserved_1 : 34;
+ count_sb_events : 1, /* wakeup_events also counts sideband events */
+ __reserved_1 : 33;
union {
__u32 wakeup_events; /* wakeup every n events */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 73ad30e124e5..1d8cd3911356 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5955,7 +5955,7 @@ void perf_output_sample(struct perf_output_handle *handle,
}
}
- if (!event->attr.watermark) {
+ if (!event->attr.count_sb_events && !event->attr.watermark) {
int wakeup_events = event->attr.wakeup_events;
if (wakeup_events) {
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 4e7c728569a8..f43a6081141f 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -197,6 +197,19 @@ __perf_output_begin(struct perf_output_handle *handle,
* none of the data stores below can be lifted up by the compiler.
*/
+ if (event->attr.count_sb_events && !event->attr.watermark) {
+ int wakeup_events = event->attr.wakeup_events;
+
+ if (wakeup_events) {
+ int events = local_inc_return(&rb->events);
+
+ if (events >= wakeup_events) {
+ local_sub(wakeup_events, &rb->events);
+ local_inc(&rb->wakeup);
+ }
+ }
+ }
+
if (unlikely(head - local_read(&rb->wakeup) > rb->watermark))
local_add(rb->watermark, &rb->wakeup);
--
2.12.2
Powered by blists - more mailing lists