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

cpupower: Add support for showing energy performance preference

The EPP value is useful for characterization of performance. Show
it in cpupower frequency-info output.

Link: https://lore.kernel.org/r/20241218191144.3440854-6-superm1@kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Mario Limonciello and committed by
Shuah Khan
5f567afc 26e16174

+46 -1
+14
tools/power/cpupower/lib/cpufreq.c
··· 127 127 enum cpufreq_string { 128 128 SCALING_DRIVER, 129 129 SCALING_GOVERNOR, 130 + ENERGY_PERFORMANCE_PREFERENCE, 130 131 MAX_CPUFREQ_STRING_FILES 131 132 }; 132 133 133 134 static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = { 134 135 [SCALING_DRIVER] = "scaling_driver", 135 136 [SCALING_GOVERNOR] = "scaling_governor", 137 + [ENERGY_PERFORMANCE_PREFERENCE] = "energy_performance_preference", 136 138 }; 137 139 138 140 ··· 207 205 unsigned long cpufreq_get_transition_latency(unsigned int cpu) 208 206 { 209 207 return sysfs_cpufreq_get_one_value(cpu, CPUINFO_LATENCY); 208 + } 209 + 210 + char *cpufreq_get_energy_performance_preference(unsigned int cpu) 211 + { 212 + return sysfs_cpufreq_get_one_string(cpu, ENERGY_PERFORMANCE_PREFERENCE); 213 + } 214 + 215 + void cpufreq_put_energy_performance_preference(char *ptr) 216 + { 217 + if (!ptr) 218 + return; 219 + free(ptr); 210 220 } 211 221 212 222 int cpufreq_get_hardware_limits(unsigned int cpu,
+8
tools/power/cpupower/lib/cpufreq.h
··· 68 68 unsigned long cpufreq_get_transition_latency(unsigned int cpu); 69 69 70 70 71 + /* determine energy performance preference 72 + * 73 + * returns NULL on failure, else the string that represents the energy performance 74 + * preference requested. 75 + */ 76 + char *cpufreq_get_energy_performance_preference(unsigned int cpu); 77 + void cpufreq_put_energy_performance_preference(char *ptr); 78 + 71 79 /* determine hardware CPU frequency limits 72 80 * 73 81 * These may be limited further by thermal, energy or other
+24 -1
tools/power/cpupower/utils/cpufreq-info.c
··· 422 422 return 0; 423 423 } 424 424 425 + /* --epp / -z */ 426 + 427 + static int get_epp(unsigned int cpu, bool interactive) 428 + { 429 + char *epp; 430 + 431 + epp = cpufreq_get_energy_performance_preference(cpu); 432 + if (!epp) 433 + return -EINVAL; 434 + if (interactive) 435 + printf(_(" energy performance preference: %s\n"), epp); 436 + 437 + cpufreq_put_energy_performance_preference(epp); 438 + 439 + return 0; 440 + } 441 + 425 442 /* --latency / -y */ 426 443 427 444 static int get_latency(unsigned int cpu, unsigned int human) ··· 478 461 get_related_cpus(cpu); 479 462 get_affected_cpus(cpu); 480 463 get_latency(cpu, 1); 464 + get_epp(cpu, true); 481 465 get_hardware_limits(cpu, 1); 482 466 483 467 freqs = cpufreq_get_available_frequencies(cpu); ··· 519 501 {"human", no_argument, NULL, 'm'}, 520 502 {"no-rounding", no_argument, NULL, 'n'}, 521 503 {"performance", no_argument, NULL, 'c'}, 504 + {"epp", no_argument, NULL, 'z'}, 522 505 { }, 523 506 }; 524 507 ··· 533 514 int output_param = 0; 534 515 535 516 do { 536 - ret = getopt_long(argc, argv, "oefwldpgrasmybnc", info_opts, 517 + ret = getopt_long(argc, argv, "oefwldpgrasmybncz", info_opts, 537 518 NULL); 538 519 switch (ret) { 539 520 case '?': ··· 557 538 case 's': 558 539 case 'y': 559 540 case 'c': 541 + case 'z': 560 542 if (output_param) { 561 543 output_param = -1; 562 544 cont = 0; ··· 666 646 break; 667 647 case 'c': 668 648 ret = get_perf_cap(cpu); 649 + break; 650 + case 'z': 651 + ret = get_epp(cpu, true); 669 652 break; 670 653 } 671 654 if (ret)