[PATCH 19/21] perf script: Display USER_DATA misc char for sample

Jiri Olsa
2018-01-24T11:53:27Z

Adding support to display sample USER_DATA misc misc char
for sample event:

# perf script -F +misc ...
sched-messaging 1414 KD 28690.636582: 4590 cycles ...
new misc field ______/

Assigning the letter 'D' for PERF_RECORD_MISC_USER_DATA.

Link: http://lkml.kernel.org/n/tip-8wczn7vnmgd98cxpemq9g832@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf-script.txt | 1 +
tools/perf/builtin-script.c | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 0d1db8c7d2d1..d1425f067ad5 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -236,6 +236,7 @@ OPTIONS
PERF_RECORD_MISC_MMAP_DATA* M
PERF_RECORD_MISC_COMM_EXEC E
PERF_RECORD_MISC_SWITCH_OUT S
+ PERF_RECORD_MISC_USER_DATA D

$ perf script -F +misc ...
sched-messaging 1414 K 28690.636582: 4590 cycles ...
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 7baa2e5d7f9e..45473c2d6e25 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -648,6 +648,10 @@ static int perf_sample__fprintf_start(struct perf_sample *sample,
ret += fprintf(fp, "g");

switch (type) {
+ case PERF_RECORD_SAMPLE:
+ if (has(USER_DATA))
+ ret += fprintf(fp, "D");
+ break;
case PERF_RECORD_MMAP:
case PERF_RECORD_MMAP2:
if (has(MMAP_DATA))
--
2.13.6