[PATCH 10/14] perf tools: introduce PERF_RECORD_USER_OVERHEAD

From: kan . liang
Date: Wed Nov 23 2016 - 12:46:25 EST


From: Kan Liang <kan.liang@xxxxxxxxx>

User space perf tool also bring overhead. Introduce
PERF_RECORD_USER_OVERHEAD to track the overhead information.

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

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index ca98c4c..6cd43c9 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 3357529..1ef1a9d 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
};

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e3aa9d7..27a5c8a 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,
};

@@ -1382,6 +1383,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);
+ return tool->overhead(tool, event, NULL, NULL);
default:
return -EINVAL;
}
--
2.5.5