Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751423AbdIOLZu (ORCPT ); Fri, 15 Sep 2017 07:25:50 -0400 Received: from mga09.intel.com ([134.134.136.24]:61318 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbdIOLZt (ORCPT ); Fri, 15 Sep 2017 07:25:49 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="151689895" From: changbin.du@intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com Cc: linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH] perf ftrace: Add -O option to set trace option Date: Fri, 15 Sep 2017 19:19:31 +0800 Message-Id: <1505474371-13292-1-git-send-email-changbin.du@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2285 Lines: 73 From: Changbin Du There are some trace options to control what gets printed in the trace output or manipulate the tracers. This patch add a commandline option to set it. Example: perf ftrace -t function -O noprint-parent --trace-funcs "__kmalloc" -a Xorg-1874 [002] .... 4107.182911: __kmalloc Xorg-1874 [002] .... 4107.182920: __kmalloc perf ftrace -t function -O print-parent --trace-funcs "__kmalloc" -a Xorg-1874 [000] .... 3924.917243: __kmalloc <-drm_atomic_state_init Xorg-1874 [000] .... 3924.917251: __kmalloc <-drm_atomic_state_init Signed-off-by: Changbin Du --- tools/perf/builtin-ftrace.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 25a42ac..8b473e2 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -36,6 +36,7 @@ struct perf_ftrace { struct list_head graph_funcs; struct list_head nograph_funcs; int graph_depth; + const char *trace_option; }; struct filter_entry { @@ -261,6 +262,17 @@ static int set_tracing_depth(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_option(struct perf_ftrace *ftrace) +{ + if (ftrace->trace_option == NULL) + return 0; + + if (write_tracing_file("trace_options", ftrace->trace_option) < 0) + return -1; + + return 0; +} + static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) { char *trace_file; @@ -313,6 +325,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_option(ftrace) < 0) { + pr_err("failed to set trace option\n"); + goto out_reset; + } + if (write_tracing_file("current_tracer", ftrace->tracer) < 0) { pr_err("failed to set current_tracer to %s\n", ftrace->tracer); goto out_reset; @@ -456,6 +473,8 @@ int cmd_ftrace(int argc, const char **argv) "Set nograph filter on given functions", parse_filter_func), OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth, "Max depth for function graph tracer"), + OPT_STRING('O', "trace-option", &ftrace.trace_option, "option", + "Set a trace option"), OPT_END() }; -- 2.7.4