Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp345617ybj; Wed, 6 May 2020 19:34:04 -0700 (PDT) X-Google-Smtp-Source: APiQypI+/lWoJjqhuycfjKv1SWBWw9v7o3aay5FT4oK3PRRKV0uhbHJhwoEvpCOvdoLv5MsHWDEh X-Received: by 2002:a05:6402:1297:: with SMTP id w23mr9691157edv.151.1588818844656; Wed, 06 May 2020 19:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588818844; cv=none; d=google.com; s=arc-20160816; b=pJlsvZE3gfz2wSpq84gTdIxt2Nkfuu7dK6jYa2QpCvJcKxOEU/dpE4Gl4e0MrJ/aKG xuiK9qVGfEMLByl/ywodU0nJo5ljXU4tX0e7uiPho91GbVlnWgpkj0qa/13KhyOLcavz okncig5VuoB0rL75+BYOQxAYg0QZ95sOZBAClLjZ+ggHqhBm8feVpp3kCuw452mvPh9w hUMfiKLBr6Pt0emF2ugY7O+//Sx8dSEy0sDiNnR3IlKQln/HNUmcpD08ajl9HpyWgB8Y I71IHaoVOqNFEbFiPRYyCcKykr+eT8rwB5h5vJ2DFTGpO3KqF55oqJruTBBd2l1W8gXA Ivxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=k414qEkE1koGztu5deC7f6jgOAvDHF8T2zRYZJkJcCk=; b=TkrsDclbrDprD4TBKHZEs1bK48w9TvrM7tGU70b5TiMycoQarDkzaANMEA1CSwJt+o 9w7nw4QYFaiyzcm0W9Uii5yRB8O6SO/bnOe9/X0mN+Lgt1lA7JoyLltmh5byTQQQV4ms 627JtTPf5gaWAZLwRVNJb2tZHw82GIDu3qzp4lK36o1tqJq5En6x2T88g5w4lXw9tHU2 EGsAtx25XVJ++pmHMu/seGUeTJ9X8go3tLr0iBj3LgF9YeYsdo3upDw2DgotNkXFwM6F ZpB1kxGN0z4ZvOX9FFZwlgY8dwI07YsTw06ex/uyZyBNc1S+sWsfZ//6rfArn5F+gX3v vQJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="DQ/j9hbU"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si2325930ejx.280.2020.05.06.19.33.41; Wed, 06 May 2020 19:34:04 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="DQ/j9hbU"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728447AbgEFUMd (ORCPT + 99 others); Wed, 6 May 2020 16:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728051AbgEFUMc (ORCPT ); Wed, 6 May 2020 16:12:32 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7D7C061A0F for ; Wed, 6 May 2020 13:12:31 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id c10so3565460qka.4 for ; Wed, 06 May 2020 13:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=k414qEkE1koGztu5deC7f6jgOAvDHF8T2zRYZJkJcCk=; b=DQ/j9hbUy+DhJjRztAg24/ym4bvqAgteqV5CxDV//h6NVv/dpm7IPBr0HE1DfJeEkc /1rpcK1yxRK8bgq6RtIU+65HRzBtHbERd+dVYjRUgyEEzoUaiiUsXFip1DWna9bX9REr 7pj2lFCRQI0HnZ8s3NlZfFv9OxLX4q7ABQpe4BME6bhOfzRLuk81iMRpWVc8mRLcMdA9 a5IXeo/sY9N1w8ha8lH3zIpdurGWsrNrDWmHhesYmlV9Q0V0L306Xx5V130Hz0B390wF BtZrG+265d5KlYHMswQTgQ+PvgFpDiFFtCJnmL1NvlDw0dy11WFm4OeNrVXVM4iuckNa JWgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=k414qEkE1koGztu5deC7f6jgOAvDHF8T2zRYZJkJcCk=; b=kLxYebU57XlqzazgBpoPa48K0lbn7JddWUWaZnOQ2aHVcrRcAz+LmkDzY7GUJOU3aQ rPuOfjcKeMk98VmIybfXGE5LaWZnf6DWliqzRlvUNOrgVhlwc3MvOf9db3lphf5H2NxP JxV+2M6qgb0DWDhwqTAEYIkFPK71rf85al3NPIrCkLLuQ4QnUphi+j5uIkxScFoOYw1T GZfO3ea+yd5nf+GNL9L7s72kxblpgkQWRB5wnNDLPbhJhqyN3soqDtDC/r/FvsG1GLfJ q/x6vIJUMaJNBoqGXAFGGVyBNv16VfAV6rXTalJNBV44jN3Ae2VWlySk3uwadYntan7G 2pFA== X-Gm-Message-State: AGi0PuZG9pzQSoay2zQidtUcupL+Od6vXpFwUKkZqh4hUDy3QJ8iMNRk 79INVH9b27S9YOmeoGOQ29m/U8VzIOc= X-Received: by 2002:a37:58c1:: with SMTP id m184mr10924577qkb.83.1588795950084; Wed, 06 May 2020 13:12:30 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.37.151]) by smtp.gmail.com with ESMTPSA id c19sm2258835qtn.94.2020.05.06.13.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 13:12:29 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2464E409A3; Wed, 6 May 2020 17:12:27 -0300 (-03) Date: Wed, 6 May 2020 17:12:27 -0300 To: Alexey Budankov Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v2 04/11] perf stat: extend -D,--delay option with -1 value Message-ID: <20200506201227.GE9893@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, May 06, 2020 at 09:20:54PM +0300, Alexey Budankov escreveu: > > 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 +- You forgot to update tools/perf/Documentation/perf-stat.h > 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 > > -- - Arnaldo