Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1109008ybs; Mon, 25 May 2020 07:24:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEC9WeVVqzzEv+gUlTD4PkbPpmhlV5JROhXNg33D3ehqlrBObVL/LoxxZIQvSd+vv13S97 X-Received: by 2002:a17:906:bcf3:: with SMTP id op19mr19423135ejb.537.1590416641074; Mon, 25 May 2020 07:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590416641; cv=none; d=google.com; s=arc-20160816; b=pu2Ud/l2Sd0bIHS7VH3OXhpdzIJL/kZ7bKtR/9qq4/l8Qym7E3lTlN9mrxEbCzl/l5 GxI2g5NxvjbVhqfMvwmucQ6oYT/jVF/J6bN1V5j+vgdXugaGUzMhtIfZi6MTg+3L1Eev iJScFis9YSYmV8ZrAJW0IWJ6KtpvI9xpQeIOf19blCZpTVALE78ft1z+VWbkPrj2QAyV rPYMYD0LhYF/0xf4Ov8DEYag/c4xQRYvngWLAN3MsjPcSd7BGZCKmAh2C5+RIxPweUmi ypywTbNYBsQAXOFe7eeJ+7PHrZpAsFqsntTyobEm0UVmw7hgKCDhwpg7/Gr1T/IwFxTv 87Wg== 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=miO+DYnnyQiwH0v5DVMbkyc1r16GT3jUIdjxIfBcxqw=; b=lGFUoZ9JV0cm4D42863vX/dgtJQAwy2GvGMX6liy+q+3yTjfnYxdjC4K8GKnl5jmeM ksZowBQNZFqj08qpzF4k2EdCkbdeZ7S7PyZdsEW5J+oV/14s/wDQY8lWTSepgtSTIHYQ l4NmVtiQ58QIhA34w1MxWVcfT9ENQWjaB2+MHArLZBWsfbQKfAyHVHPgb+L6Rb577Ye3 YlSX+2xO7odt9D7iprJQMI7lWshpeXmVfMrBhM8rqgkHcz1kmmU1r+wS01k1wRPc69A7 3eeEioCylWEBSF5bxFMbS0Ule8dAsYa0vn+KOCx7g2tcvQpp3KS6hM8YJqEaADzgFd06 uQKw== 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 dk26si9592187edb.179.2020.05.25.07.23.38; Mon, 25 May 2020 07:24:01 -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 S2390911AbgEYOUn (ORCPT + 99 others); Mon, 25 May 2020 10:20:43 -0400 Received: from mga09.intel.com ([134.134.136.24]:48247 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388714AbgEYOUm (ORCPT ); Mon, 25 May 2020 10:20:42 -0400 IronPort-SDR: jDX+qbTQwb4dVWb3hLa9petHYK+FlSamWzNH5mE3Aj4C7urTKMKQkFbJwsphcy/FHU2VdZfUI+ XpDZB+pCo+tQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2020 07:20:42 -0700 IronPort-SDR: mO38R1maFkib1SdrUsX0HWs8Vw3B/ZtvYR1Ybw4qD3aiKY/7Kd/Fi5SZvpP3im6v+BT3GYMZKC 5eL6Ra6rNGaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,433,1583222400"; d="scan'208";a="441745623" Received: from linux.intel.com ([10.54.29.200]) by orsmga005.jf.intel.com with ESMTP; 25 May 2020 07:20:42 -0700 Received: from [10.249.227.191] (abudanko-mobl.ccr.corp.intel.com [10.249.227.191]) by linux.intel.com (Postfix) with ESMTP id E5E64580101; Mon, 25 May 2020 07:20:39 -0700 (PDT) Subject: [PATCH v4 05/10] 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: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> Organization: Intel Corp. Message-ID: Date: Mon, 25 May 2020 17:20:38 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> 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 3fb5028aef08..b4d2434584f5 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -226,8 +226,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 ef2682a87491..70b48a279b75 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) @@ -1001,8 +1011,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, "topdown", &topdown_run, 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 a5604a20bdca..b00d64f0ca26 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -114,7 +114,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