From: Len Brown <lenb@kernel.org>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>
Subject: [PATCH 39/44] tools/power turbostat: support "--hide C1" etc.
Date: Wed, 1 Mar 2017 00:27:43 -0500 [thread overview]
Message-ID: <dd778a5e6bbd0f52f34c61ae9b42b725c5f22398.1488345270.git.len.brown@intel.com> (raw)
In-Reply-To: <20170301052748.27810-1-lenb@kernel.org>
In-Reply-To: <678a3bd1b3de6d2ebf604e7d708bc8150bb667e9.1488345270.git.len.brown@intel.com>
From: Len Brown <len.brown@intel.com>
Originally, the only way to hide the sysfs C-state statistics columns
was with "--hide sysfs". This was because we process "--hide" before
we probe for those columns.
hack --hide to remember deferred hide requests, and apply
them when sysfs is probed.
"--hide sysfs" is still available as short-hand to refer to
the entire group of counters.
The down-side of this change is that we no longer error check for
bogus --hide column names. But the user will quickly figure that
out if a column they mean to hide is still there...
Signed-off-by: Len Brown <len.brown@intel.com>
---
tools/power/x86/turbostat/turbostat.8 | 2 +-
tools/power/x86/turbostat/turbostat.c | 115 +++++++++++++++++++++-------------
2 files changed, 73 insertions(+), 44 deletions(-)
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index 5189d9d982fe..fedca3285326 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -114,7 +114,7 @@ This is ideal for remote debugging, use the "--out" option to save everything to
.PP
When you are not interested in all that information, and there are several ways to see only what you want. First the "--quiet" option will skip the configuration information, and turbostat will show only the counter columns. Second, you can reduce the columns with the "--hide" and "--show" options. If you use the "--show" option, then turbostat will show only the columns you list. If you use the "--hide" option, turbostat will show all columns, except the ones you list.
.PP
-To find out what columns are available for --show and --hide, the "--list" option is available. Note, however, there is an exception. The C-state columns collected from sysfs "C1,C2,C3,C1%,C2%,C3%" are not built-in counters, but are discovered after --show and --hide are processed. You can use the special counter name "sysfs" to refer to all of them at the same time.
+To find out what columns are available for --show and --hide, the "--list" option is available. For convenience, the special strings "sysfs" can be used to refer to all of the sysfs C-state counters at once:
.nf
sudo ./turbostat --show sysfs --quiet sleep 10
10.003837 sec
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index c005d9052679..596259f48f50 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -434,12 +434,45 @@ unsigned long long bic_present = BIC_sysfs;
#define BIC_PRESENT(COUNTER_BIT) (bic_present |= COUNTER_BIT)
#define BIC_NOT_PRESENT(COUNTER_BIT) (bic_present &= ~COUNTER_BIT)
+#define MAX_DEFERRED 16
+char *deferred_skip_names[MAX_DEFERRED];
+int deferred_skip_index;
+
+/*
+ * HIDE_LIST - hide this list of counters, show the rest [default]
+ * SHOW_LIST - show this list of counters, hide the rest
+ */
+enum show_hide_mode { SHOW_LIST, HIDE_LIST } global_show_hide_mode = HIDE_LIST;
+
+void help(void)
+{
+ fprintf(outf,
+ "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n"
+ "\n"
+ "Turbostat forks the specified COMMAND and prints statistics\n"
+ "when COMMAND completes.\n"
+ "If no COMMAND is specified, turbostat wakes every 5-seconds\n"
+ "to print statistics, until interrupted.\n"
+ "--add add a counter\n"
+ " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n"
+ "--cpu cpu-set limit output to summary plus cpu-set:\n"
+ " {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"
+ "--help print this help message\n"
+ "--list list column headers only\n"
+ "--out file create or truncate \"file\" for all output\n"
+ "--version print version information\n"
+ "\n"
+ "For more help, run \"man turbostat\"\n");
+}
+
/*
* bic_lookup
* for all the strings in comma separate name_list,
* set the approprate bit in return value.
*/
-unsigned long long bic_lookup(char *name_list)
+unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode)
{
int i;
unsigned long long retval = 0;
@@ -459,8 +492,19 @@ unsigned long long bic_lookup(char *name_list)
}
}
if (i == MAX_BIC) {
- fprintf(stderr, "Invalid counter name: %s\n", name_list);
- exit(-1);
+ if (mode == SHOW_LIST) {
+ fprintf(stderr, "Invalid counter name: %s\n", name_list);
+ exit(-1);
+ }
+ deferred_skip_names[deferred_skip_index++] = name_list;
+ if (debug)
+ fprintf(stderr, "deferred \"%s\"\n", name_list);
+ if (deferred_skip_index >= MAX_DEFERRED) {
+ fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n",
+ MAX_DEFERRED, name_list);
+ help();
+ exit(1);
+ }
}
name_list = comma;
@@ -471,6 +515,7 @@ unsigned long long bic_lookup(char *name_list)
return retval;
}
+
void print_header(char *delim)
{
struct msr_counter *mp;
@@ -502,20 +547,17 @@ void print_header(char *delim)
outp += sprintf(outp, "%sSMI", (printed++ ? delim : ""));
for (mp = sys.tp; mp; mp = mp->next) {
- if (*delim == ',') {
- outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), "sysfs");
- break;
- }
+
if (mp->format == FORMAT_RAW) {
if (mp->width == 64)
- outp += sprintf(outp, "%s%18.18s", delim, mp->name);
+ outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name);
else
- outp += sprintf(outp, "%s%10.10s", delim, mp->name);
+ outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), mp->name);
} else {
if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns)
- outp += sprintf(outp, "%s%8s", delim, mp->name);
+ outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), mp->name);
else
- outp += sprintf(outp, "%s%s", delim, mp->name);
+ outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), mp->name);
}
}
@@ -4142,29 +4184,6 @@ void process_cpuid()
return;
}
-void help()
-{
- fprintf(outf,
- "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n"
- "\n"
- "Turbostat forks the specified COMMAND and prints statistics\n"
- "when COMMAND completes.\n"
- "If no COMMAND is specified, turbostat wakes every 5-seconds\n"
- "to print statistics, until interrupted.\n"
- "--add add a counter\n"
- " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n"
- "--cpu cpu-set limit output to summary plus cpu-set:\n"
- " {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"
- "--help print this help message\n"
- "--list list column headers only\n"
- "--out file create or truncate \"file\" for all output\n"
- "--version print version information\n"
- "\n"
- "For more help, run \"man turbostat\"\n");
-}
-
/*
* in /dev/cpu/ return success for names that are numbers
@@ -4689,6 +4708,16 @@ void parse_add_command(char *add_command)
}
}
+int is_deferred_skip(char *name)
+{
+ int i;
+
+ for (i = 0; i < deferred_skip_index; ++i)
+ if (!strcmp(name, deferred_skip_names[i]))
+ return 1;
+ return 0;
+}
+
void probe_sysfs(void)
{
char path[64];
@@ -4720,6 +4749,9 @@ void probe_sysfs(void)
sprintf(path, "cpuidle/state%d/time", state);
+ if (is_deferred_skip(name_buf))
+ continue;
+
add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_USEC,
FORMAT_PERCENT, SYSFS_PERCPU);
}
@@ -4741,6 +4773,9 @@ void probe_sysfs(void)
sprintf(path, "cpuidle/state%d/usage", state);
+ if (is_deferred_skip(name_buf))
+ continue;
+
add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS,
FORMAT_DELTA, SYSFS_PERCPU);
}
@@ -4834,12 +4869,6 @@ void parse_cpu_command(char *optarg)
exit(-1);
}
-/*
- * HIDE_LIST - hide this list of counters, show the rest [default]
- * SHOW_LIST - show this list of counters, hide the rest
- */
-enum show_hide_mode { SHOW_LIST, HIDE_LIST } global_show_hide_mode = HIDE_LIST;
-
int shown;
/*
* parse_show_hide() - process cmdline to set default counter action
@@ -4853,9 +4882,9 @@ void parse_show_hide(char *optarg, enum show_hide_mode new_mode)
*/
if (new_mode == SHOW_LIST) {
if (shown == 0)
- bic_enabled = bic_lookup(optarg);
+ bic_enabled = bic_lookup(optarg, new_mode);
else
- bic_enabled |= bic_lookup(optarg);
+ bic_enabled |= bic_lookup(optarg, new_mode);
shown = 1;
return;
@@ -4865,7 +4894,7 @@ void parse_show_hide(char *optarg, enum show_hide_mode new_mode)
* --hide: do not show those specified
* multiple invocations simply clear more bits in enabled mask
*/
- bic_enabled &= ~bic_lookup(optarg);
+ bic_enabled &= ~bic_lookup(optarg, new_mode);
}
--
2.11.0.161.g6610af872
next prev parent reply other threads:[~2017-03-01 5:35 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-01 5:27 [GIT PULL] turbostat 17.02.24 Len Brown
2017-03-01 5:27 ` [PATCH 01/44] tools/power turbostat: fix bugs in --add option Len Brown
2017-03-01 5:27 ` [PATCH 02/44] tools/power turbostat: Add --show and --hide parameters Len Brown
2017-03-01 5:27 ` [PATCH 03/44] tools/power turbostat: BYT does not have MSR_MISC_PWR_MGMT Len Brown
2017-03-01 5:27 ` [PATCH 04/44] tools/power turbostat: decode Baytrail CC6 and MC6 demotion configuration Len Brown
2017-03-01 5:27 ` [PATCH 05/44] tools/power turbostat: Baytrail: remove debug line in quiet mode Len Brown
2017-03-01 5:27 ` [PATCH 06/44] tools/power turbostat: update MSR_PKG_CST_CONFIG_CONTROL decoding Len Brown
2017-03-01 5:27 ` [PATCH 07/44] x86: msr-index.h: Define MSR_PKG_CST_CONFIG_CONTROL Len Brown
2017-03-01 5:27 ` [PATCH 08/44] intel_idle: use new name for MSR_PKG_CST_CONFIG_CONTROL Len Brown
2017-03-01 5:27 ` [PATCH 09/44] tools/power turbostat: " Len Brown
2017-03-01 5:27 ` [PATCH 10/44] x86: msr-index.h: Remove unused MSR_NHM_SNB_PKG_CST_CFG_CTL Len Brown
2017-03-01 5:27 ` [PATCH 11/44] tools/power turbostat: Baytrail c-state support Len Brown
2017-03-01 5:27 ` [PATCH 12/44] tools/power turbostat: add precision to --debug frequency output Len Brown
2017-03-01 5:27 ` [PATCH 13/44] tools/power turbostat: further decode MSR_IA32_MISC_ENABLE Len Brown
2017-03-01 5:27 ` [PATCH 14/44] x86 msr-index.h: Define Atom specific core ratio MSR locations Len Brown
2017-03-01 5:27 ` [PATCH 15/44] intel_pstate: use MSR_ATOM_RATIOS definitions from msr-index.h Len Brown
2017-03-01 5:27 ` [PATCH 16/44] tools/power turbostat: dump Atom P-states correctly Len Brown
2017-03-01 5:27 ` [PATCH 17/44] tools/power turbostat: decode CPUID(6).TURBO Len Brown
2017-03-01 5:27 ` [PATCH 18/44] x86 msr_index.h: Define MSR_MISC_FEATURE_CONTROL Len Brown
2017-03-01 5:27 ` [PATCH 19/44] tools/power turbostat: decode MSR_MISC_FEATURE_CONTROL Len Brown
2017-03-01 5:27 ` [PATCH 20/44] tools/power turbostat: show all columns, independent of --debug Len Brown
2017-03-01 5:27 ` [PATCH 21/44] tools/power turbostat: print system config, unless --quiet Len Brown
2017-03-01 5:27 ` [PATCH 22/44] tools/power turbostat: use tsc_tweak everwhere it is needed Len Brown
2017-03-01 5:27 ` [PATCH 23/44] tools/power turbostat: bug fixes to --add, --show/--hide features Len Brown
2017-03-01 5:27 ` [PATCH 24/44] x86: intel-family.h: Add GEMINI_LAKE SOC Len Brown
2017-03-01 23:48 ` Andy Shevchenko
2017-03-01 5:27 ` [PATCH 25/44] tools/power turbostat: initial Gemini Lake SOC support Len Brown
2017-03-01 5:27 ` [PATCH 26/44] tools/power turbostat: Denverton: use HW CC1 counter, skip C3, C7 Len Brown
2017-03-01 5:27 ` [PATCH 27/44] tools/power turbostat: skip unused counters on SKX Len Brown
2017-03-01 5:27 ` [PATCH 28/44] tools/power turbostat: fix decoding for GLM, DNV, SKX turbo-ratio limits Len Brown
2017-03-01 5:27 ` [PATCH 29/44] tools/power turbostat: skip unused counters on BDX Len Brown
2017-03-01 5:27 ` [PATCH 30/44] tools/power turbostat: extend --add option to accept /sys path Len Brown
2017-03-01 5:27 ` [PATCH 31/44] tools/power turbostat: print sysfs C-state stats Len Brown
2017-03-01 5:27 ` [PATCH 32/44] tools/power turbostat: add --cpu parameter Len Brown
2017-03-01 5:27 ` [PATCH 33/44] tools/power turbostat: fix zero IRQ count shown in one-shot command mode Len Brown
2017-03-01 5:27 ` [PATCH 34/44] tools/power turbostat: Add --list option to show available header names Len Brown
2017-03-01 5:27 ` [PATCH 35/44] tools/power turbostat: use wide columns to display large numbers Len Brown
2017-03-01 5:27 ` [PATCH 36/44] tools/power turbostat: update --list feature Len Brown
2017-03-01 5:27 ` [PATCH 37/44] tools/power turbostat: turbostat.8 update Len Brown
2017-03-01 5:27 ` [PATCH 38/44] tools/power turbostat: move --Package and --processor into the --cpu option Len Brown
2017-03-01 5:27 ` Len Brown [this message]
2017-03-01 5:27 ` [PATCH 40/44] tools/power turbostat: show package number, even without --debug Len Brown
2017-03-01 5:27 ` [PATCH 41/44] tools/power turbostat: dump p-state software config Len Brown
2017-03-01 5:27 ` [PATCH 42/44] tools/power turbostat: show error on exec Len Brown
2017-03-01 5:27 ` [PATCH 43/44] tools/power turbostat: bugfix: --add u32 was printed as u64 Len Brown
2017-03-01 5:27 ` [PATCH 44/44] tools/power turbostat: version 17.02.24 Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd778a5e6bbd0f52f34c61ae9b42b725c5f22398.1488345270.git.len.brown@intel.com \
--to=lenb@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).