Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp69395imm; Wed, 5 Sep 2018 15:09:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdarngPbunmSJbQ1EXMjkmprV55bY4e+NLJFnqI2zaqgsKHGeIc62qL6/r6TCsdPLYtyHvlG X-Received: by 2002:a62:45d2:: with SMTP id n79-v6mr42860628pfi.137.1536185349287; Wed, 05 Sep 2018 15:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185349; cv=none; d=google.com; s=arc-20160816; b=cOU0lxbM/IRfFD5c/oPYyMkVO+tQCgVE1LSyx4lbziwS9VSvgGS4Qb6VwuRV42fyOc VGICSOYUbV9iPuJEAPz31Yiy3vdhlIgGcrh6MWkvsCof8nvslnN31W3EcMVFQ7IHTKbg 7F8Wu7V96cNG7Ly4+RhFSdxdtx+lG8yfB03bzSdTZeBMXSd4mkiPuM4LpJgL7K9iQ4G5 hUWlqAON+dHLtG4Pkdi9e7O43qFyLmqph2Z2KZqN/4QKxiFGkgInKvkC0mp93AS089Dl B3+6LeGAkR/GzSFBkXiGb0bBPifBpnD85VnojnPZDl41gCXgp2Q+o+C3d3yn8SyY1T/E xt1g== 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=qNyYe6e/GAsgjWJpae+koShBGxk06WJnVKv8tg1ObTs=; b=IowOOuBdPymeLoO5bY8zcYDS6K9nMQ1+tA/FaSm9Bervj/TdWA1feFz8BYylv/VH+5 O/VouHT9/laQrzCB5VMm7J/coQcbq9jqRVsZRU8z9+iZ3iwhN+Qgd/vNOufvfeYqqRd8 vvJ28uHRqw4mU9X2Yg6XiNu8iIvPasX6uDAjePSYHpM/Nc9R5z0YL4y4FzjN2ZG8u7PK xUwSOUfSkP/pGRkPhQlEmdbYTRYGrH+qJ/MJyKo+0hPpIC5FC5bSOVufUbCASNU7asDg +de5G82zxGqLJ4tBEgqQAARcWug5DQoBstxBu5EJNFDS1dqR6iidJzVT+hvRw9sL4twP 4LLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AB8rRRq/"; 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 p20-v6si2847098pgk.393.2018.09.05.15.08.53; Wed, 05 Sep 2018 15:09:09 -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="AB8rRRq/"; 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 S1728767AbeIFCjQ (ORCPT + 99 others); Wed, 5 Sep 2018 22:39:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727593AbeIFCjP (ORCPT ); Wed, 5 Sep 2018 22:39:15 -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 3A8B020869; Wed, 5 Sep 2018 22:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185223; bh=RZo0ALqNRCBkTQGQx+I9kN8uKtoweeuqexuSr3CQtFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AB8rRRq/SPZlKeKT6ZnA+5OVm5x4hwkfJ877szbr/xRB6Ol8zzhlpR929X1e60OHh EFaerJ+Oi3ricJ8YVyq77/jA2bhJzZB9q8o1Qsj3QGaV/8V5BDpv3Ww8CoxelbE89C J/zhR+tihdsvhioCc7ltK/cVU7Pe3FvQEHch0UV4= 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 48/77] perf stat: Move 'unit_width' to 'struct perf_stat_config' Date: Wed, 5 Sep 2018 19:04:11 -0300 Message-Id: <20180905220440.20256-49-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 'unit_width' variable to 'struct perf_stat_config', so it can be passed around and used outside the '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-24-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 11 ++++++----- tools/perf/util/stat.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 397cb4f28d7f..24171aa6c41f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -161,7 +161,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 unit_width = 4; /* strlen("unit") */ static bool forever = false; static bool force_metric_only = false; static bool no_merge = false; @@ -200,6 +199,7 @@ static volatile int done = 0; static struct perf_stat_config stat_config = { .aggr_mode = AGGR_GLOBAL, .scale = true, + .unit_width = 4, /* strlen("unit") */ }; static bool is_duration_time(struct perf_evsel *evsel) @@ -524,8 +524,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) counter->supported = true; l = strlen(counter->unit); - if (l > unit_width) - unit_width = l; + if (l > stat_config.unit_width) + stat_config.unit_width = l; if (perf_evsel__should_store_id(counter) && perf_evsel__store_ids(counter, evsel_list)) @@ -963,7 +963,7 @@ static void abs_printout(struct perf_stat_config *config, if (evsel->unit) fprintf(output, "%-*s%s", - config->csv_output ? 0 : unit_width, + config->csv_output ? 0 : config->unit_width, evsel->unit, config->csv_sep); fprintf(output, "%-*s", config->csv_output ? 0 : 25, perf_evsel__name(evsel)); @@ -1056,7 +1056,7 @@ static void printout(struct perf_stat_config *config, int id, int nr, } fprintf(config->output, "%-*s%s", - config->csv_output ? 0 : unit_width, + config->csv_output ? 0 : config->unit_width, counter->unit, config->csv_sep); fprintf(config->output, "%*s", @@ -1542,6 +1542,7 @@ static void print_interval(struct perf_stat_config *config, char *prefix, struct timespec *ts) { bool metric_only = config->metric_only; + unsigned int unit_width = config->unit_width; FILE *output = config->output; static int num_print_interval; diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index da838182b99c..2dc66e0ba4b8 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -98,6 +98,7 @@ struct perf_stat_config { unsigned int interval; unsigned int timeout; unsigned int initial_delay; + unsigned int unit_width; int times; struct runtime_stat *stats; int stats_num; -- 2.14.4