Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp74293imm; Wed, 5 Sep 2018 15:14:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZKd7i+D48473PFGO+G/bB4PMRclU1NjxuFhcFub5nhnRZoPJ+I+pPOhrx6kWaaOdiScyVb X-Received: by 2002:aa7:88d3:: with SMTP id p19-v6mr42971423pfo.160.1536185658333; Wed, 05 Sep 2018 15:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185658; cv=none; d=google.com; s=arc-20160816; b=lr4f4duIxHFRm0qXfxwDMcgMxTrmLNz/jEEAReOMbdetq1z3nZIRy9sDYnfzbDxrrW 8w9bTMlTP56/n6eKpkkOvefCXXQDW874aLtkalc9fSxbIMxoMtk1lHH+Jyo0ncfHpRQ7 c6rHR40SuiurErszJNQ/xna34+xWDVPXBTYV7VJULZzMVcsdJxCp1gt1UgYmpbmC0bKF DrgH9FncdnjV/kaS7M3e4/IHmvXnKBXzT+Zf4LvImMnYj7kbYoNGNDIVZvcye6tUM6hh CSV+wiaWZZPr1inAN/SPlei767VkXBghDfpZHf1r2hGhYsRE8rBLCKTKJuq1n/gYwToy JKjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=h6SigUdD9mf7/hP6pYBxcwOW/NV/6U43y4FKPtG4wPk=; b=J8wpJzlQWh4CQipswVWOj0AStV6fNE3ped985pzgBT+p6V3p8HZ8g6X9Qd0tmwpVxb e3mZHkHPZEU+lTdVUsAnBsjp4UPJ9bh8u4J56VYI7vDN5QaofNwbMWCRY3qCDN3rtcFh EoD9JxV3ADeTvomMh++sUYHW5cFXS7Jz7tGqGfmsRC6DksfQtcaXyTm8LCgzFzPxnlgA FWnN9buaeCTo2uEtmIF/RfYySgQOv+xG/vp+DLzM64WZm9UobpWkxStcTh0XaxwE7BIi +Ls1KWlL4GGjs2bpH62B3eyt18mu8rJT0h2BV0bvBVtpgjPX8iK2pI8cRYzwElxbQt2U CS7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iY7xT7mE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z16-v6si3285464pgi.252.2018.09.05.15.14.02; Wed, 05 Sep 2018 15:14:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iY7xT7mE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbeIFCiR (ORCPT + 99 others); Wed, 5 Sep 2018 22:38:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728389AbeIFCiQ (ORCPT ); Wed, 5 Sep 2018 22:38:16 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8EB942083D; Wed, 5 Sep 2018 22:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185164; bh=25N4pgeHbET0RFZc5MyyCHZe+bwDu+ZRHpoxVzTwOuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iY7xT7mEolQvGeLlkXoQoInPa5Y378judqeb3Q/ccfM+T1EKN6suyG0bYhA1KCLdQ 7WkG403vOCeuRn/x2jdVECTd3abpmboa6pgQjbeiTrz90prr0wN6vLC+4tR3LAEXLJ 4UwQamjKVGc+QbchLdLfjd8/ao9gBXIp4wYOu720= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jiri Olsa , Alexander Shishkin , Andi Kleen , David Ahern , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 27/77] perf stat: Move 'initial_delay' to 'struct perf_stat_config' Date: Wed, 5 Sep 2018 19:03:50 -0300 Message-Id: <20180905220440.20256-28-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa Move the static 'initial_delay' variable to 'struct perf_stat_config', so it can be passed around and used outside the 'perf stat' command. Add 'struct perf_stat_config' argument to create_perf_stat_counter() and use its 'initial_delay' member instead of the static one. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20180830063252.23729-3-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 16 ++++++++-------- tools/perf/util/stat.h | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d389ed623715..719abdd3b7de 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -164,7 +164,6 @@ static bool group = false; static const char *pre_cmd = NULL; static const char *post_cmd = NULL; static bool sync_run = false; -static unsigned int initial_delay = 0; static unsigned int unit_width = 4; /* strlen("unit") */ static bool forever = false; static bool metric_only = false; @@ -236,7 +235,8 @@ static void perf_stat__reset_stats(void) perf_stat__reset_shadow_per_stat(&stat_config.stats[i]); } -static int create_perf_stat_counter(struct perf_evsel *evsel) +static int create_perf_stat_counter(struct perf_evsel *evsel, + struct perf_stat_config *config) { struct perf_event_attr *attr = &evsel->attr; struct perf_evsel *leader = evsel->leader; @@ -286,7 +286,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) * In case of initial_delay we enable tracee * events manually. */ - if (target__none(&target) && !initial_delay) + if (target__none(&target) && !config->initial_delay) attr->enable_on_exec = 1; } @@ -428,15 +428,15 @@ static void process_interval(void) static void enable_counters(void) { - if (initial_delay) - usleep(initial_delay * USEC_PER_MSEC); + if (stat_config.initial_delay) + 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) || initial_delay) + if (!target__none(&target) || stat_config.initial_delay) perf_evlist__enable(evsel_list); } @@ -609,7 +609,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) evlist__for_each_entry(evsel_list, counter) { try_again: - if (create_perf_stat_counter(counter) < 0) { + if (create_perf_stat_counter(counter, &stat_config) < 0) { /* Weak group failed. Reset the group. */ if ((errno == EINVAL || errno == EBADF) && @@ -2027,7 +2027,7 @@ static const struct option stat_options[] = { "aggregate counts per physical processor core", AGGR_CORE), OPT_SET_UINT(0, "per-thread", &stat_config.aggr_mode, "aggregate counts per thread", AGGR_THREAD), - OPT_UINTEGER('D', "delay", &initial_delay, + OPT_UINTEGER('D', "delay", &stat_config.initial_delay, "ms to wait before starting measurement after program start"), OPT_CALLBACK_NOOPT(0, "metric-only", &metric_only, NULL, "Only print computed metrics. No raw values", enable_metric_only), diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 36efb986f7fc..91e6609fce6e 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -6,6 +6,7 @@ #include #include "xyarray.h" #include "rblist.h" +#include "perf.h" struct stats { double n, mean, M2; @@ -85,14 +86,15 @@ struct runtime_stat { }; struct perf_stat_config { - enum aggr_mode aggr_mode; - bool scale; - FILE *output; - unsigned int interval; - unsigned int timeout; - int times; - struct runtime_stat *stats; - int stats_num; + enum aggr_mode aggr_mode; + bool scale; + FILE *output; + unsigned int interval; + unsigned int timeout; + unsigned int initial_delay; + int times; + struct runtime_stat *stats; + int stats_num; }; void update_stats(struct stats *stats, u64 val); -- 2.14.4