Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2711051pxa; Fri, 7 Aug 2020 19:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiLldU380u9N75f1jx/ZAzCzBLxUdgh4wg8w87F4NK5RsBft+QVUE9a9Z1sqQxDHedhLvO X-Received: by 2002:a17:906:4e14:: with SMTP id z20mr12713188eju.541.1596854433101; Fri, 07 Aug 2020 19:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596854433; cv=none; d=google.com; s=arc-20160816; b=McrGXIMgXcoSg8Wj6PmWqyuW2LRNyd3OpaKpmzh4Y7yYM5ya4vQuKVWLpW6/25ZZGc meYfVmMU6jUbjk6bLzk3V7TlDWixIRezckotTZ3HMlW2i9Q+iDoRpVHj8hj3h9/ADZKD LLpnndPyfsqYJR6Ps+xmoKfLw+6TNs+ViOi96dwbzeM88AITrK56y71bJ1uYJ5m2PP+G ck8867g7nPdXs1STW8qq2yM5ZLJQHZfMYbg7tkhMJTrYPN92qOd2uOyOBE+OrFnM1NIj Hr208AKPmv0EIGh+pr5OfdkhAIhtOxdz3xRCioiDPNDZeeAbdBX4ghO+xibupHTT+Tbu RgKA== 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=UJoxlxdzo/7xR3hce6XQ/G6O6irwnhhW25YH3Di2vOU=; b=Se0Yx+2lcYQN9pebnVKuI4Xy9qCDh49YopVs2L1UWGibo1hHgbM4ar6N/SEL9nbb5H nJKU0JzGXEihVkPncBayvCVBBK16y7EEnuGA+EBnIuH+tIoQnl9NbRMSgeBgzH+ceWdw rh5s1oPRppS0NN36JzyCgfUroDFGwaO3B8Y8rj8lB/plN3fZwVkgTqrHIB9L4DQ5ow/o SQdvBKkT3uEiCg2y0bbo2iB19GjPvDh3n/iaOeMrvizAmbRqDb/HtjEqobJlPvhmJrZb RnQYZUnJ/KZomvXbJEyLnjrSKEMAD+OUb92gEK4Ovu064um8lQD6Ox1ywAc2cCi5WvW5 ULkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u2HIUZMV; 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 r26si6210584edy.137.2020.08.07.19.40.10; Fri, 07 Aug 2020 19:40:33 -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=u2HIUZMV; 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 S1726518AbgHHCj1 (ORCPT + 99 others); Fri, 7 Aug 2020 22:39:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgHHCj1 (ORCPT ); Fri, 7 Aug 2020 22:39:27 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D4EBC061756 for ; Fri, 7 Aug 2020 19:39:27 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id p4so3541294qkf.0 for ; Fri, 07 Aug 2020 19:39:27 -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=UJoxlxdzo/7xR3hce6XQ/G6O6irwnhhW25YH3Di2vOU=; b=u2HIUZMVJJUbRUbxKKeJkqo9uMtY6j7IYbE7LNlPUxAdbNG1z6mJuYXKw8/z38xYuk 8rFTiVjRhLBFc5xhPKoCfAbBPuVmMuR6ohNJvg3m766RW7nCr/il7Ih6XkT2/ZwPbtqI Vhf3bBF5pv+PXi38svJWoy42RsWjtMNza5aFzuVS3mzDVr/qPA0/+NPqKwhyu7BRZJZg 6rBkQ4QQfMKBDK1JwL1t6jW8XjM4kl6fVFSyEADg8wMGzxcKMamP1c5hrd2Q1jCnOK53 4y3lLjTqP+FshHkZUonp8oG2c7NAaM0CPcGExfhhyakqqwHZed5Lh+AUVhCeKKTmO8iy ijAg== 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=UJoxlxdzo/7xR3hce6XQ/G6O6irwnhhW25YH3Di2vOU=; b=Rjs+/lgG+VlG0yXDNMXNsXWGWRQpIEkxmCa/q041/caRukKntNTdMxrZc4NzDI2Cqe 81KoVEhpIj2TpWDtfvSUj9vxnyEMYFMtPFAW7v8C88jesV42irv7NX2nc4/JTLRaY3CV L5NK3Tm++rHaJk2KHvFAl2ceaQwG2a4yT8tmlbb+s48+KjXq+tmusBieNj9PojbzC1gD WZSwbjEEWZa+N+zL0n2u8+oQNEkUkrlGKg9BCq7nYo1O4Yu+uuktRFKNEytiZotAZI1I HB2CLqGou8HfKdkpwMZFyHco2bYPwcNrY00wkp7cF1zfVyr9qGh5V+3aE99qdYzyouW2 e5LQ== X-Gm-Message-State: AOAM533GPMHOwuIk+IU/y3/MSeWhvx9BHny+apZs1vgSsvFeIZIoDOO1 k7UXZRh+8zqV0AjE1ktzxh4= X-Received: by 2002:a37:a503:: with SMTP id o3mr16003767qke.162.1596854366363; Fri, 07 Aug 2020 19:39:26 -0700 (PDT) Received: from vultr.guest ([66.42.85.36]) by smtp.gmail.com with ESMTPSA id n33sm7818702qtd.43.2020.08.07.19.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 19:39:25 -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 v8 09/18] perf ftrace: add support for trace option sleep-time Date: Sat, 8 Aug 2020 10:31:32 +0800 Message-Id: <20200808023141.14227-10-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200808023141.14227-1-changbin.du@gmail.com> References: <20200808023141.14227-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 8f08ad0992c2..3380a2e2c9ad 100644 --- a/tools/perf/Documentation/perf-ftrace.txt +++ b/tools/perf/Documentation/perf-ftrace.txt @@ -101,6 +101,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 469b89748c42..47d63bba6a48 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -44,6 +44,7 @@ struct perf_ftrace { unsigned long percpu_buffer_size; bool inherit; int func_stack_trace; + int graph_nosleep_time; }; struct filter_entry { @@ -205,6 +206,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) @@ -386,6 +388,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; @@ -465,6 +478,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; @@ -637,6 +655,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; +} + static void select_tracer(struct perf_ftrace *ftrace) { bool graph = !list_empty(&ftrace->graph_funcs) || @@ -694,6 +732,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_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", "size of per cpu buffer", parse_buffer_size), OPT_BOOLEAN(0, "inherit", &ftrace.inherit, -- 2.25.1