Commit 1c91c990 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-tools'

Merge cpupower utility updates for 6.14:

 - Fix TSC MHz calculation in cpupower (He Rongguang).

 - Add install and uninstall options to bindings Makefile and add header
   changes for cpufreq.h to SWIG bindings in cpupower (John B. Wyatt IV).

 - Add missing residency header changes in cpuidle.h to SWIG bindings in
   cpupower (John B. Wyatt IV).

 - Add output files to .gitignore and clean them up in "make clean" in
   selftests/cpufreq (Li Zhijian).

 - Fix cross-compilation in cpupower Makefile (Peng Fan).

 - Revise the is_valid flag handling for idle_monitor in the cpupower
   utility (wangfushuai).

 - Extend and clean up AMD processors support in cpupower (Mario
   Limonciello).

* pm-tools:
  pm: cpupower: Add missing residency header changes in cpuidle.h to SWIG
  pm: cpupower: Add header changes for cpufreq.h to SWIG bindings
  pm: cpupower: Add install and uninstall options to bindings makefile
  cpupower: Adjust whitespace for amd-pstate specific prints
  cpupower: Don't fetch maximum latency when EPP is enabled
  cpupower: Add support for showing energy performance preference
  cpupower: Don't try to read frequency from hardware when kernel uses aperfmperf
  cpupower: Add support for amd-pstate preferred core rankings
  cpupower: Add support for parsing 'enabled' or 'disabled' strings from table
  cpupower: Remove spurious return statement
  cpupower: fix TSC MHz calculation
  cpupower: revise is_valid flag handling for idle_monitor
  pm: cpupower: Makefile: Fix cross compilation
  selftests/cpufreq: gitignore output files and clean them in make clean
parents eddd3769 166eb235
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -87,11 +87,19 @@ INSTALL_SCRIPT = ${INSTALL} -m 644
# to something more interesting, like "arm-linux-".  If you want
# to compile vs uClibc, that can be done here as well.
CROSS ?= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
ifneq ($(CROSS), )
CC = $(CROSS)gcc
LD = $(CROSS)gcc
AR = $(CROSS)ar
STRIP = $(CROSS)strip
RANLIB = $(CROSS)ranlib
else
CC ?= $(CROSS)gcc
LD ?= $(CROSS)gcc
AR ?= $(CROSS)ar
STRIP ?= $(CROSS)strip
RANLIB ?= $(CROSS)ranlib
endif
HOSTCC = gcc
MKDIR = mkdir

+10 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ HAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; el
LIB_DIR := ../../lib
PY_INCLUDE = $(firstword $(shell python-config --includes))
OBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o)
INSTALL_DIR = $(shell python3 -c "import site; print(site.getsitepackages()[0])")

all: _raw_pylibcpupower.so

@@ -28,6 +29,15 @@ else ifeq ($(HAVE_PYCONFIG),0)
endif
	swig -python raw_pylibcpupower.swg

# Only installs the Python bindings
install: _raw_pylibcpupower.so
	install -D _raw_pylibcpupower.so $(INSTALL_DIR)/_raw_pylibcpupower.so
	install -D raw_pylibcpupower.py $(INSTALL_DIR)/raw_pylibcpupower.py

uninstall:
	rm -f $(INSTALL_DIR)/_raw_pylibcpupower.so
	rm -f $(INSTALL_DIR)/raw_pylibcpupower.py

# Will only clean the bindings folder; will not clean the actual cpupower folder
clean:
	rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so
+25 −0
Original line number Diff line number Diff line
@@ -48,6 +48,31 @@ To run the test script:
$ python test_raw_pylibcpupower.py


developing/using the bindings directly
--------------------------------------

You need to add the Python bindings directory to your $PYTHONPATH.

You would set the path in the Bash terminal or in the Bash profile:

PYTHONPATH=~/linux/tools/power/cpupower/bindings/python:$PYTHONPATH

This allows you to set a specific repo of the bindings to use.


installing/uninstalling
-----------------------

Python uses a system specific site-packages folder to look up modules to import
by default. You do not need to install cpupower to use the SWIG bindings.

You can install and uninstall the bindings to the site-packages with:

sudo make install

sudo make uninstall


credits
-------

+5 −0
Original line number Diff line number Diff line
@@ -134,6 +134,9 @@ void cpufreq_put_stats(struct cpufreq_stats *stats);

unsigned long cpufreq_get_transitions(unsigned int cpu);

char *cpufreq_get_energy_performance_preference(unsigned int cpu);
void cpufreq_put_energy_performance_preference(char *ptr);

int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy);

int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq);
@@ -160,6 +163,8 @@ int cpuidle_state_disable(unsigned int cpu, unsigned int idlestate,
				   unsigned int disable);
unsigned long cpuidle_state_latency(unsigned int cpu,
						unsigned int idlestate);
unsigned long cpuidle_state_residency(unsigned int cpu,
						unsigned int idlestate);
unsigned long cpuidle_state_usage(unsigned int cpu,
					unsigned int idlestate);
unsigned long long cpuidle_state_time(unsigned int cpu,
+18 −0
Original line number Diff line number Diff line
@@ -102,6 +102,10 @@ unsigned long cpufreq_get_sysfs_value_from_table(unsigned int cpu,
	if (len == 0)
		return 0;

	if (!strcmp(linebuf, "enabled\n"))
		return 1;
	if (!strcmp(linebuf, "disabled\n"))
		return 0;
	value = strtoul(linebuf, &endp, 0);

	if (endp == linebuf || errno == ERANGE)
@@ -123,12 +127,14 @@ static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu,
enum cpufreq_string {
	SCALING_DRIVER,
	SCALING_GOVERNOR,
	ENERGY_PERFORMANCE_PREFERENCE,
	MAX_CPUFREQ_STRING_FILES
};

static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = {
	[SCALING_DRIVER] = "scaling_driver",
	[SCALING_GOVERNOR] = "scaling_governor",
	[ENERGY_PERFORMANCE_PREFERENCE] = "energy_performance_preference",
};


@@ -203,6 +209,18 @@ unsigned long cpufreq_get_transition_latency(unsigned int cpu)
	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,
				unsigned long *min,
				unsigned long *max)
Loading