Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp712342ybt; Wed, 8 Jul 2020 09:49:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2M/7hPSlg8YXhqGRVbQLYUiJ106+s0G4BFSH2uML21aZn60n1XtGoWtfAv6TH2hTD2XPh X-Received: by 2002:aa7:d049:: with SMTP id n9mr62534655edo.39.1594226972767; Wed, 08 Jul 2020 09:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594226972; cv=none; d=google.com; s=arc-20160816; b=A9petH5icva3JVxj4uTwraNgAEseMg7J7rSBDMf1rHYReSyXT1sBI8hgdGTE0BrC5r 7r4hXcwwHFL/QYNxVjfogGuRqo/z+JIYq1PagBj06HZB1W36kitvLQiTMK5ESGN4I+Lr WEKxnkSn0JHDUEu2Z4g1W0y5nnDekUWRQMvfAhVKjmX36owR0vGXrNakfAxY5f2s0n5V Oe3lUzREfhSchSOx5qbu1R8sWqZ9WSkGwC6V96M/IVE3O/MRWen5pyo+DWKYzJAGU/uO In2FL15i8QZlo5EiyWBlk1/rQITWfntS2BEnV/GXomL4qmhDBrcerqzSg+anM0YGike9 AFgw== 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=QkOQa+fhsVBdkyrnn+LvzRJ5M0r+UHMFfipuwZ4Wr5k=; b=sjiZwXuXQ1BgoSeNF+Q2rkNRGWG/cj236Rsp7MrpC3khexJVOAthJPVvJDyoEa3mAX 8PPSJ7PWqPlotW1/9YlaW3RcH08DU5bhzRy6+/uSZbRggmdtUx4bDiZux68Q5132JASg 9cSvPfZaQs5mcc6ZckWFrE5s68xmkTP6TrE9+CGOJ0Xe1yKdMS6uIlx/JKW+gZMoAEQB vhZQqgk80crlBmyzi3JL1aVle1qEW7m0nnyBxBh/y/Xh0kEWfjprZ9xcPds8hnmC3Wta 7XqQ0S0SlIiOcPuroFEMaRZyR2+AvtmgBaJ4LkcGXjJypV+MzdV3RD6C8w/c3jr1bp+t BpaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QsJK4Bjj; 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 r22si326468edq.411.2020.07.08.09.49.09; Wed, 08 Jul 2020 09:49: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=QsJK4Bjj; 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 S1730844AbgGHQsD (ORCPT + 99 others); Wed, 8 Jul 2020 12:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730841AbgGHQsC (ORCPT ); Wed, 8 Jul 2020 12:48:02 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14B95C061A0B for ; Wed, 8 Jul 2020 09:48:02 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id k5so1434876pjg.3 for ; Wed, 08 Jul 2020 09:48:02 -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=QkOQa+fhsVBdkyrnn+LvzRJ5M0r+UHMFfipuwZ4Wr5k=; b=QsJK4Bjjk5NoK4hbtiH51s5X7hWNB6/QjFSxRcZrICFfqJiPgH+HyGrx0LwOup1h18 ah4ZMYly447iIaKUfQ+2EM3RoX2eq1OXQ0AIdOaXBJGvFCFm2dhXSxVUEUD92H1h1Ao6 du1g5qorekFo6r5Y9fW23v6gJg4uV8dulNHJoJ2JpTDQEYkT/m+W2aNXa1N5FPIMYA4L KmU6udh+ZNyAFtVBddO0MOqxPIMtbz0BOQtGlS/iUCjA0JI1L0jnA1WEXqSd23dV7glY nJwce05EhxxtK6KwQEnt7ozVyhNA/XIsE16rpxyIEKCrEKS+voz/5fASapeg8/HwYcc1 gPrA== 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=QkOQa+fhsVBdkyrnn+LvzRJ5M0r+UHMFfipuwZ4Wr5k=; b=WH+EgTEu0guJV/RMUdQ6d1hGWmEeTKf7zEhdhp1v1mZ5iki8i+xsqVfnqsvWXX9y6V 5oF+ON1xVYG0mUAHFDwWd17pdzXAcSkUQhpVd3YGO9hvvovJpUQbMhszockDG4FnWntt CIkJvx8PcLEzW0Ep/tBwXt/iIgPXem8IMi69cfzqXBQkA7Co+CmZokVch6ggEPnfd4/a /L0ya0ur2Kf6fDsICLY7k1Bk62kRM7niMsdIe0RA58hwIbBX1O/iLUKZCFgROp6CuJOm RcKjrsk7VA7gSmrlMjHWYn4zr0MPgf5DvkyrEsDBKt83oVTzWNgxF5ImQyT6f9InnWKP Kfeg== X-Gm-Message-State: AOAM532c7h9MtLPeUc0OnPRsD6WECziS49znHykj5qN5/pJ5xE7Xfr5b /pvzE7cF7o9CtHCWzxhlP7I= X-Received: by 2002:a17:90a:65c7:: with SMTP id i7mr10524373pjs.103.1594226881643; Wed, 08 Jul 2020 09:48:01 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id r8sm310803pfg.147.2020.07.08.09.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 09:48:00 -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 v3 11/17] perf ftrace: add support for trace option sleep-time Date: Thu, 9 Jul 2020 00:45:59 +0800 Message-Id: <20200708164605.31245-12-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200708164605.31245-1-changbin.du@gmail.com> References: <20200708164605.31245-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 nosleep-time' which allow us only to measure on-CPU time. This option is function_graph tracer only. Signed-off-by: Changbin Du --- v3: switch to uniform option --graph-opts. v2: option name '--nosleep-time' -> '--graph-nosleep-time'. --- tools/perf/Documentation/perf-ftrace.txt | 4 +++ tools/perf/builtin-ftrace.c | 41 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt index eba0e85aa308..2165a75f1da1 100644 --- a/tools/perf/Documentation/perf-ftrace.txt +++ b/tools/perf/Documentation/perf-ftrace.txt @@ -106,6 +106,10 @@ OPTIONS --graph-depth=:: Set max depth for function graph tracer to follow +--graph-opts:: + List of options allowed to set: + nosleep-time - Measure on-CPU time only for function_graph 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 095471593d68..57d04d0e1178 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -43,6 +43,7 @@ struct perf_ftrace { unsigned long percpu_buffer_size; bool inherit; int func_stack_trace; + int graph_nosleep_time; }; struct filter_entry { @@ -201,6 +202,7 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused) { write_tracing_option_file("function-fork", "0"); write_tracing_option_file("func_stack_trace", "0"); + write_tracing_option_file("sleep-time", "1"); } static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) @@ -382,6 +384,17 @@ static int set_tracing_trace_inherit(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_sleep_time(struct perf_ftrace *ftrace) +{ + if (!ftrace->graph_nosleep_time) + return 0; + + if (write_tracing_option_file("sleep-time", "0") < 0) + return -1; + + return 0; +} + static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) { char *trace_file; @@ -461,6 +474,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_sleep_time(ftrace) < 0) { + pr_err("failed to set tracing option sleep-time\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; @@ -644,6 +662,26 @@ static int parse_func_tracer_opts(const struct option *opt, return 0; } +static int parse_graph_tracer_opts(const struct option *opt, + const char *str, int unset) +{ + int ret; + struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value; + struct sublevel_option graph_tracer_opts[] = { + { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time }, + { .name = NULL, } + }; + + if (unset) + return 0; + + ret = perf_parse_sublevel_options(str, graph_tracer_opts); + if (ret) + return ret; + + return 0; +} + int cmd_ftrace(int argc, const char **argv) { int ret; @@ -686,6 +724,9 @@ int cmd_ftrace(int argc, const char **argv) "Set nograph filter on given functions", parse_filter_func), 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", + parse_graph_tracer_opts), OPT_UINTEGER('d', "delay", &ftrace.initial_delay, "ms to wait before starting tracing after program start"), OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", -- 2.25.1