Received: by 10.213.65.68 with SMTP id h4csp3697822imn; Tue, 10 Apr 2018 03:18:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/M4cL5wicRXFPZHip0DE7xnABqLVCD7PNoRLeil/RvgbEPyoQ1K7UsgmyDGwIK2cSeW4Kg X-Received: by 10.98.234.13 with SMTP id t13mr2263373pfh.56.1523355529367; Tue, 10 Apr 2018 03:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523355529; cv=none; d=google.com; s=arc-20160816; b=RkMzTqTjPqxH9lG9IyAqnB8KGb4KZWI+Qb8tLykwkotI/qdV46T0bgkB++bNBid43/ 3tnpPafzyodv4m8B8uQqdd3vh5uRFlekxWkXqRO1NMy+yifiPG3fLZKMiAbldDUb0dzd w0EYzkP2+unIXv/4N6/wV1o5gi1+M1m8KnTun66fSGYq9CQBr8t5mZGraWKFvCGXSz/b VszXhzSSQh7bohjd6O0zhIpTAEHRzvX1rQPoI6Wvkty72JG3K47+sXT+noQnNuKHg8Ng PrKxE7g6W9Mi/F4lIyrMSjGtkb7/gZRVD48Ca4VwIWdeAB7w6MDFA+BkjgTIr60kulqc 8FIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8K45lBf1povItpgoWg574+imRh59juL5d6WO2UEIG1U=; b=iLQK1jXPVTzpizAqdKqLQJSuNu4viZEHL0vGA2Ul0s9gkK4dIPo/kXNxIsITRL32pb FkDXwBHXejIgJybfWUhlKPfwzecDyZTsq0o371Q2NAWG4zr2xUUa9CMetahGlw3QNsR9 xjuQtXskNqTsv8YwlNCZoLLR7FOWxhT+0Ts75l21/tdBQUKjlXS+aA9wjvYYfCzHH89w ZtHmFitWEXHia1Mg7itXDUq8bZXCiC9F5U9GKrJeY+qNcszXPPbSKStbxglS0yDK6rCE Fml/aXQs1gvzoYTySgZ1DXkuA6N09kMMspxnbWbQjPhAUe6qRHm5gnRVIYIsZGbcctiI PbbA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si1847632pfv.115.2018.04.10.03.18.12; Tue, 10 Apr 2018 03:18:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752693AbeDJKP3 (ORCPT + 99 others); Tue, 10 Apr 2018 06:15:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:27012 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbeDJKP2 (ORCPT ); Tue, 10 Apr 2018 06:15:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2018 03:15:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,431,1517904000"; d="scan'208";a="45674737" Received: from yu-chen.sh.intel.com ([10.239.160.138]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2018 03:15:26 -0700 From: Yu Chen To: Len Brown Cc: "Rafael J . Wysocki" , Artem Bityutskiy , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH][RFC] tools/power turbostat: if --max_loop, print for specific time of loops Date: Tue, 10 Apr 2018 18:18:31 +0800 Message-Id: <20180410101831.28530-1-yu.c.chen@intel.com> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen Yu There's a use case during test to only print specific round of loops if --interval is specified, for example, with this patch applied: turbostat -i 5 --max_loops 4 will capture 4 samples with 5 seconds interval. Signed-off-by: Chen Yu --- tools/power/x86/turbostat/turbostat.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index bd9c6b31a504..a35418a59468 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -48,6 +48,7 @@ char *proc_stat = "/proc/stat"; FILE *outf; int *fd_percpu; struct timespec interval_ts = {5, 0}; +unsigned int max_loops; unsigned int debug; unsigned int quiet; unsigned int sums_need_wide_columns; @@ -470,6 +471,7 @@ void help(void) " {core | package | j,k,l..m,n-p }\n" "--quiet skip decoding system configuration header\n" "--interval sec Override default 5-second measurement interval\n" + "--max_loops times The number of loops if interval is specified\n" "--help print this help message\n" "--list list column headers only\n" "--out file create or truncate \"file\" for all output\n" @@ -2565,6 +2567,7 @@ void turbostat_loop() { int retval; int restarted = 0; + int loops = 0; restart: restarted++; @@ -2583,6 +2586,7 @@ void turbostat_loop() restarted = 0; gettimeofday(&tv_even, (struct timezone *)NULL); + loops = 0; while (1) { if (for_all_proc_cpus(cpu_is_not_present)) { re_initialize(); @@ -2626,6 +2630,9 @@ void turbostat_loop() compute_average(ODD_COUNTERS); format_all_counters(ODD_COUNTERS); flush_output_stdout(); + + if (++loops >= (max_loops/2)) + break; } } @@ -5009,12 +5016,13 @@ void cmdline(int argc, char **argv) {"Summary", no_argument, 0, 'S'}, {"TCC", required_argument, 0, 'T'}, {"version", no_argument, 0, 'v' }, + {"max_loops", required_argument, 0, 'x'}, {0, 0, 0, 0 } }; progname = argv[0]; - while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:o:qST:v", + while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:o:qST:vx:", long_options, &option_index)) != -1) { switch (opt) { case 'a': @@ -5076,6 +5084,15 @@ void cmdline(int argc, char **argv) print_version(); exit(0); break; + case 'x': + { + unsigned int loops = strtod(optarg, NULL); + + if (loops % 2) + loops++; + max_loops = loops; + } + break; } } } -- 2.13.6