Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp586288ybg; Mon, 1 Jun 2020 09:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4tvxuVbGGi97QE4ZMW52/MdYdYuHHBC8WFwbI1F5FFo01Zwf0w17NOXHMhNE06SJGCOvz X-Received: by 2002:a17:906:55c9:: with SMTP id z9mr5697095ejp.276.1591027395371; Mon, 01 Jun 2020 09:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591027395; cv=none; d=google.com; s=arc-20160816; b=K47S0LIDQJZfkddfKa0rKGQB4S7arWJWJi+/p2njcACIvOtydJ8uCCbXSgLqes+ZjF GN60YIIJxbxT11DROAguyW+yW7rCm7cEPJVRSttPuIHHt4csZ21Sgv+RmsvTyiTMsa22 K0av0plrhLYhI5W8vWh5s1TkP4B5BYXr2XjFx0TP/hCjgP1jZYXyU6h4kHG4WY1s+Pyj TuoErwjt1iYake7CtgJRy0SNcsA70T4KJ4PkVzFQjaRb+R7PFq5S73BVjUVjDKFk/F5w ETXDV5sYLb8g+Z2nDYLk58zgxtP7JpDCPv/3KRwFkKJhK8IUW6KHMgBplrE1KTXkgiS1 8x3w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=8MLeBvDsslNI7nnZPQPkm2Oym4ryI/nMmLltCX3W/os=; b=tJbMxd+ZTEJhnC9cl7KIoq3fZzaXvs1DOck1l2FpR4wdi4kzeVOxT/usFFrhD6p9ln u1K0uaSHASCGyFyPxguSbys8m3n92JvspsZnr2tyjbEMeVo51SKquxS+FLZp44YZWRh+ BqGWSvlN6wqidf/8f+ej1ceIjokEbPQ2bS7cYUDLEnibsmvNT9ISQR0YpPOGnOQEghNB edyDMYHSX+D33WQxhfOM6S279LPehs0rUCD0w2fIKjp8SPGJm13nSkRabc4XcVJMG53L dAb2Adi+u/LF8/cSP2djyYZnKt6x7v94KXrB8G2VXNBlGk/0q9UqTh1ii2vugCxSBHVe JRKA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si3562380edw.77.2020.06.01.09.02.48; Mon, 01 Jun 2020 09:03:15 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbgFAP6Z (ORCPT + 99 others); Mon, 1 Jun 2020 11:58:25 -0400 Received: from mga01.intel.com ([192.55.52.88]:57197 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbgFAP6Z (ORCPT ); Mon, 1 Jun 2020 11:58:25 -0400 IronPort-SDR: nKnL9GXgNdV7y1eR79tXKRO4yaLnrkVrYkmDWmke23NxWzkpwXo3N6yMK/gGonyo/BMl8c272k XrQ4rZdPwBgg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 08:58:24 -0700 IronPort-SDR: MjXikgx+FgiPhATo4dDoBGA/8PaAOvSGuW8QPX9BBFThLnLJb83rY9OTd8ZMdHdz0hatxNby7j n0yb0XyI8yrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,461,1583222400"; d="scan'208";a="347081992" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 01 Jun 2020 08:58:24 -0700 Received: from [10.249.230.65] (abudanko-mobl.ccr.corp.intel.com [10.249.230.65]) by linux.intel.com (Postfix) with ESMTP id 81706580646; Mon, 1 Jun 2020 08:58:22 -0700 (PDT) Subject: [PATCH v5 08/13] perf stat: extend -D,--delay option with -1 value From: Alexey Budankov To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: Organization: Intel Corp. Message-ID: <9a0ef5c9-e66c-bd64-5f9d-ef3d4a135e66@linux.intel.com> Date: Mon, 1 Jun 2020 18:58:21 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend -D,--delay option with -1 value to start monitoring with events disabled to be enabled later by enable command provided via control file descriptor. Signed-off-by: Alexey Budankov --- tools/perf/Documentation/perf-stat.txt | 5 +++-- tools/perf/builtin-stat.c | 18 ++++++++++++++---- tools/perf/util/evlist.h | 3 +++ tools/perf/util/stat.h | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index b029ee728a0b..9f32f6cd558d 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -238,8 +238,9 @@ mode, use --per-node in addition to -a. (system-wide). -D msecs:: --delay msecs:: -After starting the program, wait msecs before measuring. This is useful to -filter out the startup phase of the program, which is often very different. +After starting the program, wait msecs before measuring (-1: start with events +disabled). This is useful to filter out the startup phase of the program, +which is often very different. -T:: --transaction:: diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 8eeaf92912d8..d0ddaa5fac96 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -441,16 +441,26 @@ static bool process_timeout(bool timeout, unsigned int interval, int *times) static void enable_counters(void) { - if (stat_config.initial_delay) + if (stat_config.initial_delay < 0) { + pr_info(EVLIST_DISABLED_MSG); + return; + } + + if (stat_config.initial_delay > 0) { + pr_info(EVLIST_DISABLED_MSG); usleep(stat_config.initial_delay * USEC_PER_MSEC); + } /* * We need to enable counters only if: * - we don't have tracee (attaching to task or cpu) * - we have initial delay configured */ - if (!target__none(&target) || stat_config.initial_delay) + if (!target__none(&target) || stat_config.initial_delay) { evlist__enable(evsel_list); + if (stat_config.initial_delay > 0) + pr_info(EVLIST_ENABLED_MSG); + } } static void disable_counters(void) @@ -1007,8 +1017,8 @@ static struct option stat_options[] = { "aggregate counts per thread", AGGR_THREAD), OPT_SET_UINT(0, "per-node", &stat_config.aggr_mode, "aggregate counts per numa node", AGGR_NODE), - OPT_UINTEGER('D', "delay", &stat_config.initial_delay, - "ms to wait before starting measurement after program start"), + OPT_INTEGER('D', "delay", &stat_config.initial_delay, + "ms to wait before starting measurement after program start (-1: start with events disabled)"), OPT_CALLBACK_NOOPT(0, "metric-only", &stat_config.metric_only, NULL, "Only print computed metrics. No raw values", enable_metric_only), OPT_BOOLEAN(0, "metric-no-group", &stat_config.metric_no_group, diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index bccf0a970371..7c3726a685f5 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -377,4 +377,7 @@ int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack); int evlist__finalize_ctlfd(struct evlist *evlist); int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd); +#define EVLIST_ENABLED_MSG "Events enabled\n" +#define EVLIST_DISABLED_MSG "Events disabled\n" + #endif /* __PERF_EVLIST_H */ diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index f75ae679eb28..626421ef35c2 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -116,7 +116,7 @@ struct perf_stat_config { FILE *output; unsigned int interval; unsigned int timeout; - unsigned int initial_delay; + int initial_delay; unsigned int unit_width; unsigned int metric_only_len; int times; -- 2.24.1