From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933750AbeAXLwd (ORCPT ); Wed, 24 Jan 2018 06:52:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38860 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933712AbeAXLw3 (ORCPT ); Wed, 24 Jan 2018 06:52:29 -0500 From: Jiri Olsa To: Peter Zijlstra , Ingo Molnar Cc: lkml , Namhyung Kim , David Ahern , Andi Kleen , Alexander Shishkin , Andy Lutomirski , Arnaldo Carvalho de Melo Subject: [PATCH 18/21] perf script: Add support to display user data ID Date: Wed, 24 Jan 2018 12:51:40 +0100 Message-Id: <20180124115143.14322-19-jolsa@kernel.org> In-Reply-To: <20180124115143.14322-1-jolsa@kernel.org> References: <20180124115143.14322-1-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Assing new -F option user_data_id field argument to display column with user data id for sample. The new column displays the USER_DATA_ID or N/A if the sample does not have user data attached (PERF_RECORD_MISC_USER_DATA bit set) $ perf script -F+user_data_id ... perf 29014 ... cycles:ppp: N/A ffffffff870d013d __upda... sched-messaging 29014 ... cycles:ppp: 8 ffffffff8741d15a flex_a... new column _________/ Link: http://lkml.kernel.org/n/tip-ujjq7auvaw49slr57sarh0cu@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/builtin-script.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 7730c1d2b5d3..0d1db8c7d2d1 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -117,7 +117,7 @@ OPTIONS Comma separated list of fields to print. Options are: comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output, brstackinsn, - brstackoff, callindent, insn, insnlen, synth, phys_addr, metric, misc. + brstackoff, callindent, insn, insnlen, synth, phys_addr, metric, misc, user_data_id. Field list can be prepended with the type, trace, sw or hw, to indicate to which event type the field list applies. e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 2b8231292fe2..7baa2e5d7f9e 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -95,6 +95,7 @@ enum perf_output_field { PERF_OUTPUT_UREGS = 1U << 27, PERF_OUTPUT_METRIC = 1U << 28, PERF_OUTPUT_MISC = 1U << 29, + PERF_OUTPUT_USER_DATA_ID = 1U << 30, }; struct output_option { @@ -131,6 +132,7 @@ struct output_option { {.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR}, {.str = "metric", .field = PERF_OUTPUT_METRIC}, {.str = "misc", .field = PERF_OUTPUT_MISC}, + {.str = "user_data_id", .field = PERF_OUTPUT_USER_DATA_ID}, }; enum { @@ -1670,6 +1672,13 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(WEIGHT)) fprintf(fp, "%16" PRIu64, sample->weight); + if (PRINT_FIELD(USER_DATA_ID)) { + if (sample->misc & PERF_RECORD_MISC_USER_DATA) + fprintf(fp, "%16" PRIu64, sample->user_data_id); + else + fprintf(fp, "%16s", "N/A"); + } + if (PRINT_FIELD(IP)) { struct callchain_cursor *cursor = NULL; -- 2.13.6