[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1439889946-28986-7-git-send-email-kan.liang@intel.com>
Date: Tue, 18 Aug 2015 05:25:42 -0400
From: kan.liang@...el.com
To: acme@...nel.org
Cc: a.p.zijlstra@...llo.nl, mingo@...hat.com, jolsa@...nel.org,
namhyung@...nel.org, ak@...ux.intel.com, eranian@...gle.com,
linux-kernel@...r.kernel.org, Kan Liang <kan.liang@...el.com>
Subject: [PATCH RFC 06/10] perf,tools: New RECORD type PERF_RECORD_STAT_READ
From: Kan Liang <kan.liang@...el.com>
Introduce a new user RECORD type PERF_RECORD_STAT_READ to store the
stat event read result.
Signed-off-by: Kan Liang <kan.liang@...el.com>
---
tools/perf/util/event.c | 1 +
tools/perf/util/event.h | 10 ++++++++++
tools/perf/util/session.c | 15 +++++++++++++++
tools/perf/util/tool.h | 1 +
4 files changed, 27 insertions(+)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 7ff6127..601f4be 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -37,6 +37,7 @@ static const char *perf_event__names[] = {
[PERF_RECORD_AUXTRACE_INFO] = "AUXTRACE_INFO",
[PERF_RECORD_AUXTRACE] = "AUXTRACE",
[PERF_RECORD_AUXTRACE_ERROR] = "AUXTRACE_ERROR",
+ [PERF_RECORD_STAT_READ] = "STAT_READ",
};
const char *perf_event__name(unsigned int id)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index f729df5..f6932cf 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -226,6 +226,7 @@ enum perf_user_event_type { /* above any possible kernel type */
PERF_RECORD_AUXTRACE_INFO = 70,
PERF_RECORD_AUXTRACE = 71,
PERF_RECORD_AUXTRACE_ERROR = 72,
+ PERF_RECORD_STAT_READ = 73,
PERF_RECORD_HEADER_MAX
};
@@ -355,6 +356,14 @@ struct context_switch_event {
u32 next_prev_tid;
};
+struct stat_read_event {
+ struct perf_event_header header;
+ u64 value; /* counter value delta */
+ u32 cpu;
+ u32 pos_id; /* event position in evlist */
+ u64 time; /* time stamp */
+};
+
union perf_event {
struct perf_event_header header;
struct mmap_event mmap;
@@ -377,6 +386,7 @@ union perf_event {
struct aux_event aux;
struct itrace_start_event itrace_start;
struct context_switch_event context_switch;
+ struct stat_read_event stat_read;
};
void perf_event__print_totals(void);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 18722e7..1547970 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -337,6 +337,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
tool->context_switch = perf_event__process_switch;
if (tool->read == NULL)
tool->read = process_event_sample_stub;
+ if (tool->stat_read == NULL)
+ tool->stat_read = process_build_id_stub;
if (tool->throttle == NULL)
tool->throttle = process_event_stub;
if (tool->unthrottle == NULL)
@@ -440,6 +442,16 @@ static void perf_event__task_swap(union perf_event *event, bool sample_id_all)
swap_sample_id_all(event, &event->fork + 1);
}
+static void perf_event__stat_read_swap(union perf_event *event,
+ bool sample_id_all __maybe_unused)
+{
+
+ event->stat_read.value = bswap_64(event->stat_read.value);
+ event->stat_read.cpu = bswap_32(event->stat_read.cpu);
+ event->stat_read.pos_id = bswap_32(event->stat_read.pos_id);
+ event->stat_read.time = bswap_64(event->stat_read.time);
+}
+
static void perf_event__read_swap(union perf_event *event, bool sample_id_all)
{
event->read.pid = bswap_32(event->read.pid);
@@ -642,6 +654,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
[PERF_RECORD_EXIT] = perf_event__task_swap,
[PERF_RECORD_LOST] = perf_event__all64_swap,
[PERF_RECORD_READ] = perf_event__read_swap,
+ [PERF_RECORD_STAT_READ] = perf_event__stat_read_swap,
[PERF_RECORD_THROTTLE] = perf_event__throttle_swap,
[PERF_RECORD_UNTHROTTLE] = perf_event__throttle_swap,
[PERF_RECORD_SAMPLE] = perf_event__all64_swap,
@@ -1191,6 +1204,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,
case PERF_RECORD_AUXTRACE_ERROR:
perf_session__auxtrace_error_inc(session, event);
return tool->auxtrace_error(tool, event, session);
+ case PERF_RECORD_STAT_READ:
+ return tool->stat_read(tool, event, session);
default:
return -EINVAL;
}
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
index cab8cc2..3a002a2 100644
--- a/tools/perf/util/tool.h
+++ b/tools/perf/util/tool.h
@@ -57,6 +57,7 @@ struct perf_tool {
auxtrace_info,
auxtrace_error;
event_op3 auxtrace;
+ event_op2 stat_read;
bool ordered_events;
bool ordering_requires_timestamps;
};
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists