From ed2d26d7cbccb1aa719a5d3fb8e87ef6610cb530 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Wed, 18 Nov 2015 12:04:48 -0500 Subject: 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 Cc: Shuah Khan Cc: linux-api@vger.kernel.org Signed-off-by: Prarit Bhargava Signed-off-by: Shuah Khan --- tools/testing/selftests/intel_pstate/msr.c | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tools/testing/selftests/intel_pstate/msr.c (limited to 'tools/testing/selftests/intel_pstate/msr.c') diff --git a/tools/testing/selftests/intel_pstate/msr.c b/tools/testing/selftests/intel_pstate/msr.c new file mode 100644 index 000000000000..abbbfc84d359 --- /dev/null +++ b/tools/testing/selftests/intel_pstate/msr.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +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; +} -- cgit v1.2.3-59-g8ed1b