Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp323376ybt; Wed, 17 Jun 2020 01:43:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKdjnumPm3Ds7Tg+sygsHMw6NLPvWSfjbgnmzxzqVYN9gUGiY3hE53ss2r50rVGdVH0B6J X-Received: by 2002:a17:906:a2c2:: with SMTP id by2mr6468703ejb.454.1592383385509; Wed, 17 Jun 2020 01:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592383385; cv=none; d=google.com; s=arc-20160816; b=YTx6vsSPYH8VFftuS5ZztCTjYR1+7QPzUvdO+ydI6KVmsmgyYql03BcrwIa2mxmUgH 0y1G77k7YTOrVdkInzBvMYtM0cih1mfB2DdoqUy/4sffJiHiPxOS/MD7FHo6/7PIXJLy Gt04udsCEzpegDdU1LZxvh6BN9QEbVqqmreyE1c9MSeqkalwKi8wqqNU2CVy+bv/xwpD sizc58y7VLo+IU21AGzSQsRuRhPEvXoV6VaXyYqqRXeCkKXr/uXhLpHwtVr/zWAnU+CT MszdPezBBY7rR9CNaFM3z9jhTk4F+J9JgSbOehAaZ5379TG5i0yFa6qe70yDudUw9JCd tfOQ== 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=PYel4CpDV6p7PWv+FeX61HVOlHLU0uOWDxYNi/haa7U=; b=uCIHCZDA6UBaDT+PMixgAH72NNR0Gwc0cHJT17N/fK4JJ9lN4S067LQK4f2uTAovsT zzvfdJndqOkJCVPXnOHv792R5KCzo7iQ728AA3W7WhtkvsU8i5BYYKUpAt4TApBpVwD3 GKbt2Zn62QRodE+UjqzTYigQa0JXkl1r8CKwu9Gv98WWlUejx8Ju6TTdWXgnR0DrDnmB ye4Ay1ZLsOYZnD71zUrHKCjqd91F7lA01FWay8rEfvM8t+3g9ZM79K7vDBFMf3iIHAbs I967GCm5Ejh8YW1E80duFEoDJdfeYB+3+oVnotl/x+gqkdonmWJCiXgFCUc6HKgRgtqf Q85Q== 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 f12si12426949edl.157.2020.06.17.01.42.42; Wed, 17 Jun 2020 01:43:05 -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 S1726688AbgFQIkv (ORCPT + 99 others); Wed, 17 Jun 2020 04:40:51 -0400 Received: from mga03.intel.com ([134.134.136.65]:55161 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbgFQIkv (ORCPT ); Wed, 17 Jun 2020 04:40:51 -0400 IronPort-SDR: 0KpBszN8KlwMazYkKgzb/Dfbkgdx/7V27Q2V662EAe23+zi//K7BsO1kGQ/Rw8H7Dp/iCS/LsH xXQX8mQvvbMg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2020 01:40:50 -0700 IronPort-SDR: XecbNr9oMhQT9id9eoiKcoKEH1X69lOMvLnn8wFFi5sF79Kw/PeYmo9mxf8WRE76PISVDQ2Axh qOzJ2fkJhz+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,522,1583222400"; d="scan'208";a="352013850" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 17 Jun 2020 01:40:50 -0700 Received: from [10.249.225.191] (abudanko-mobl.ccr.corp.intel.com [10.249.225.191]) by linux.intel.com (Postfix) with ESMTP id 54BB1580223; Wed, 17 Jun 2020 01:40:48 -0700 (PDT) Subject: [PATCH v8 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: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> Organization: Intel Corp. Message-ID: <0c521b60-720d-4ecf-31d4-6a949870ede0@linux.intel.com> Date: Wed, 17 Jun 2020 11:40:47 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <0781a077-aa82-5b4a-273e-c17372a72b93@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 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 39749c290508..f88d5ee55022 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -494,16 +494,26 @@ static bool process_timeout(int 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) @@ -1060,8 +1070,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