Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp70013imm; Wed, 5 Sep 2018 15:09:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYee0QiJbM3lR+1TPIi4Vemb6+iPwW2FJth5gCHK1p3Uo8YmPR8mUGMpXLBNvu5NVxzxTcv X-Received: by 2002:a63:de10:: with SMTP id f16-v6mr38457449pgg.97.1536185387428; Wed, 05 Sep 2018 15:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185387; cv=none; d=google.com; s=arc-20160816; b=CiHc4Z9JaS6FpB/LgfdY/EXB4Ag2FU1zEQPlkgd2sWYQJTNWbBCf+S69MK1OMJF+QO 0k+ddBoNxaTwUjljwlyWZR5FNVYnAXFjr+QZMQHNKO+tbCyNySzCIfC33XNCD8jlDpK5 nfEhk1GueMJJWFluu51peaWjokekrIA/DcvoWK6hNLVwVq4g9NN4StxRmTozUnF8RY6r DRgUXX4AYLF+HDsFnO5/EixuvMXYd5CphMB/LU1t6jtMHh/A0qOmT2Rrqi5kzmBaFBDg AEkKjobDCcB1q+/pgS8Q/kfRFHyBrjj+xa17mYmbKTisW2Aa1xVJtJfiAyPvxEqskP5+ icoQ== 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=hXVnFbOtw21e2OLQFxohbKebIi4Foxsjdvi8BiN/zlg=; b=nLCwUQKA3CKduXWTtcFRIDTgAHPYycAOrYHz/GhnoulubNGorYYr0gYtrYQ1Lk1iPO X3/iyq1fK46vAVlBWs58Tb8Jyk8b2Cw6GjcSb90EkZJkZUAHqxN3fuGeK5trAcCH3yXG +nJSeLtIJHqgplasUKrBfyJ66uPaX2yLKMx0RABZqhrQkHXl3M7ah7HBkRTbxXIMHrRj CjUrOOuGYUNqhZTR0mQYzT1jRUzIM5gVGWotyRQOM0C2tJCdVM8OaP9tRk172OcC4BnF AysbHRBr7+Az0BpKxTOfD53QlxwybdvBls+dC1TSGUvzozSKpAib/XMrXdmv0RWglKgg k/vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JQB8Lfld; 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 r7-v6si3130673pgh.473.2018.09.05.15.09.32; Wed, 05 Sep 2018 15:09:47 -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=JQB8Lfld; 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 S1728943AbeIFCju (ORCPT + 99 others); Wed, 5 Sep 2018 22:39:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727586AbeIFCjt (ORCPT ); Wed, 5 Sep 2018 22:39:49 -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 0D6AF20869; Wed, 5 Sep 2018 22:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185257; bh=zHR+oSQvSTNob/LgsxOREkA3+72gC8K3t2mDt+03Rc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQB8LfldUWnQ3gZYyrr+XgFD3kjKZ5sZzyWb3IDIXSIwCF2T7kQun/YZr25UUktPV M0jUnAfG+vTo0KfkoxBB1XFDgfFiWvuSwpEyvK2KykTo9law1+DTJo0a7Sb7hEhmO6 lntYGL7+wuIZmWypHIXyZEb0eHN5X6uBckZ1WEWs= 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 60/77] perf stat: Move ru_* data to 'struct perf_stat_config' Date: Wed, 5 Sep 2018 19:04:23 -0300 Message-Id: <20180905220440.20256-61-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 'ru_*' global variables to 'struct perf_stat_config', so that 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-36-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 12 +++++------- tools/perf/util/stat.h | 6 ++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index f61c2dc8c7e8..942ebfd8ef2e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -171,8 +171,6 @@ static bool interval_count; static const char *output_name; static int output_fd; static u64 *walltime_run; -static bool ru_display = false; -static struct rusage ru_data; struct perf_stat { bool record; @@ -583,7 +581,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) break; } } - wait4(child_pid, &status, 0, &ru_data); + wait4(child_pid, &status, 0, &stat_config.ru_data); if (workload_exec_errno) { const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); @@ -1679,9 +1677,9 @@ static void print_footer(struct perf_stat_config *config) if (config->run_count == 1) { fprintf(output, " %17.9f seconds time elapsed", avg); - if (ru_display) { - double ru_utime = timeval2double(&ru_data.ru_utime); - double ru_stime = timeval2double(&ru_data.ru_stime); + if (config->ru_display) { + double ru_utime = timeval2double(&config->ru_data.ru_utime); + double ru_stime = timeval2double(&config->ru_data.ru_stime); fprintf(output, "\n\n"); fprintf(output, " %17.9f seconds user\n", ru_utime); @@ -2855,7 +2853,7 @@ int cmd_stat(int argc, const char **argv) * run and when there's specified tracee. */ if ((stat_config.run_count == 1) && target__none(&target)) - ru_display = true; + stat_config.ru_display = true; if (stat_config.run_count < 0) { pr_err("Run count must be a positive number\n"); diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 6fb4dac26ccc..1fd0b7e196c6 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -4,6 +4,10 @@ #include #include +#include +#include +#include +#include #include "xyarray.h" #include "rblist.h" #include "perf.h" @@ -95,6 +99,7 @@ struct perf_stat_config { bool interval_clear; bool metric_only; bool null_run; + bool ru_display; FILE *output; unsigned int interval; unsigned int timeout; @@ -109,6 +114,7 @@ struct perf_stat_config { int stats_num; const char *csv_sep; struct stats *walltime_nsecs_stats; + struct rusage ru_data; }; void update_stats(struct stats *stats, u64 val); -- 2.14.4