Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1381895ybt; Sat, 27 Jun 2020 06:42:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynolSuVc10ZNZFBXMwzhvqBWcpMOFAJWkTFY8YhGrBDI8JtESCOdIa97+2IahUTdMhK/9E X-Received: by 2002:a17:906:9394:: with SMTP id l20mr7208418ejx.467.1593265334980; Sat, 27 Jun 2020 06:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593265334; cv=none; d=google.com; s=arc-20160816; b=o77j/NfubO0KuuCQI3V8Nen1EBB52qNp3XqM57Ldh8bGOYju+jN4HFlpkgpKguxylu K7Vputdl6qiU8g7EMJ3R8xxhkKfltREtXoKrcURbN4lnrUznykdrcisq3JWg2aO9s/tW 8fpl8fN5D4Cddfe5iNEWgnUEomK+zv8QfHK8ajZNRRgp+5HYrmR0EW7F3GYS23cMVt9S LOh5uCzl+eol43j2lt6fr+Z2EE7iSyyu1Occl7AJX/9hfojaTsS5pSa4rRyNElREyTsu 3tmozfdi1B1NQnUC4En1/vSj/iTQl7N5PCxBmOuhjSGhOvZWZst+PlOhoY37MY/YBB4L lYeg== 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=NsLJGbXipZRby2dRrFjoiSEZL0RmxKph7eOLD/owQ6o=; b=gw4a6V6CsgIhasOzrm2vviH878/u3lmyUPODj2Sepji8T/Oc03UolLrlIwUIYAUVk/ Tc7f9tLmeKY4YC3qC8WE64veuJTra6aXFKl8FCd50B35drum4ybJawtYwoxadXcMnEll PtqHCEd/QmbGN/2fYseJZK4Jf7LeIoxzc34MhMX2n82l4F8mt9Mwy3QGFC4jxe8eYaGx Jh87oLtbKKt6SXjsij6ZRPndsjMLRmMtBOiqiV4MLCzGu7nMwKX3bnOs36MN75jj8kne EBWyE3IUObVW+25qZpP+KzkiTomuVOO+t/06owH6KGKOUhUmK7ZfKXLg6JIjHAzxK/ZO C7/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M5W+8UiK; 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 p23si8902234ejz.151.2020.06.27.06.41.52; Sat, 27 Jun 2020 06:42:14 -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=M5W+8UiK; 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 S1726920AbgF0Nis (ORCPT + 99 others); Sat, 27 Jun 2020 09:38:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbgF0Nis (ORCPT ); Sat, 27 Jun 2020 09:38:48 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E98C061794 for ; Sat, 27 Jun 2020 06:38:48 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id t6so6275165pgq.1 for ; Sat, 27 Jun 2020 06:38:48 -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=NsLJGbXipZRby2dRrFjoiSEZL0RmxKph7eOLD/owQ6o=; b=M5W+8UiKUw2VGgK5sqy3qWAj+RfTLoVA0B05jfGbFgSaSl4iWjcr/qLiiKAk9WPuJM P0lPoiKbkJoFJr9n0qv3DfbudPC6I0KPGpthbgYaf8W+H5uR1POkdrQpcb8YNdz4h998 vJdoYrsibj1FNCqu9zBhSrnPmltrAOHD63XGPmQPBbs2PrxSBeZFeUBJ2hsA01DB2hPK 03GQ3zo8Frj18IQIhKtFjLhyFru6qbpUXmXLTTCo9KMxuTCUvX39hD4kaPD/Qrk7lFuZ 2LyCqCCAdsKVGQZd2xbwu0nkOsy4w1JtllulZhh7rBIcJBb5Egqu9kX9gU7YZlYFL36i U4aA== 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=NsLJGbXipZRby2dRrFjoiSEZL0RmxKph7eOLD/owQ6o=; b=Pk/cR2obffSIZzdJ8qiY8cCMCqbZFDVfnTHiOUBdvCJL9bxepjAMjVMYlCieOXe4tD i7JpT/0U4FzTZnQktxc6m/ll9kwQl4j6lcaYir4QwTlKc6L80/LxsMNsg5y3gwIzNRa0 6RoiVUsQNqN36J1SriYBfdpWmaZci3uN0ElJxWNj3WmB3ayPut3QYydr5+tC1qaxevB4 Et9mBmvCNCCDa19R5vlPi0K3T2mqq5A0amDXPRlDPQbiQ3Y7IYekiGG7l851CN5giUr2 jEAGUqcQJvE14y/pRdrxSa54Vr1RqTTIXC17C1SGhuJuJRmbodxrS4RTZA1CIDVuuLcg UzAg== X-Gm-Message-State: AOAM532P6bahzQSANkjguTsCjPMA5Qu5ND9/jAjDmgUG+yLCf4f2JDsr /Ay+n4fXhA8hDpCRrKC9lEg= X-Received: by 2002:a63:560f:: with SMTP id k15mr3250755pgb.162.1593265128032; Sat, 27 Jun 2020 06:38:48 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id x8sm15060086pje.31.2020.06.27.06.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jun 2020 06:38:47 -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 v2 14/15] perf ftrace: add support for trace option tracing_thresh Date: Sat, 27 Jun 2020 21:36:53 +0800 Message-Id: <20200627133654.64863-15-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200627133654.64863-1-changbin.du@gmail.com> References: <20200627133654.64863-1-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds an option '--graph-thresh' to setup trace duration threshold for funcgraph tracer. $ sudo ./perf ftrace -G --graph-thresh 100 3) ! 184.060 us | } /* schedule */ 3) ! 185.600 us | } /* exit_to_usermode_loop */ 2) ! 225.989 us | } /* schedule_idle */ 2) # 4140.051 us | } /* do_idle */ Signed-off-by: Changbin Du --- tools/perf/Documentation/perf-ftrace.txt | 3 +++ tools/perf/builtin-ftrace.c | 25 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt index cc770fc0a1e8..64843d0cdc45 100644 --- a/tools/perf/Documentation/perf-ftrace.txt +++ b/tools/perf/Documentation/perf-ftrace.txt @@ -116,6 +116,9 @@ OPTIONS --graph-verbose:: Show process names, PIDs, timestamps for function_graph tracer. +--graph-thresh:: + Setup trace duration threshold for funcgraph tracer. + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-trace[1] diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index e037fe7abd47..0f8716ea0da4 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -46,6 +46,7 @@ struct perf_ftrace { bool graph_nosleep_time; bool graph_noirqs; bool graph_verbose; + unsigned graph_thresh; }; struct filter_entry { @@ -229,6 +230,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) if (write_tracing_file("max_graph_depth", "0") < 0) return -1; + if (write_tracing_file("tracing_thresh", "0") < 0) + return -1; + reset_tracing_filters(); reset_tracing_options(ftrace); return 0; @@ -440,6 +444,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_thresh(struct perf_ftrace *ftrace) +{ + int ret; + + if (ftrace->graph_thresh == 0) + return 0; + + ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh); + if (ret < 0) + return ret; + + return 0; +} + static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) { char *trace_file; @@ -539,6 +557,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_thresh(ftrace) < 0) { + pr_err("failed to set tracing thresh\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; @@ -726,6 +749,8 @@ int cmd_ftrace(int argc, const char **argv) "ignore functions that happen inside interrupt for function_graph tracer"), OPT_BOOLEAN(0, "graph-verbose", &ftrace.graph_verbose, "show process names, PIDs, timestamps for function_graph tracer"), + OPT_UINTEGER(0, "graph-thresh", &ftrace.graph_thresh, + "only show functions of which the duration is greater than µs"), OPT_END() }; -- 2.25.1