Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1168467ybk; Sun, 10 May 2020 08:12:43 -0700 (PDT) X-Google-Smtp-Source: APiQypJQsih65B4yvbIJ7Ek81sH9/H9Jioc4bSM51lxUX4eTVJpFi/2ujHX0HHmij8yEb98ljiaP X-Received: by 2002:aa7:cf94:: with SMTP id z20mr9563623edx.302.1589123563761; Sun, 10 May 2020 08:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589123563; cv=none; d=google.com; s=arc-20160816; b=kH7TCSadYJU4zqRGaz27wGLvoSSvs4X4ROztkf/2y26OLH2ocgCNR9CXGgRfjOSA8u WglYXJMgh09SiXDqNX5WVAZyO2hmQdY2XydPTDLAAlAQFEo+W29VdsfnpFg9AQ97V5ju BOcWXamH8Jyk1vGPuzZzW13Mubah6UoTDm9DMA5c/l9bsIEzNzgk6NEnfFsJ3ep/QNbK 4wrxL7yj0+I3kwtNlhh9nvSZyNawFigqcYIkKxYW+gUBGj56W12X37oQAVSJk7dwNhl4 gOUHAFBuX2QA/jLzvQiC0Z77uFxqFfoSdxggXD2z22rZlRphN4p3iavqIQWWL8TdVtsC lJow== 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=R71wv0tzjUnDdB850oLrpvurQ3EzqnCxkzexdSHqy5Y=; b=pfHPTC6S0J0S0ikIvb1dBLjHRjiu1N0sC6utd27BLhJ6kpr314PhTuQhBHrc8SKTEP 6KOLWwx/5JADoxeeI1YrO+wQBGuK8wmHZe7xqSbOTTxkXV4iJy8XNNUWosvYsVNNBWw3 jsUjITT/72nUoZ5SmbwqdybmOKk8gmJyU9Vi+dez9VAdaVoBmnhZxT0fk3ySvt6hRA5+ +LJgFoHOHRDgJwD27jWApyah91d2WVHlmkTmZInrIUfpo4Z+XCx6BI5HUDCy4HbrLbuY G+SKmRQjkEnuky8FMGmWU1u3BWx82tA6U0d0EqdXtsRcsS/w/7atI8/uFTo7ZdPGnU18 skug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kNZBqkM3; 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 j2si1029597ejs.531.2020.05.10.08.12.21; Sun, 10 May 2020 08:12:43 -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=kNZBqkM3; 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 S1729216AbgEJPIa (ORCPT + 99 others); Sun, 10 May 2020 11:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgEJPI3 (ORCPT ); Sun, 10 May 2020 11:08:29 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5C5DC061A0C for ; Sun, 10 May 2020 08:08:29 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k19so2809199pll.9 for ; Sun, 10 May 2020 08:08:29 -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=R71wv0tzjUnDdB850oLrpvurQ3EzqnCxkzexdSHqy5Y=; b=kNZBqkM3tnsd4pcITGtJn6/fHNoJl01xCbpxO1vvIyBYxEeAg5UkzmT1OjT/eITnwz 7ifJKVNXhjCwzYhFPDz0oEGqgbjFUBiv87Khm8G9SZ6O5jYBPanw9RXFJCJCtRSAu/Cu Htv+akSQa8ggBedcA57rR797Z+aabJA5ESBj07PXivvDeAZEn7Ty9w0hmKhRrJ2Uaf// 8WZp5kcWlwAwohHdrSbNWM37u/lVsHb+icwVOwL8D7UPvAP0eKMgbGuj0uysb/862LhB itndB8f7QdOQrWkLAXU7eh5qBiIVOsNhXL8HlBKIZ7IXER9pULLSr8jyv/dumazK1o/n wYAA== 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=R71wv0tzjUnDdB850oLrpvurQ3EzqnCxkzexdSHqy5Y=; b=q6hwO43V5/CGWIr4CRawlfJnAptusmKbLcqxm2CuUo7RTc7BeZE7k4AcD3LAhm5J2k otaQejtMy9dWK4CJ4W5sZEZmX+dTw3S4K3uM8H79v9DL2MD03NYYUgoM/aP+HF8gVr/s QHZI0e6uCF3CeFd90Zq15O3XFcatXplRz+U8bdyi+kvOdthtCXs17PnP1gsxDFjD6i0F CyrdIKaLv4nxq7ee1hc0HmvBXwdlT+TygzfIMFPxemNlQ3XHQ+kE5AdOAUZaq/SB9KY1 I8uvn7p7y691m47YjSfV7NQeHxq3F3sNYaWaC46GWWgJPvxxj3jYI6W7kcEQESpAl0AA ynEQ== X-Gm-Message-State: AGi0PuYy++y7rYhDDCO7QFkAu9hzUuQF536LgVCplkPjuPYFv/ZyjDbv n2R/agpyCsz+gGfKLfdrLrM= X-Received: by 2002:a17:90b:70f:: with SMTP id s15mr16954860pjz.33.1589123309275; Sun, 10 May 2020 08:08:29 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id v7sm6870909pfm.146.2020.05.10.08.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 08:08:28 -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 08/19] perf ftrace: add option -l/--long-info to show more info Date: Sun, 10 May 2020 23:06:17 +0800 Message-Id: <20200510150628.16610-9-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200510150628.16610-1-changbin.du@gmail.com> References: <20200510150628.16610-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 trace. $ sudo perf ftrace -G -l 6800.190937 | 4) <...>-7683 | 2.072 us | mutex_unlock(); 6800.190941 | 4) <...>-7683 | 2.171 us | __fsnotify_parent(); 6800.190943 | 4) <...>-7683 | 1.497 us | fsnotify(); 6800.190944 | 4) <...>-7683 | 0.775 us | __sb_end_write(); 6800.190945 | 4) <...>-7683 | 0.854 us | fpregs_assert_state_consistent(); 6800.190947 | 4) <...>-7683 | | do_syscall_64() { 6800.190948 | 4) <...>-7683 | | __x64_sys_close() { 6800.190948 | 4) <...>-7683 | | __close_fd() { 6800.190948 | 4) <...>-7683 | 0.322 us | _raw_spin_lock(); 6800.190949 | 4) <...>-7683 | | filp_close() { 6800.190949 | 4) <...>-7683 | 0.320 us | dnotify_flush(); 6800.190950 | 4) <...>-7683 | 0.325 us | locks_remove_posix(); Signed-off-by: Changbin Du --- tools/perf/builtin-ftrace.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index b16600a16efa..f11f2d3431b0 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -42,6 +42,7 @@ struct perf_ftrace { bool func_stack_trace; bool nosleep_time; bool nofuncgraph_irqs; + bool long_info; }; struct filter_entry { @@ -190,6 +191,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("irq-info", "0"); } static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) @@ -371,6 +375,23 @@ static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_long_info(struct perf_ftrace *ftrace) +{ + if (!ftrace->long_info) + 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("irq-info", "1") < 0) + return -1; + + return 0; +} + static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) { char *trace_file; @@ -449,6 +470,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_long_info(ftrace) < 0) { + pr_err("failed to set tracing option funcgraph-proc/funcgraph-abstime/irq-info\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; @@ -588,6 +614,8 @@ int cmd_ftrace(int argc, const char **argv) "Measure on-CPU time only (function_graph only)"), OPT_BOOLEAN(0, "nofuncgraph-irqs", &ftrace.nofuncgraph_irqs, "Ignore functions that happen inside interrupt (function_graph only)"), + OPT_BOOLEAN('l', "long-info", &ftrace.long_info, + "Show process names, PIDs, timestamps, irq-info if available"), OPT_END() }; -- 2.25.1