Skip to contentSkip to conversation

tools, testing, add test for intel_pstate driver

PATCH In review Prarit Bhargava 2 participants 2 messages Nov 18, 2015 – Nov 23, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools, testing, add test for intel_pstate driver

This test used the cpupower utility to set the cpu frequency from the maximum turbo value to the minimum supported value in steps of 100 MHz.

The results are displayed in a table which indicate the "Target" state, or the requested frequency in MHz, the Actual frequency, as read from /proc/cpuinfo, the difference between the Target and Actual frequencies, and the value of MSR 0x199 (MSR_IA32_PERF_CTL) which indicates what pstate the cpu is in, and the value of /sys/devices/system/cpu/intel_pstate/max_perf_pct X maximum turbo state

---
 tools/testing/selftests/intel_pstate/Makefile |   15 ++++
 tools/testing/selftests/intel_pstate/aperf.c  |   80 +++++++++++++++++
 tools/testing/selftests/intel_pstate/msr.c    |   39 +++++++++
 tools/testing/selftests/intel_pstate/run.sh   |  113 +++++++++++++++++++++++++
 4 files changed, 247 insertions(+)
 create mode 100644 tools/testing/selftests/intel_pstate/Makefile
 create mode 100644 tools/testing/selftests/intel_pstate/aperf.c
 create mode 100644 tools/testing/selftests/intel_pstate/msr.c
 create mode 100755 tools/testing/selftests/intel_pstate/run.sh
tools/testing/selftests/intel_pstate/Makefile new file +15 -0
new file mode 100644
index 0000000..f5f1a28
@@ -0,0 +1,15 @@
+CC := $(CROSS_COMPILE)gcc
+CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE
+LDFLAGS := $(LDFLAGS) -lm
+
+TARGETS := msr aperf
+
+TEST_PROGS := $(TARGETS) run.sh
+
+.PHONY: all clean
+all: $(TARGETS)
+
+$(TARGETS): $(HEADERS)
+
+clean:
+	rm -f $(TARGETS)
tools/testing/selftests/intel_pstate/aperf.c new file +80 -0

80 lines not on this page · raw message

tools/testing/selftests/intel_pstate/msr.c new file +39 -0
new file mode 100644
index 0000000..abbbfc8
@@ -0,0 +1,39 @@
+#include <math.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/timeb.h>
+#include <sched.h>
+#include <errno.h>
+
+
+int main(int argc, char **argv) {
+	int cpu, fd;
+	long long msr;
+	char msr_file_name[64];
+
+	if (argc != 2)
+		return 1;
+
+	errno = 0;
+	cpu = strtol(argv[1], (char **) NULL, 10);
+
+	if (errno)
+		return 1;
+
+	sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
+	fd = open(msr_file_name, O_RDONLY);
+
+	if (fd == -1) {
+		perror("Failed to open");
+		return 1;
+	}
+
+	pread(fd, &msr,  sizeof(msr), 0x199);
+
+	printf("msr 0x199: 0x%llx\n", msr);
+	return 0;
+}
tools/testing/selftests/intel_pstate/run.sh new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
1.7.9.3

A message that is not in the archive (sent off-list or not yet received): 1447866288-8125-1-git-send-email-prarit-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 10 lines · Prarit Bhargava

This test used the cpupower utility to set the cpu frequency from the maximum turbo value to the minimum supported value in steps of 100 MHz.

The results are displayed in a table which indicate the "Target" state, or the requested frequency in MHz, the Actual frequency, as read from /proc/cpuinfo, the difference between the Target and Actual frequencies, and the value of MSR 0x199 (MSR_IA32_PERF_CTL) which indicates what pstate the cpu is in, and the value of /sys/devices/system/cpu/intel_pstate/max_perf_pct X maximum turbo state

Quoted 4 lines

---

Thanks. Applied to linux-kselftest next for 4.5-rc1

thanks,
-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978