Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/power x86_energy_perf_policy: Enhance HWP enabled check

Verify that all CPUs have HWP enabled, not just cpu0.

Signed-off-by: Len Brown <len.brown@intel.com>

Len Brown b6b42a60 62127655

+37 -9
+37 -9
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
··· 4 4 * policy preference bias on recent X86 processors. 5 5 */ 6 6 /* 7 - * Copyright (c) 2010 - 2017 Intel Corporation. 7 + * Copyright (c) 2010 - 2025 Intel Corporation. 8 8 * Len Brown <len.brown@intel.com> 9 9 */ 10 10 ··· 517 517 518 518 void print_version(void) 519 519 { 520 - printf("x86_energy_perf_policy 17.05.11 (C) Len Brown <len.brown@intel.com>\n"); 520 + printf("x86_energy_perf_policy 2025.9.19 Len Brown <lenb@kernel.org>\n"); 521 521 } 522 522 523 523 void cmdline(int argc, char **argv) ··· 1312 1312 if (CPU_ISSET_S(cpu_num, set_size, cpu_set)) 1313 1313 func(cpu_num); 1314 1314 } 1315 + int for_all_cpus_in_set_and(size_t set_size, cpu_set_t *cpu_set, int (func)(int)) 1316 + { 1317 + int cpu_num; 1318 + int retval = 1; 1319 + 1320 + for (cpu_num = 0; cpu_num <= max_cpu_num; ++cpu_num) 1321 + if (CPU_ISSET_S(cpu_num, set_size, cpu_set)) 1322 + retval &= func(cpu_num); 1323 + 1324 + return retval; 1325 + } 1315 1326 1316 1327 void init_data_structures(void) 1317 1328 { ··· 1337 1326 for_all_proc_cpus(mark_cpu_present); 1338 1327 } 1339 1328 1340 - /* clear has_hwp if it is not enable (or being enabled) */ 1341 - 1342 - void verify_hwp_is_enabled(void) 1329 + int is_hwp_enabled_on_cpu(int cpu_num) 1343 1330 { 1344 1331 unsigned long long msr; 1332 + int retval; 1333 + 1334 + /* MSR_PM_ENABLE[1] == 1 if HWP is enabled and MSRs visible */ 1335 + get_msr(cpu_num, MSR_PM_ENABLE, &msr); 1336 + retval = (msr & 1); 1337 + 1338 + if (verbose) 1339 + fprintf(stderr, "cpu%d: %sHWP\n", cpu_num, retval ? "" : "No-"); 1340 + 1341 + return retval; 1342 + } 1343 + 1344 + /* 1345 + * verify_hwp_is_enabled() 1346 + * 1347 + * Set (has_hwp=0) if no HWP feature or any of selected CPU set does not have HWP enabled 1348 + */ 1349 + void verify_hwp_is_enabled(void) 1350 + { 1351 + int retval; 1345 1352 1346 1353 if (!has_hwp) /* set in early_cpuid() */ 1347 1354 return; 1348 1355 1349 - /* MSR_PM_ENABLE[1] == 1 if HWP is enabled and MSRs visible */ 1350 - get_msr(base_cpu, MSR_PM_ENABLE, &msr); 1351 - if ((msr & 1) == 0) { 1356 + retval = for_all_cpus_in_set_and(cpu_setsize, cpu_selected_set, is_hwp_enabled_on_cpu); 1357 + 1358 + if (retval == 0) { 1352 1359 fprintf(stderr, "HWP can be enabled using '--hwp-enable'\n"); 1353 1360 has_hwp = 0; 1354 - return; 1355 1361 } 1356 1362 } 1357 1363