Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp70719imm; Wed, 5 Sep 2018 15:10:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZWPv3mJtKTMwET0AfgWjOoRwueX25BaLP8636CtmbqMBcQGSo7I1L+jj0jEV7P36Jlz6O8 X-Received: by 2002:a62:219b:: with SMTP id o27-v6mr42464722pfj.235.1536185431872; Wed, 05 Sep 2018 15:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185431; cv=none; d=google.com; s=arc-20160816; b=fjT5gE1M1+5bxr+gUKo7A1EHG1vY+5Tz5ro01oODMoEVtx+1YvvOArS3ysBaorS1NG +D/r3z7kkF9Y3hd/8Na7cVUeVjH/9QzhJTMYj+83JU3dgG/yc9JstFnAtwz6/43IeP6X LXG6hcmku4KStb23L77ebgUlsDkDZuYiXF4UGqgwRi5oR4Q7G90hVymCS/utLJ+bn5Ur 1+QYBjWQg0m9HJvQ3nUquziy0nAlKjvjDclUTIv3w/lyTWclVm5LbXw7cI3+e9eem6Ny FNy2lMsYVvVLxmiquOUrebdUrotAZcwR9UpnARQaHYUeK3Oskv/iVWea3bh5rJoagUcq cYAA== 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=TVsQPZCPAOyzPCULVcGhXblH9KemAnd4cmdz6v74lms=; b=WtGm7w03tRroQkEnAtkaJ/ILOZ+WU3Y3SUSB/4my7HCiojFHytvVjY5uw7+FmJiVGD uh+zJ0vDcUTemEHC+mxitW2NERPXh9l3AJG6HGsPys8ehm/MYvrjAxx6eeZNyEaewvJW iZBf+hlqH+uPNK9nR/H2m+mKxDkvh31SPm5EusfsSuTdeKJu9Gcgm0G9TvRkS/AOjgCx OYxeDZou+4mzmoQC3ASfDLOFgL6LcL2DZA3t74Vfuh+nv4c8eIXLQJ4p7iksoiNhwbff 99T5rFJZHNToTuVjJCynSAEfhk3wZeQbBEp123IumjoEUtJ4JWXZbrkZhRx8TY7oblVp E+4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rcVzZQ5O; 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 i9-v6si3119523pgk.403.2018.09.05.15.10.16; Wed, 05 Sep 2018 15:10:31 -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=rcVzZQ5O; 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 S1729022AbeIFCkI (ORCPT + 99 others); Wed, 5 Sep 2018 22:40:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:55150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727586AbeIFCkH (ORCPT ); Wed, 5 Sep 2018 22:40:07 -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 92F5820839; Wed, 5 Sep 2018 22:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185275; bh=CNI5LzmQOIMnRIgekWN+NG6dfGZMHOUxTHTcmc05tCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rcVzZQ5OTwxyJPshVfI3S7N4uocz34idaUfZANsTVj6R3/y9tdZSx9NTKBOe26XNx d4iukSYgfQvLrqVHj9tYMLrwJ/3TXvLCHLDwjCq0+aTQWcHzSbd6DgFhI1g0+sai7H YpEqgx4awcJAScQYxPVKhjN/12fFgKyjORSEjGMg= 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 66/77] perf stat: Move 'walltime_*' data to 'struct perf_stat_config' Date: Wed, 5 Sep 2018 19:04:29 -0300 Message-Id: <20180905220440.20256-67-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 variables 'walltime_*' to 'struct perf_stat_config', so that it can be passed around and used outside 'perf stat' command. 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-42-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 22 ++++++++++------------ tools/perf/util/stat.h | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 486b0cf7818d..8a4979748cbb 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -158,13 +158,11 @@ static const char *post_cmd = NULL; static bool sync_run = false; static bool forever = false; static bool force_metric_only = false; -static bool walltime_run_table = false; static struct timespec ref_time; static bool append_file; static bool interval_count; static const char *output_name; static int output_fd; -static u64 *walltime_run; struct perf_stat { bool record; @@ -604,8 +602,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) t1 = rdclock(); - if (walltime_run_table) - walltime_run[run_idx] = t1 - t0; + if (stat_config.walltime_run_table) + stat_config.walltime_run[run_idx] = t1 - t0; update_stats(&walltime_nsecs_stats, t1 - t0); @@ -1646,7 +1644,7 @@ static void print_table(struct perf_stat_config *config, fprintf(output, "%*s# Table of individual measurements:\n", indent, ""); for (idx = 0; idx < config->run_count; idx++) { - double run = (double) walltime_run[idx] / NSEC_PER_SEC; + double run = (double) config->walltime_run[idx] / NSEC_PER_SEC; int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5); fprintf(output, " %17.*f (%+.*f) ", @@ -1694,7 +1692,7 @@ static void print_footer(struct perf_stat_config *config) */ int precision = get_precision(sd) + 2; - if (walltime_run_table) + if (config->walltime_run_table) print_table(config, output, precision, avg); fprintf(output, " %17.*f +- %.*f seconds time elapsed", @@ -1888,7 +1886,7 @@ static const struct option stat_options[] = { "be more verbose (show counter open errors, etc)"), OPT_INTEGER('r', "repeat", &stat_config.run_count, "repeat command and print average + stddev (max: 100, forever: 0)"), - OPT_BOOLEAN(0, "table", &walltime_run_table, + OPT_BOOLEAN(0, "table", &stat_config.walltime_run_table, "display details about each run (only with -r option)"), OPT_BOOLEAN('n', "null", &stat_config.null_run, "null run - dont start any counters"), @@ -2802,7 +2800,7 @@ int cmd_stat(int argc, const char **argv) goto out; } - if (walltime_run_table && stat_config.run_count <= 1) { + if (stat_config.walltime_run_table && stat_config.run_count <= 1) { fprintf(stderr, "--table is only supported with -r\n"); parse_options_usage(stat_usage, stat_options, "r", 1); parse_options_usage(NULL, stat_options, "table", 0); @@ -2870,9 +2868,9 @@ int cmd_stat(int argc, const char **argv) stat_config.run_count = 1; } - if (walltime_run_table) { - walltime_run = zalloc(stat_config.run_count * sizeof(walltime_run[0])); - if (!walltime_run) { + if (stat_config.walltime_run_table) { + stat_config.walltime_run = zalloc(stat_config.run_count * sizeof(stat_config.walltime_run[0])); + if (!stat_config.walltime_run) { pr_err("failed to setup -r option"); goto out; } @@ -3052,7 +3050,7 @@ int cmd_stat(int argc, const char **argv) perf_stat__exit_aggr_mode(); perf_evlist__free_stats(evsel_list); out: - free(walltime_run); + free(stat_config.walltime_run); if (smi_cost && smi_reset) sysfs__write_int(FREEZE_ON_SMI_PATH, 0); diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 0758107fe56f..5193cbf6e4c6 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -105,6 +105,7 @@ struct perf_stat_config { bool ru_display; bool big_num; bool no_merge; + bool walltime_run_table; FILE *output; unsigned int interval; unsigned int timeout; @@ -123,6 +124,7 @@ struct perf_stat_config { struct cpu_map *aggr_map; aggr_get_id_t aggr_get_id; struct cpu_map *cpus_aggr_map; + u64 *walltime_run; }; void update_stats(struct stats *stats, u64 val); -- 2.14.4