[PATCH V2 11/13] perf tools: introduce PERF_RECORD_USER_OVERHEAD

From: kan . liang
Date: Fri Dec 02 2016 - 16:21:20 EST


From: Kan Liang <kan.liang@xxxxxxxxx>

It is used to track user space perf tool profiling time cost.

Signed-off-by: Kan Liang <kan.liang@xxxxxxxxx>
---
tools/perf/util/event.c | 1 +
tools/perf/util/event.h | 5 +++++
tools/perf/util/session.c | 4 ++++
3 files changed, 10 insertions(+)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index e8736dc..764893c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -48,6 +48,7 @@ static const char *perf_event__names[] = {
[PERF_RECORD_STAT_ROUND] = "STAT_ROUND",
[PERF_RECORD_EVENT_UPDATE] = "EVENT_UPDATE",
[PERF_RECORD_TIME_CONV] = "TIME_CONV",
+ [PERF_RECORD_USER_OVERHEAD] = "USER_OVERHEAD",
};

const char *perf_event__name(unsigned int id)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index a6c98ce..6110f32 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -237,6 +237,7 @@ enum perf_user_event_type { /* above any possible kernel type */
PERF_RECORD_STAT_ROUND = 77,
PERF_RECORD_EVENT_UPDATE = 78,
PERF_RECORD_TIME_CONV = 79,
+ PERF_RECORD_USER_OVERHEAD = 80,
PERF_RECORD_HEADER_MAX
};

@@ -490,6 +491,10 @@ struct time_conv_event {
u64 time_zero;
};

+enum perf_user_overhead_event_type { /* above any possible kernel type */
+ PERF_USER_OVERHEAD_TYPE_START = 100,
+};
+
struct perf_overhead {
struct perf_event_header header;
u64 type;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 1dc32e3..7745bec 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -804,6 +804,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
[PERF_RECORD_STAT_ROUND] = perf_event__stat_round_swap,
[PERF_RECORD_EVENT_UPDATE] = perf_event__event_update_swap,
[PERF_RECORD_TIME_CONV] = perf_event__all64_swap,
+ [PERF_RECORD_USER_OVERHEAD] = perf_event__all64_swap,
[PERF_RECORD_HEADER_MAX] = NULL,
};

@@ -1387,6 +1388,9 @@ static s64 perf_session__process_user_event(struct perf_session *session,
case PERF_RECORD_TIME_CONV:
session->time_conv = event->time_conv;
return tool->time_conv(tool, event, session);
+ case PERF_RECORD_USER_OVERHEAD:
+ overhead_stats_update(tool, session->evlist, event, -1);
+ return tool->overhead(tool, event, NULL, NULL);
default:
return -EINVAL;
}
--
2.5.5