Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1168919ybk; Sun, 10 May 2020 08:13:32 -0700 (PDT) X-Google-Smtp-Source: APiQypIkU7QJq9qR1t8OjC7mO9aILcOx9sEaPxugNwOtGvky8RW2WXCqDKv5pctk/2ohImWRPnoR X-Received: by 2002:aa7:d718:: with SMTP id t24mr10247062edq.29.1589123612562; Sun, 10 May 2020 08:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589123612; cv=none; d=google.com; s=arc-20160816; b=FuVdoG11dmFrDjAgDmfJBFz9vmQ4UF6AIuQ0oNZE5bAUSbCL7Ch7jVS45Ep/hqBFVN SKroPjfNu3fLH5mtJZgNznnV1nbDyBnzBR4+DFSlbxX/WXVlpzmrXD1MUvgdWav1w70I ttk7xStVH1PmgJ65/rl/Og7N5DOtqNf3GIm6pmAhgiXr8+f0kYPZtyaaA23KKmc+VTEw MyyAxKMVlHeInfoLjSFli3WKw3B5VI0rXAfXTA0jEVTIrwabZYBJQYz1KrRWN+kY16+R I9h9QlIeStN0krDAL8MIJBDkSFclhiPbBw9dDdlAHwFcY4CJwxTduEMLNv1cvPGKAOjq tvAw== 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=UwWrCXO3EiMCCi/VR56OQtOH8VL67AQVe2Td23eGNBo=; b=uDoALYD+dRf7E37EoBVpaX4Z0N+mw0bdy/31OV//N1ZDu+AuSFSyIc37z84XBP7+eK LBHE9uIYFZfMGL2ZSGt2DQwSrJGM9KC2Sn6BpcPOZmnM60HTuU6AZZXO9x6Vwux/tejx hVgpCubgDhwleE+eZ1LydBUYuoaV/BOQd/OKaSQHqySlvOtImqXBPEChEu+yTJ3u0Hg6 EH89XcVF0dt9BJSOnqvSzzzq1ExP1JcjOfSkcO1KytFIaByW5EeKyPTLuUkDGYNtEvtt 5OD89OoWiHD8W1IHWg6iGNsUgnHeIYIIOtuUpS5Dd68CgD2njwD5FybgjhbHclE/KmyA EWgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XJBHmSbm; 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 4si4911686ejy.347.2020.05.10.08.13.09; Sun, 10 May 2020 08:13:32 -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=XJBHmSbm; 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 S1729297AbgEJPKf (ORCPT + 99 others); Sun, 10 May 2020 11:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728849AbgEJPKf (ORCPT ); Sun, 10 May 2020 11:10:35 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AAFAC061A0C for ; Sun, 10 May 2020 08:10:35 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t16so2811308plo.7 for ; Sun, 10 May 2020 08:10:35 -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=UwWrCXO3EiMCCi/VR56OQtOH8VL67AQVe2Td23eGNBo=; b=XJBHmSbmFs4/mmJZsFtukL3kXcrxNpRmnKfwTujxxb8wey3PABRkXjNovoopXXO15u //e2mT7jWi5e2rJh2ZUOKhrwYPjTUnE5mDStAqgUaMGOzKQ+49N1lUNFVZP2zkIDjdxH JUGGzGN2stZbpteYGlh5cTGHxOitMQbML3yHcUHlJTgBdFoQvYm/Uy5lryDViYqKlgiM RQjc472sd5n89XH6n4Ps7SA2PXvfy/U5pwFgT3QtUj2CHX0aloHLzPF8R/62Q8p74Lak R3a0NzlchvFHtE5EOo6tM8ScMOevbIHJ6p9YsGF6oJzlfpQGYTq+bOa++EF0praSyDym 5e2A== 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=UwWrCXO3EiMCCi/VR56OQtOH8VL67AQVe2Td23eGNBo=; b=KVdhEnZGRpJSCu7f2Nfr2OZ9950HUudelgCBxlHeua1m91UNVjFiZyMxpo9+CdfTMB +1wvqJyLLCXyG4h+zpluXw3LNwHDu8xSzcFR3sOzUl2p3knou+U99MDvN/mx6GlHBps5 5bYdmiuunrDzaYdXZLEOs80wjHWArpTdFONGtasHmEMtlixcosq3LbWIB7T7EuZhzufU T9kvuYv2v62xmyTbROvBOmhn4lgCTXAsJPdGU19+3ebbIMsRuDPHgjw/L+LCOt6LR/OB 643I9zOiU6hTCWSBcgOF0CJNfEOVuQH8W+5EekL5Db4tA1xxi2QOr4LojSYLL1OC3BfY +dCw== X-Gm-Message-State: AGi0PuZRMj8oPZt59DTs7OsZhbWz1rIesHwbUdQbvkDqu+4cyByt8SjZ JJTF91HGw256K89Tz0u1nYgJjUNDjGY= X-Received: by 2002:a17:902:207:: with SMTP id 7mr10881495plc.331.1589123434717; Sun, 10 May 2020 08:10:34 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id v7sm6870909pfm.146.2020.05.10.08.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 08:10:34 -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 18/19] perf ftrace: add option --latency-format to display more info about delay Date: Sun, 10 May 2020 23:06:27 +0800 Message-Id: <20200510150628.16610-19-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 This is for the function graph tracer to display more info about latency. The execution context is shown in this case. $ sudo perf ftrace -G --latency-format \# tracer: function_graph \# 1) .... | 0.992 us | mutex_unlock(); 1) .... | 1.404 us | __fsnotify_parent(); 1) .... | 1.023 us | fsnotify(); 1) .... | 0.335 us | __sb_end_write(); 1) d... | 0.439 us | fpregs_assert_state_consistent(); 1) d... | | do_syscall_64() { 1) .... | | __x64_sys_close() { Signed-off-by: Changbin Du --- tools/perf/builtin-ftrace.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index d376b37c53fc..fd8e2f305136 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -44,6 +44,7 @@ struct perf_ftrace { bool nosleep_time; bool nofuncgraph_irqs; bool funcgraph_tail; + bool latency_format; bool long_info; unsigned tracing_thresh; bool trace_children; @@ -217,6 +218,7 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused) write_tracing_option_file("sleep-time", "1"); write_tracing_option_file("funcgraph-irqs", "1"); write_tracing_option_file("funcgraph-tail", "0"); + write_tracing_option_file("latency-format", "0"); write_tracing_option_file("funcgraph-proc", "0"); write_tracing_option_file("funcgraph-abstime", "0"); write_tracing_option_file("irq-info", "0"); @@ -456,6 +458,17 @@ static int set_tracing_funcgraph_tail(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_latency_format(struct perf_ftrace *ftrace) +{ + if (!ftrace->latency_format) + return 0; + + if (write_tracing_option_file("latency-format", "1") < 0) + return -1; + + return 0; +} + static int set_tracing_trace_children(struct perf_ftrace *ftrace) { if (!ftrace->trace_children) @@ -579,6 +592,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_latency_format(ftrace) < 0) { + pr_err("failed to set tracing option latency-format\n"); + goto out_reset; + } + if (set_tracing_trace_children(ftrace) < 0) { pr_err("failed to set tracing option function-fork\n"); goto out_reset; @@ -748,6 +766,8 @@ int cmd_ftrace(int argc, const char **argv) "Ignore functions that happen inside interrupt (function_graph only)"), OPT_BOOLEAN(0, "funcgraph-tail", &ftrace.funcgraph_tail, "Show function tails comment (function_graph only)"), + OPT_BOOLEAN(0, "latency-format", &ftrace.latency_format, + "displays additional information about the latency (function_graph only)"), OPT_BOOLEAN('l', "long-info", &ftrace.long_info, "Show process names, PIDs, timestamps, irq-info if available"), OPT_UINTEGER(0, "tracing-thresh", &ftrace.tracing_thresh, -- 2.25.1