mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
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>
This commit is contained in:
parent
26e16174f5
commit
5f567afc28
|
|
@ -127,12 +127,14 @@ static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu,
|
||||||
enum cpufreq_string {
|
enum cpufreq_string {
|
||||||
SCALING_DRIVER,
|
SCALING_DRIVER,
|
||||||
SCALING_GOVERNOR,
|
SCALING_GOVERNOR,
|
||||||
|
ENERGY_PERFORMANCE_PREFERENCE,
|
||||||
MAX_CPUFREQ_STRING_FILES
|
MAX_CPUFREQ_STRING_FILES
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = {
|
static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = {
|
||||||
[SCALING_DRIVER] = "scaling_driver",
|
[SCALING_DRIVER] = "scaling_driver",
|
||||||
[SCALING_GOVERNOR] = "scaling_governor",
|
[SCALING_GOVERNOR] = "scaling_governor",
|
||||||
|
[ENERGY_PERFORMANCE_PREFERENCE] = "energy_performance_preference",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -207,6 +209,18 @@ unsigned long cpufreq_get_transition_latency(unsigned int cpu)
|
||||||
return sysfs_cpufreq_get_one_value(cpu, CPUINFO_LATENCY);
|
return sysfs_cpufreq_get_one_value(cpu, CPUINFO_LATENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *cpufreq_get_energy_performance_preference(unsigned int cpu)
|
||||||
|
{
|
||||||
|
return sysfs_cpufreq_get_one_string(cpu, ENERGY_PERFORMANCE_PREFERENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpufreq_put_energy_performance_preference(char *ptr)
|
||||||
|
{
|
||||||
|
if (!ptr)
|
||||||
|
return;
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
int cpufreq_get_hardware_limits(unsigned int cpu,
|
int cpufreq_get_hardware_limits(unsigned int cpu,
|
||||||
unsigned long *min,
|
unsigned long *min,
|
||||||
unsigned long *max)
|
unsigned long *max)
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,14 @@ unsigned long cpufreq_get_freq_hardware(unsigned int cpu);
|
||||||
unsigned long cpufreq_get_transition_latency(unsigned int cpu);
|
unsigned long cpufreq_get_transition_latency(unsigned int cpu);
|
||||||
|
|
||||||
|
|
||||||
|
/* determine energy performance preference
|
||||||
|
*
|
||||||
|
* returns NULL on failure, else the string that represents the energy performance
|
||||||
|
* preference requested.
|
||||||
|
*/
|
||||||
|
char *cpufreq_get_energy_performance_preference(unsigned int cpu);
|
||||||
|
void cpufreq_put_energy_performance_preference(char *ptr);
|
||||||
|
|
||||||
/* determine hardware CPU frequency limits
|
/* determine hardware CPU frequency limits
|
||||||
*
|
*
|
||||||
* These may be limited further by thermal, energy or other
|
* These may be limited further by thermal, energy or other
|
||||||
|
|
|
||||||
|
|
@ -422,6 +422,23 @@ static int get_freq_stats(unsigned int cpu, unsigned int human)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --epp / -z */
|
||||||
|
|
||||||
|
static int get_epp(unsigned int cpu, bool interactive)
|
||||||
|
{
|
||||||
|
char *epp;
|
||||||
|
|
||||||
|
epp = cpufreq_get_energy_performance_preference(cpu);
|
||||||
|
if (!epp)
|
||||||
|
return -EINVAL;
|
||||||
|
if (interactive)
|
||||||
|
printf(_(" energy performance preference: %s\n"), epp);
|
||||||
|
|
||||||
|
cpufreq_put_energy_performance_preference(epp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* --latency / -y */
|
/* --latency / -y */
|
||||||
|
|
||||||
static int get_latency(unsigned int cpu, unsigned int human)
|
static int get_latency(unsigned int cpu, unsigned int human)
|
||||||
|
|
@ -461,6 +478,7 @@ static void debug_output_one(unsigned int cpu)
|
||||||
get_related_cpus(cpu);
|
get_related_cpus(cpu);
|
||||||
get_affected_cpus(cpu);
|
get_affected_cpus(cpu);
|
||||||
get_latency(cpu, 1);
|
get_latency(cpu, 1);
|
||||||
|
get_epp(cpu, true);
|
||||||
get_hardware_limits(cpu, 1);
|
get_hardware_limits(cpu, 1);
|
||||||
|
|
||||||
freqs = cpufreq_get_available_frequencies(cpu);
|
freqs = cpufreq_get_available_frequencies(cpu);
|
||||||
|
|
@ -501,6 +519,7 @@ static struct option info_opts[] = {
|
||||||
{"human", no_argument, NULL, 'm'},
|
{"human", no_argument, NULL, 'm'},
|
||||||
{"no-rounding", no_argument, NULL, 'n'},
|
{"no-rounding", no_argument, NULL, 'n'},
|
||||||
{"performance", no_argument, NULL, 'c'},
|
{"performance", no_argument, NULL, 'c'},
|
||||||
|
{"epp", no_argument, NULL, 'z'},
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -514,7 +533,7 @@ int cmd_freq_info(int argc, char **argv)
|
||||||
int output_param = 0;
|
int output_param = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = getopt_long(argc, argv, "oefwldpgrasmybnc", info_opts,
|
ret = getopt_long(argc, argv, "oefwldpgrasmybncz", info_opts,
|
||||||
NULL);
|
NULL);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case '?':
|
case '?':
|
||||||
|
|
@ -538,6 +557,7 @@ int cmd_freq_info(int argc, char **argv)
|
||||||
case 's':
|
case 's':
|
||||||
case 'y':
|
case 'y':
|
||||||
case 'c':
|
case 'c':
|
||||||
|
case 'z':
|
||||||
if (output_param) {
|
if (output_param) {
|
||||||
output_param = -1;
|
output_param = -1;
|
||||||
cont = 0;
|
cont = 0;
|
||||||
|
|
@ -647,6 +667,9 @@ int cmd_freq_info(int argc, char **argv)
|
||||||
case 'c':
|
case 'c':
|
||||||
ret = get_perf_cap(cpu);
|
ret = get_perf_cap(cpu);
|
||||||
break;
|
break;
|
||||||
|
case 'z':
|
||||||
|
ret = get_epp(cpu, true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user