Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1290106ybt; Sat, 11 Jul 2020 05:45:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw86Fi1S3K5wtWmP2R8QPEQbD6l9jus74lgFi5qOF51vp6/4HllLj2DA62v9fng2H1LRtv4 X-Received: by 2002:a17:906:82d4:: with SMTP id a20mr61392428ejy.165.1594471500873; Sat, 11 Jul 2020 05:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594471500; cv=none; d=google.com; s=arc-20160816; b=FYkq1RmwmkzHLpdq7phz7VH+5QnDIQCdpo8UtjtqYdwShUjQp0uHUCmSPiyUYWNmCa iXl6ALoS6KRSaH6ugAp+K5gCyP+NTbbs4Y0GjL97MjwbafRbHfqQ6S42a3/Ed6/h3SYF E+wvlceJ46ALzO3L0R0MsR7i+OrfQGlv4zUDka4TKLNz7+OYxL7H893dc/B0MWjYHWlp Gt2zMZBJV1npGgA6AS3NWPeNh/NP/VpqYSU9xCsLZb4qhzysw+PKQ4axcsTK8+v0vOAM OuyjaN97wlz+x5xwggr5684iTNxoIkV55NYPTzZAeEHI0jPPuODn+WNub5PUma8W09lB 8/kw== 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=a2hRN1o8EhoWJ7fMKxLmJVUsfsNgfHlSCMCgFfm4Eu0=; b=SJho0SKTY2RDx6p/hFTJfYmJnpoyhjt4wZf2HLfdEym/hYryoCgFSELa5fdhDpnxtk M8s8/txihPlzbjPk5J8OdPYjYUk8p8nEOY7iZ3hcEigjncD9KGP4cfbMUvO3BRjlLIBP 7OLX2hIyL9K5ZfbfxBZ6KuhaZoFqGwomTP7eGpei82HcWsti0L9nf0pOKKAwq8rBxNCX uWU8121xtuwOJfIPeuy0Cy4mnVq2PgTvUXlzSIRx7yLcf4bv8G8RaKD2tVnmyq187NXL HyRb9Z+w+NHYhoI5JpnTcdHS2Dp8fWe3XEAs8G27zZ+f7rez/qygokuOFl0nljhATvsC 9uHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R1yg7yls; 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 s20si5907240edy.519.2020.07.11.05.44.38; Sat, 11 Jul 2020 05:45:00 -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=R1yg7yls; 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 S1728510AbgGKMnh (ORCPT + 99 others); Sat, 11 Jul 2020 08:43:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbgGKMnh (ORCPT ); Sat, 11 Jul 2020 08:43:37 -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 04934C08C5DD for ; Sat, 11 Jul 2020 05:43:37 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id o1so3368425plk.1 for ; Sat, 11 Jul 2020 05:43:37 -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=a2hRN1o8EhoWJ7fMKxLmJVUsfsNgfHlSCMCgFfm4Eu0=; b=R1yg7ylscd3dtJGfSD6X8VU53CaYeaAiNis/Ps0Ikg+0iLZu3DUH0MsvRLYhATD+ib I0HNCXSaklAbckgnaGezYXSGA3sEpHkw5DCA+uTnrdxnfjzIN1X0VI7cv8xJ+olPKyu4 BdBixJx34BNFd2TvRHlmGJssYzJbv8ElvefTozlN/1zrI9A0Oen38nP+bn97CB1G1So/ 1jfPLmd4TksinX078/yfxWtwOMNS9NvP/geEUzCIa4ZoU6LnKd4ELWtpmUV5o6krpXNi WjaH3fxg8KkIWz9ey4FB+jhSZRtjO86JDJhoxK7GucY4LZmppZkjSYxRt1c8BcdKSts0 wrwQ== 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=a2hRN1o8EhoWJ7fMKxLmJVUsfsNgfHlSCMCgFfm4Eu0=; b=P5GuVyZCytOnKmakJzx4XpN6keLcN1L89TNWD5JrmlSbqhWrOQipM+u+46MfmgueQU Abgt4e/sJnZ0VtMZd73C6vTyXVdccofEaOIrIdAazlwu+4/fAfCSFhHWt7jXACav1FZw xDWTvQOZm4/7hnoPH4Fzo0ITXH7HePjmV07vZ+OjGy2U6g3kwwHDXwtDv3mM2DIkzGLB /SpDvNYOViAY75V6c4OrKqeIbYkF4v2W5pKu6Kx+WPptb7ex5Ozlq8BA5K2uXLmQBSiM HDo9aGSa2syHKbZlzq1IKbSajCWvVaDJxzvZeDAtS+dr21QErZuj5RX30va7wP0wFiEn ROBw== X-Gm-Message-State: AOAM533ZeU6ozVW6f6tYcaB0KZjdryx1VsEV1EojheKcvtLn5Hmfk79O JS8/q5Y6SobT20sGrKhHNdA= X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr60489476plq.314.1594471416581; Sat, 11 Jul 2020 05:43:36 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id c19sm8352899pjs.11.2020.07.11.05.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 05:43:35 -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 v5 14/17] perf ftrace: add support for trace option tracing_thresh Date: Sat, 11 Jul 2020 20:40:32 +0800 Message-Id: <20200711124035.6513-15-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200711124035.6513-1-changbin.du@gmail.com> References: <20200711124035.6513-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 adds an option '--graph-opts thresh' to setup trace duration threshold for funcgraph tracer. $ sudo ./perf ftrace -G --graph-opts 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 | 1 + tools/perf/builtin-ftrace.c | 26 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt index 0dd5ef4f9c65..a103e3fd8d42 100644 --- a/tools/perf/Documentation/perf-ftrace.txt +++ b/tools/perf/Documentation/perf-ftrace.txt @@ -108,6 +108,7 @@ OPTIONS 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. + thresh= - Setup trace duration threshold in microseconds. SEE ALSO -------- diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index d169d6329454..c6d0194e4d0e 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -46,6 +46,7 @@ struct perf_ftrace { int graph_nosleep_time; int graph_noirqs; int graph_verbose; + int 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; @@ -441,6 +445,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; @@ -540,6 +558,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; @@ -723,6 +746,7 @@ static int parse_graph_tracer_opts(const struct option *opt, { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time }, { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs }, { .name = "verbose", .value_ptr = &ftrace->graph_verbose }, + { .name = "thresh", .value_ptr = &ftrace->graph_thresh }, { .name = NULL, } }; @@ -779,7 +803,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,verbose", + "graph tracer options, available options: nosleep-time,noirqs,verbose,thresh=", 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