Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2029532ybh; Fri, 17 Jul 2020 07:39:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynqTOx0/DdSrundSiQGXvn4YnoGSFRIdtPbG0tqTY60zuKfftu6K2jFfx5yXQCEpBcV63G X-Received: by 2002:a17:906:1491:: with SMTP id x17mr9176476ejc.416.1594996777152; Fri, 17 Jul 2020 07:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594996777; cv=none; d=google.com; s=arc-20160816; b=Tzu39jAYpPRsJ1b8TSLrk+a6s0183X6OVhIp90PJuqAO5WnsUqwqFGefoPUJLwXQNR tdp6FgnynwbRaa2fCgoL39v+APoXOt7rNWhBPizZdkuFPj1TJY+83LKPjr8S2l2JN7Zw AY/quKhLrvUga6G2oAiQHtHI47lbPV3BeRCHhvgVduUnx7piFmPo4FBFMBdh2Sy4+97+ niphguatTvhasF6BSRESd2MOkT+oeQBV+0g1tCO9bwESnQaihZJXiUchGeJhFTGt3YyA JE4i9g84BhK2ikeOiAZxqgq7wez6oIHu87/Q9G2H4yQGQZTLWSsAFV8ICS410U05j7TM 8dSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UFP+x3j4+5MaBu1RqkqiwZg2PpWg/cFgrQKA41+DGK0=; b=LOjRWbNbu/M/rCKo9H3exAU9IwEKRieGse2kfZ9DFnlZ/WpjyYTdl7dzNg4daWzICD 6dkJQ5ewbGcukTDuu+HrJrCt4w2licMgO32Silx4Nk9VIdnBm3/c68+g6XXZzvfrAiIY MgL7+L8GBqoTZkL8d3CZUKUDh7jMY5ZoAP1JF+CzSNa3Io/YLg0kLtJTTt9knh3ETChj xDm8CW/CkwAVdLOmzMbuzpwKl9rnnqp5Z92B15Tt2ZYW9KBxWo+8028R/HZwDihjB/0i in0RqtSch8NVULJE9/gQecZthkzjT0eNiXUpBA1P/GFzoX4L4G/zscqZLjZcibJFMpem 4zew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XeIx9NbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq6si5160718ejb.108.2020.07.17.07.39.14; Fri, 17 Jul 2020 07:39:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XeIx9NbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727853AbgGQOiV (ORCPT + 99 others); Fri, 17 Jul 2020 10:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgGQOiU (ORCPT ); Fri, 17 Jul 2020 10:38:20 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE107C0619D2 for ; Fri, 17 Jul 2020 07:38:20 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id u185so5491222pfu.1 for ; Fri, 17 Jul 2020 07:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UFP+x3j4+5MaBu1RqkqiwZg2PpWg/cFgrQKA41+DGK0=; b=XeIx9NbO9jcYgTU5r6EJBq2L3JfYGcdydHzE1GB8bgDURUF/rqIjU2RsdktIoFGpbn 8CqTWuynKJyHfW7k/ZpIxT61jugBj3H0Xf3jC+zryAJPYiIPdgbu3y5GFDAfUOPS3xD4 KNjbpqUq94k+h0+0WweMwOjY7K5rB4foA5JGN/VjbV3wWgMCz8LQ65ZiO2KmGRfkwYfH uspcRh7+2ML56bGAkmS9d5QsEOStMGYP3BF1WYA+0SPqC93Jv7QxZcLax9YRKY9yXNW4 811bBXugkZpekrnaPM88aUsRTgNqfxRu9vrovuKoO/J89bI5GXbJGdF7XZ7NQAV2mulD iYFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UFP+x3j4+5MaBu1RqkqiwZg2PpWg/cFgrQKA41+DGK0=; b=QiClO7jX+V4RU0EFO5gvLicg2U6PZceQ2a6r3brkZtYSNBy6at2lexm3chdwsbuqKZ xsVT8LGcQQ51fHfWG9QsZ79G0NBKaXm+/hb5LNvu9Pq/0Nx5l8WbQduZSB2kZf9TUzAL uLMjBDBJRTqmBrVqNPnZG6W7JxRkbDaockJ12jnVph2l4N59DyrM+SS0mTJDtuIBpefq YQHt/icJt4Jn8fKmd43W5nzeAqHHasrdT4tOeOa4BBGfcFIL2t0yln6SP3sLzpBcIYJS SsH9hENe2OxqTw+WLVce1sA7mEivWfv3uWAsYdS+pjzSkAXneecLRLFiNGmfzeeAJ4oQ ClgA== X-Gm-Message-State: AOAM531UOMGkcXjt52rz2J1pa67HVyZGn6iR2uTnvRwe0KjbmYI18wAn uh+aToHsP9voZBEsFCKiHD0= X-Received: by 2002:a63:7c56:: with SMTP id l22mr8688320pgn.127.1594996700308; Fri, 17 Jul 2020 07:38:20 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id a68sm3214689pje.35.2020.07.17.07.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 07:38:19 -0700 (PDT) From: Changbin Du To: Jiri Olsa , Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Namhyung Kim , Steven Rostedt , linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH v6 12/17] perf ftrace: add option 'verbose' to show more info for graph tracer Date: Fri, 17 Jul 2020 22:36:23 +0800 Message-Id: <20200717143628.47721-13-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200717143628.47721-1-changbin.du@gmail.com> References: <20200717143628.47721-1-changbin.du@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sometimes we want ftrace display more and longer information about the trace. $ sudo perf ftrace -G '*' 2) 0.979 us | mutex_unlock(); 2) 1.540 us | __fsnotify_parent(); 2) 0.433 us | fsnotify(); $ sudo perf ftrace -G '*' --graph-opts verbose 14160.770883 | 0) <...>-47814 | .... | 1.289 us | mutex_unlock(); 14160.770886 | 0) <...>-47814 | .... | 1.624 us | __fsnotify_parent(); 14160.770887 | 0) <...>-47814 | .... | 0.636 us | fsnotify(); 14160.770888 | 0) <...>-47814 | .... | 0.328 us | __sb_end_write(); 14160.770888 | 0) <...>-47814 | d... | 0.430 us | fpregs_assert_state_consistent(); 14160.770889 | 0) <...>-47814 | d... | | do_syscall_64() { 14160.770889 | 0) <...>-47814 | .... | | __x64_sys_close() { Signed-off-by: Changbin Du --- tools/perf/Documentation/perf-ftrace.txt | 1 + tools/perf/builtin-ftrace.c | 29 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt index 3ab1fe040994..319ec6375228 100644 --- a/tools/perf/Documentation/perf-ftrace.txt +++ b/tools/perf/Documentation/perf-ftrace.txt @@ -103,6 +103,7 @@ OPTIONS List of options allowed to set: nosleep-time - Measure on-CPU time only for function_graph tracer. noirqs - Ignore functions that happen inside interrupt. + verbose - Show process names, PIDs, timestamps, etc. SEE ALSO -------- diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 95d87c5966ad..0d893d97691d 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -45,6 +45,7 @@ struct perf_ftrace { int func_irq_info; int graph_nosleep_time; int graph_noirqs; + int graph_verbose; }; struct filter_entry { @@ -208,6 +209,9 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused) write_tracing_option_file("func_stack_trace", "0"); write_tracing_option_file("sleep-time", "1"); write_tracing_option_file("funcgraph-irqs", "1"); + write_tracing_option_file("funcgraph-proc", "0"); + write_tracing_option_file("funcgraph-abstime", "0"); + write_tracing_option_file("latency-format", "0"); write_tracing_option_file("irq-info", "0"); } @@ -423,6 +427,23 @@ static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) +{ + if (!ftrace->graph_verbose) + return 0; + + if (write_tracing_option_file("funcgraph-proc", "1") < 0) + return -1; + + if (write_tracing_option_file("funcgraph-abstime", "1") < 0) + return -1; + + if (write_tracing_option_file("latency-format", "1") < 0) + return -1; + + return 0; +} + static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) { char *trace_file; @@ -517,6 +538,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_funcgraph_verbose(ftrace) < 0) { + pr_err("failed to set tracing option funcgraph-proc/funcgraph-abstime\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; @@ -699,6 +725,7 @@ static int parse_graph_tracer_opts(const struct option *opt, struct sublevel_option graph_tracer_opts[] = { { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time }, { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs }, + { .name = "verbose", .value_ptr = &ftrace->graph_verbose }, { .name = NULL, } }; @@ -753,7 +780,7 @@ int cmd_ftrace(int argc, const char **argv) OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth, "Max depth for function graph tracer"), OPT_CALLBACK(0, "graph-opts", &ftrace, "options", - "graph tracer options, available options: nosleep-time,noirqs", + "graph tracer options, available options: nosleep-time,noirqs,verbose", parse_graph_tracer_opts), OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", "size of per cpu buffer", parse_buffer_size), -- 2.25.1