Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp53843ybj; Wed, 6 May 2020 11:23:17 -0700 (PDT) X-Google-Smtp-Source: APiQypL2lZTrzgk8NlzEQJwkD2eCg2yHMAObsB9pGXSm4T5XXkaBh4dg8hdjegMNO+lEG7dLeGGX X-Received: by 2002:aa7:d143:: with SMTP id r3mr7724273edo.147.1588789397387; Wed, 06 May 2020 11:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588789397; cv=none; d=google.com; s=arc-20160816; b=iR750fNwaJ5c4jFtBL3NeCcauiFN4NfDIGVf81WWkqZvCnAGmxKy+BQdJmPx40OCTR N5HCy78LtBJn3/AsmHtiuU1W+hx3S1A0GjTIjVYjt5Gq7/ZcdC2wKaovRt61Pw/n0esA p5KGUJS+yMJmvO4X7sXWMv9AhGHVEqYpMk39gGfHfF6XBoUQn1sb08gxNBKiqKAnxsZK g1vOhijBsLx3t2wqryjeAg1u3NknkRsUY+pV2R65hH/h+vbGKze6i5qduM3532S8UTlP ti9TihYMtJK0y0UGg7H7cGfFUmsclpdQnWbfpraYulMJM2tSJSuMrEdFlbJer8z+2rRS b7KQ== 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=TCEQZlZNSG041XNF6YNIOJXrMGuwjWWPvEJXPLEJvK0=; b=hufUTXUGE4WAoZzuQZU8OmeyHQvso3A24n8pSDtZE6hEvTyx68SaU4abtRpiWQbWhk OUmKJufP+nq4Gz4C9KNZf5Z+Ru8/gnTqgSCA26RrYUHh6h5LZFoPfv4GmIxS1x2N4gX3 xS1FpVGOAgSn9GyyFjBqZiM18AZPvZCjQHXdRcRqCno7MOreg2xdjouhT2pF5XYDarqS 9J6RE9cEbZvYGd9MRnFtPDQJR5Rq0U0M7Gv7yo0OVvFk3pPS72lIE4Aatg2RA6tEpbTL RX/35ordofXkELaCXW/m1PBYZDMkGNWRWCyB7scgV7eMWr0B7tsNCzUzBZ/FGkStzQ6q taoQ== 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 a11si1692849ejr.86.2020.05.06.11.22.53; Wed, 06 May 2020 11:23:17 -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 S1730084AbgEFSU6 (ORCPT + 99 others); Wed, 6 May 2020 14:20:58 -0400 Received: from mga09.intel.com ([134.134.136.24]:45742 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729757AbgEFSU6 (ORCPT ); Wed, 6 May 2020 14:20:58 -0400 IronPort-SDR: 1ns3Uh9GibrGlVxCBfZ3PkZ0OQUV86FZfLNGaFY7uebvmVwlwJKOv27niAtS1+ZXDGA00NmRoX C/6x1O274Y0w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2020 11:20:57 -0700 IronPort-SDR: HCPTaO2Hwj49m6PtKDn0xkScq8UN+38Fy94ZSIF4qlGOEofq+QuFwChFSp2Epl3v4hcmO0OSaQ Ozn36vM3hKzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,360,1583222400"; d="scan'208";a="263650013" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 06 May 2020 11:20:57 -0700 Received: from [10.249.228.227] (abudanko-mobl.ccr.corp.intel.com [10.249.228.227]) by linux.intel.com (Postfix) with ESMTP id 531B258043A; Wed, 6 May 2020 11:20:55 -0700 (PDT) Subject: [PATCH v2 04/11] perf stat: extend -D,--delay option with -1 value From: Alexey Budankov To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: Organization: Intel Corp. Message-ID: Date: Wed, 6 May 2020 21:20:54 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 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/builtin-stat.c | 18 ++++++++++++++---- tools/perf/util/evlist.h | 3 +++ tools/perf/util/stat.h | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 9775b0905146..bda777ca0420 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -383,16 +383,26 @@ static bool print_interval_and_stop(struct perf_stat_config *config, int *times) static void enable_counters(void) { - if (stat_config.initial_delay) + if (stat_config.initial_delay < 0) { + pr_info(PERF_EVLIST__DISABLED_MSG); + return; + } + + if (stat_config.initial_delay > 0) { + pr_info(PERF_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(PERF_EVLIST__ENABLED_MSG); + } } static void disable_counters(void) @@ -929,8 +939,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 84386850c290..874ecf068ac9 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -366,6 +366,9 @@ enum evlist_ctl_cmd { CTL_CMD_ACK = 'a' }; +#define PERF_EVLIST__ENABLED_MSG "Events enabled\n" +#define PERF_EVLIST__DISABLED_MSG "Events disabled\n" + int perf_evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack); int perf_evlist__finalize_ctlfd(struct evlist *evlist); int perf_evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd); diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index b4fdfaa7f2c0..027b9dcd902f 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -113,7 +113,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