Skip to content

Commit 3d94026

Browse files
zhang-ruilenb
authored andcommitted
tools/power turbostat: Introduce --force parameter
Turbostat currently exits under the following conditions: 1. When running on non-Intel/AMD/Hygon x86 vendors. 2. When running on Intel models that lack specific platform features. Introduce a new `--force` parameter that allows turbostat to run on these unsupported platforms with minimal default feature support. This provides users with the flexibility to gather basic information even on unsupported systems. [lenb: updated warning message text] Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent cc63f89 commit 3d94026

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ unsigned int rapl_joules;
326326
unsigned int summary_only;
327327
unsigned int list_header_only;
328328
unsigned int dump_only;
329+
unsigned int force_load;
329330
unsigned int has_aperf;
330331
unsigned int has_aperf_access;
331332
unsigned int has_epb;
@@ -1058,7 +1059,8 @@ void probe_platform_features(unsigned int family, unsigned int model)
10581059

10591060

10601061
if (authentic_amd || hygon_genuine) {
1061-
platform = &default_features;
1062+
/* fallback to default features on unsupported models */
1063+
force_load++;
10621064
if (max_extended_level >= 0x80000007) {
10631065
unsigned int eax, ebx, ecx, edx;
10641066

@@ -1067,7 +1069,7 @@ void probe_platform_features(unsigned int family, unsigned int model)
10671069
if ((edx & (1 << 14)) && family >= 0x17)
10681070
platform = &amd_features_with_rapl;
10691071
}
1070-
return;
1072+
goto end;
10711073
}
10721074

10731075
if (!genuine_intel)
@@ -1081,6 +1083,11 @@ void probe_platform_features(unsigned int family, unsigned int model)
10811083
}
10821084

10831085
end:
1086+
if (force_load && !platform) {
1087+
fprintf(outf, "Forced to run on unsupported platform!\n");
1088+
platform = &default_features;
1089+
}
1090+
10841091
if (platform)
10851092
return;
10861093

@@ -2160,6 +2167,8 @@ void help(void)
21602167
" displays the raw counter values\n"
21612168
" -e, --enable [all | column]\n"
21622169
" shows all or the specified disabled column\n"
2170+
" -f, --force\n"
2171+
" force load turbostat with minimum default features on unsupported platforms.\n"
21632172
" -H, --hide [column | column,column,...]\n"
21642173
" hide the specified column(s)\n"
21652174
" -i, --interval sec.subsec\n"
@@ -9942,6 +9951,7 @@ void cmdline(int argc, char **argv)
99429951
{ "Dump", no_argument, 0, 'D' },
99439952
{ "debug", no_argument, 0, 'd' }, /* internal, not documented */
99449953
{ "enable", required_argument, 0, 'e' },
9954+
{ "force", no_argument, 0, 'f' },
99459955
{ "interval", required_argument, 0, 'i' },
99469956
{ "IPC", no_argument, 0, 'I' },
99479957
{ "num_iterations", required_argument, 0, 'n' },
@@ -10002,6 +10012,9 @@ void cmdline(int argc, char **argv)
1000210012
/* --enable specified counter */
1000310013
bic_enabled = bic_enabled | bic_lookup(optarg, SHOW_LIST);
1000410014
break;
10015+
case 'f':
10016+
force_load++;
10017+
break;
1000510018
case 'd':
1000610019
debug++;
1000710020
ENABLE_BIC(BIC_DISABLED_BY_DEFAULT);

0 commit comments

Comments
 (0)