Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp3560367imc; Sun, 24 Feb 2019 07:40:07 -0800 (PST) X-Google-Smtp-Source: AHgI3IaN+VEGQoq8+iL0w0WF0K2BGZr5KOf3n6ZuCoyXV82nrOifMI+XoX8eOqFpxDspY0QltyUZ X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr5342311plb.164.1551022807678; Sun, 24 Feb 2019 07:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551022807; cv=none; d=google.com; s=arc-20160816; b=xJ2wtGWzjib6ZQxI8Tdmly1+t8b1zUHCyV7cXRP4klj12y4E+s22+dAl6UzbU1J0Xd dg0ZawPmApo8rqME1wQJFRUbppxVk5pRk+4UZ5mNDmPYepIE2R5QF3yoreKcZAt3GaPV 7+HR7ueakyK3f+OX15ZGBV60cibZDDcpIcxrBYzJUJrfd841wL4tVTkbglB43TDVd2Po DHanp5K7EgIRIzicpBkkL+swWfO0l48N8QofLOW3laV6tJPP4YHGtaZsSjRsa296fFzF LFtLJu8XuPfAevRO3vxDQFRdgtgE47Lavt+yIoCqj8Po7MCtvlWj8B2XvFH1WhT8aOWl qpzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=phd79qbykf0dHwKmCAWCx3Bc1mh3XOJ+WdBYdc20aY0=; b=OM5wkf5aG25/k15nMk1wPTZJjMdp8uxzYwG0EdkWGThOK5krU0SpxCCV3PLRqvVmtD XRGEg7wgnMQJ0KM2qL6B8kVeJ8GAmvKyBPDUr7MtGzvbHDLXsmuLs2OYJeYQ0VBDd8Km DzFMeK4+KUOvqyZiJ4Fw+osGDDYKXpcLu79+ur20NAW2UiB8rZGcQb7kVTBHHVE/6vee LqPHuiUFKJ+foNRllH7Bu8xS/X7NVYpvm1AKLfmqWJusXgk5hB+KsICuf93ghAipMe3+ ladxifdvdS0OHpXjJoqyW8FlqLNHcPQy7M6K4jnXWkI3FOgsj0FHkEwVZFmz6HJ5fYta VBMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id co9si7168097plb.324.2019.02.24.07.39.52; Sun, 24 Feb 2019 07:40:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728631AbfBXPjB (ORCPT + 99 others); Sun, 24 Feb 2019 10:39:01 -0500 Received: from mga01.intel.com ([192.55.52.88]:4458 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727752AbfBXPhb (ORCPT ); Sun, 24 Feb 2019 10:37:31 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP; 24 Feb 2019 07:37:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,407,1544515200"; d="scan'208";a="120396829" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by orsmga008.jf.intel.com with ESMTP; 24 Feb 2019 07:37:30 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 9A6AD3011D4; Sun, 24 Feb 2019 07:37:30 -0800 (PST) From: Andi Kleen To: acme@kernel.org, linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, eranian@google.com, Andi Kleen Subject: [PATCH 04/11] perf tools report: Parse time quantum Date: Sun, 24 Feb 2019 07:37:15 -0800 Message-Id: <20190224153722.27020-5-andi@firstfloor.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190224153722.27020-1-andi@firstfloor.org> References: <20190224153722.27020-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen Many workloads change over time. perf report currently aggregates the whole time range reported in perf.data. This patch adds an option for a time quantum to quantisize the perf.data over time. This just adds the option, will be used in follow on patches for a time sort key. Signed-off-by: Andi Kleen --- tools/perf/Documentation/perf-report.txt | 4 +++ tools/perf/builtin-report.c | 37 ++++++++++++++++++++++++ tools/perf/util/hist.c | 2 ++ tools/perf/util/hist.h | 2 ++ 4 files changed, 45 insertions(+) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 51dbc519dbce..9ec1702bccdd 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -497,6 +497,10 @@ include::itrace.txt[] The period/hits keywords set the base the percentage is computed on - the samples period or the number of samples (hits). +--time-quantum:: + Configure time quantum for time sort key. Default 100ms. + Accepts s, us, ms, ns units. + include::callchain-overhead-calculation.txt[] SEE ALSO diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index bb8918a747ba..600e168f3b99 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -47,6 +47,7 @@ #include #include #include +#include "sane_ctype.h" #include #include #include @@ -926,6 +927,39 @@ report_parse_callchain_opt(const struct option *opt, const char *arg, int unset) return parse_callchain_report_opt(arg); } +static int +parse_time_quantum(const struct option *opt, const char *arg, + int unset __maybe_unused) +{ + unsigned long *time_q = opt->value; + char *end; + + *time_q = strtoul(arg, &end, 0); + if (end == arg) + goto parse_err; + while (isspace(*end)) + end++; + if (*end == 0) + return 0; + if (!strcmp(end, "s")) { + *time_q *= 1000000000; + return 0; + } + if (!strcmp(end, "ms")) { + *time_q *= 1000000; + return 0; + } + if (!strcmp(end, "us")) { + *time_q *= 1000; + return 0; + } + if (!strcmp(end, "ns")) + return 0; +parse_err: + pr_err("Cannot parse time quantum `%s'\n", arg); + return -1; +} + int report_parse_ignore_callees_opt(const struct option *opt __maybe_unused, const char *arg, int unset __maybe_unused) @@ -1148,6 +1182,9 @@ int cmd_report(int argc, const char **argv) "Set percent type local/global-period/hits", annotate_parse_percent_type), OPT_BOOLEAN(0, "ns", &nanosecs, "Show times in nanosecs"), + OPT_CALLBACK(0, "time-quantum", &time_quantum, "time (ms|us|ns)", + "Set time quantum for time sort key (default 100ms)", + parse_time_quantum), OPT_END() }; struct perf_data data = { diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 669f961316f0..d25ca5bb91e6 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -20,6 +20,8 @@ #include #include +unsigned long time_quantum = 100000000; + static bool hists__filter_entry_by_dso(struct hists *hists, struct hist_entry *he); static bool hists__filter_entry_by_thread(struct hists *hists, diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 4af27fbab24f..8e602b486c5c 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -531,4 +531,6 @@ static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t s return __hists__scnprintf_title(hists, bf, size, true); } +extern unsigned long time_quantum; + #endif /* __PERF_HIST_H */ -- 2.17.2