mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 10:31:33 -04:00
Merge tag 'linux-cpupower-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux
Pull cpupower utility updates for 7.3-rc1 from Shuah Khan: "Adds support for generic CPPC display that depends only on standardized fields, improving AMD specific implementation for the same. Removes conditional return with no effect as part of tree-wide code clean up effort." * tag 'linux-cpupower-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux: cpupower: remove conditional return with no effect cpupower: Add libm to cpupower for generic CPPC view cpupower: Print kernel and hardware frequency information cpupower: Build and call CPPC information on non-AMD processors cpupower: Add generic CPPC performance display
This commit is contained in:
@@ -131,7 +131,7 @@ override CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
|
||||
|
||||
UTIL_OBJS = utils/helpers/amd.o utils/helpers/msr.o \
|
||||
utils/helpers/sysfs.o utils/helpers/misc.o utils/helpers/cpuid.o \
|
||||
utils/helpers/pci.o utils/helpers/bitmask.o \
|
||||
utils/helpers/pci.o utils/helpers/bitmask.o utils/helpers/cppc.o \
|
||||
utils/idle_monitor/nhm_idle.o utils/idle_monitor/snb_idle.o \
|
||||
utils/idle_monitor/hsw_ext_idle.o \
|
||||
utils/idle_monitor/amd_fam14h_idle.o utils/idle_monitor/cpuidle_sysfs.o \
|
||||
@@ -236,9 +236,9 @@ $(OUTPUT)%.o: %.c
|
||||
$(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)$(LIBCPUPOWER)
|
||||
$(ECHO) " CC " $@
|
||||
ifeq ($(strip $(STATIC)),true)
|
||||
$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lrt -lpci -L$(OUTPUT) -o $@
|
||||
$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lm -lrt -lpci -L$(OUTPUT) -o $@
|
||||
else
|
||||
$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
|
||||
$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lm -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
|
||||
endif
|
||||
$(QUIET) $(STRIPCMD) $@
|
||||
|
||||
|
||||
@@ -270,10 +270,10 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)
|
||||
{
|
||||
unsigned long freq;
|
||||
|
||||
if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
|
||||
freq = cpufreq_get_freq_hardware(cpu);
|
||||
if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF) && !freq)
|
||||
return -EINVAL;
|
||||
|
||||
freq = cpufreq_get_freq_hardware(cpu);
|
||||
printf(_(" current CPU frequency: "));
|
||||
if (!freq) {
|
||||
printf("Unable to call hardware\n");
|
||||
@@ -477,12 +477,13 @@ static int get_latency(unsigned int cpu, unsigned int human)
|
||||
}
|
||||
|
||||
/* --performance / -c */
|
||||
|
||||
static int get_perf_cap(unsigned int cpu)
|
||||
{
|
||||
if (cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
|
||||
cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE)
|
||||
amd_pstate_show_perf_and_freq(cpu, no_rounding);
|
||||
else
|
||||
cppc_show_perf_and_freq(cpu, no_rounding);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -513,8 +514,8 @@ static void debug_output_one(unsigned int cpu)
|
||||
|
||||
get_available_governors(cpu);
|
||||
get_policy(cpu);
|
||||
if (get_freq_hardware(cpu, 1) < 0)
|
||||
get_freq_kernel(cpu, 1);
|
||||
get_freq_hardware(cpu, 1);
|
||||
get_freq_kernel(cpu, 1);
|
||||
get_boost_mode(cpu);
|
||||
get_perf_cap(cpu);
|
||||
}
|
||||
|
||||
56
tools/power/cpupower/utils/helpers/cppc.c
Normal file
56
tools/power/cpupower/utils/helpers/cppc.c
Normal file
@@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "helpers/helpers.h"
|
||||
#include "cpufreq.h"
|
||||
#include "acpi_cppc.h"
|
||||
|
||||
#define cppc_to_frequency(perf) (roundf(slope * (perf) + intercept))
|
||||
|
||||
void cppc_show_perf_and_freq(unsigned int cpu, int no_rounding)
|
||||
{
|
||||
int64_t nominal = acpi_cppc_get_data(cpu, NOMINAL_PERF);
|
||||
int64_t nominal_freq = acpi_cppc_get_data(cpu, NOMINAL_FREQ) * 1000;
|
||||
int64_t lowest = acpi_cppc_get_data(cpu, LOWEST_PERF);
|
||||
int64_t lowest_freq = acpi_cppc_get_data(cpu, LOWEST_FREQ) * 1000;
|
||||
unsigned long non_linear = acpi_cppc_get_data(cpu, LOWEST_NONLINEAR_PERF);
|
||||
unsigned long highest = acpi_cppc_get_data(cpu, HIGHEST_PERF);
|
||||
float slope, intercept;
|
||||
|
||||
/* do the optional freq fields look invalid? */
|
||||
if (!nominal_freq || !lowest_freq || nominal == lowest)
|
||||
return;
|
||||
|
||||
slope = (float)(nominal_freq - lowest_freq) / (nominal - lowest);
|
||||
intercept = lowest_freq - slope * lowest;
|
||||
|
||||
printf(_(" CPPC limits:\n"));
|
||||
printf(_(" Highest Performance: %lu. Maximum Frequency: "),
|
||||
highest);
|
||||
/*
|
||||
* If boost isn't active, the cpuinfo_max doesn't indicate real max
|
||||
* frequency.
|
||||
*/
|
||||
print_speed(cppc_to_frequency(highest), no_rounding);
|
||||
printf(".\n");
|
||||
|
||||
printf(_(" Nominal Performance: %lu. Nominal Frequency: "),
|
||||
acpi_cppc_get_data(cpu, NOMINAL_PERF));
|
||||
print_speed(nominal_freq, no_rounding);
|
||||
printf(".\n");
|
||||
|
||||
printf(_(" Lowest Non-linear Performance: %lu. Lowest Non-linear Frequency: "),
|
||||
non_linear);
|
||||
print_speed(cppc_to_frequency(non_linear), no_rounding);
|
||||
printf(".\n");
|
||||
|
||||
printf(_(" Lowest Performance: %lu. Lowest Frequency: "),
|
||||
acpi_cppc_get_data(cpu, LOWEST_PERF));
|
||||
print_speed(lowest_freq, no_rounding);
|
||||
printf(".\n");
|
||||
}
|
||||
@@ -221,4 +221,6 @@ void print_online_cpus(void);
|
||||
void print_offline_cpus(void);
|
||||
void print_speed(unsigned long speed, int no_rounding);
|
||||
|
||||
void cppc_show_perf_and_freq(unsigned int cpu, int no_rounding);
|
||||
|
||||
#endif /* __CPUPOWERUTILS_HELPERS__ */
|
||||
|
||||
@@ -47,8 +47,6 @@ static int powercap_print_one_zone(struct powercap_zone *zone)
|
||||
|
||||
printf("\n");
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user