Skip to content

Commit

Permalink
cpupower: Add cpuidle parts into library
Browse files Browse the repository at this point in the history
This more or less is a renaming and moving of functions and should not
introduce any functional change.

cpupower was built from cpufrequtils (which had a C library providing easy
access to cpu frequency platform info). In the meantime it got enhanced
by quite some neat cpuidle userspace tools.

Now the cpu idle functions have been separated and added to the cpupower.so
library.
So beside an already existing public header file:
cpufreq.h
cpupower now also exports these cpu idle functions in:
cpuidle.h

Here again pasted for better review of the interfaces:

======================================
int cpuidle_is_state_disabled(unsigned int cpu,
                                       unsigned int idlestate);
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_usage(unsigned int cpu,
                                        unsigned int idlestate);
unsigned long long cpuidle_state_time(unsigned int cpu,
                                                unsigned int idlestate);
char *cpuidle_state_name(unsigned int cpu,
                                unsigned int idlestate);
char *cpuidle_state_desc(unsigned int cpu,
                                unsigned int idlestate);
unsigned int cpuidle_state_count(unsigned int cpu);

char *cpuidle_get_governor(void);
char *cpuidle_get_driver(void);

======================================

Signed-off-by: Thomas Renninger <trenn@suse.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Thomas Renninger authored and Rafael J. Wysocki committed Apr 28, 2016
1 parent fe7656a commit ac5a181
Show file tree
Hide file tree
Showing 17 changed files with 1,242 additions and 931 deletions.
12 changes: 7 additions & 5 deletions tools/power/cpupower/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DESTDIR ?=
# and _should_ modify the PACKAGE_BUGREPORT definition

VERSION= $(shell ./utils/version-gen.sh)
LIB_MAJ= 0.0.0
LIB_MAJ= 0.0.1
LIB_MIN= 0

PACKAGE = cpupower
Expand Down Expand Up @@ -129,7 +129,7 @@ WARNINGS += -Wshadow
CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
-DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE

UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \
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/idle_monitor/nhm_idle.o utils/idle_monitor/snb_idle.o \
Expand All @@ -148,9 +148,9 @@ UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \
utils/helpers/bitmask.h \
utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def

LIB_HEADERS = lib/cpufreq.h lib/sysfs.h
LIB_SRC = lib/cpufreq.c lib/sysfs.c
LIB_OBJS = lib/cpufreq.o lib/sysfs.o
LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h
LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c
LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o
LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS))

CFLAGS += -pipe
Expand Down Expand Up @@ -280,6 +280,7 @@ install-lib:
$(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/
$(INSTALL) -d $(DESTDIR)${includedir}
$(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h
$(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h

install-tools:
$(INSTALL) -d $(DESTDIR)${bindir}
Expand Down Expand Up @@ -315,6 +316,7 @@ endif
uninstall:
- rm -f $(DESTDIR)${libdir}/libcpupower.*
- rm -f $(DESTDIR)${includedir}/cpufreq.h
- rm -f $(DESTDIR)${includedir}/cpuidle.h
- rm -f $(DESTDIR)${bindir}/utils/cpupower
- rm -f $(DESTDIR)${mandir}/man1/cpupower.1
- rm -f $(DESTDIR)${mandir}/man1/cpupower-frequency-set.1
Expand Down
3 changes: 2 additions & 1 deletion tools/power/cpupower/bench/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <sched.h>

#include <cpufreq.h>
#include <cpupower.h>

#include "config.h"
#include "system.h"
Expand Down Expand Up @@ -60,7 +61,7 @@ int set_cpufreq_governor(char *governor, unsigned int cpu)

dprintf("set %s as cpufreq governor\n", governor);

if (cpufreq_cpu_exists(cpu) != 0) {
if (cpupower_is_cpu_online(cpu) != 0) {
perror("cpufreq_cpu_exists");
fprintf(stderr, "error: cpu %u does not exist\n", cpu);
return -1;
Expand Down
Loading

0 comments on commit ac5a181

Please sign in to comment.