public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] device-drivers/ltp_acpi_cpufreq: move it to cpufreq/cpufreq_boost
@ 2014-12-04 17:20 Alexey Kodanev
  2014-12-04 17:20 ` [LTP] [PATCH 2/2] device-drivers/cpufreq: add intel_pstate driver to boost test Alexey Kodanev
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kodanev @ 2014-12-04 17:20 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 runtest/kernel_misc                                |    2 +-
 testcases/kernel/device-drivers/Makefile           |    1 +
 testcases/kernel/device-drivers/acpi/.gitignore    |    1 -
 testcases/kernel/device-drivers/acpi/Makefile      |    4 +-
 .../kernel/device-drivers/acpi/ltp_acpi_cpufreq.c  |  177 --------------------
 testcases/kernel/device-drivers/cpufreq/.gitignore |    1 +
 testcases/kernel/device-drivers/cpufreq/Makefile   |   22 +++
 .../kernel/device-drivers/cpufreq/cpufreq_boost.c  |  177 ++++++++++++++++++++
 8 files changed, 203 insertions(+), 182 deletions(-)
 delete mode 100644 testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c
 create mode 100644 testcases/kernel/device-drivers/cpufreq/.gitignore
 create mode 100644 testcases/kernel/device-drivers/cpufreq/Makefile
 create mode 100644 testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c

diff --git a/runtest/kernel_misc b/runtest/kernel_misc
index 01b0acb..c12c31e 100644
--- a/runtest/kernel_misc
+++ b/runtest/kernel_misc
@@ -5,6 +5,6 @@ block_dev block_dev
 tpci tpci
 tbio tbio
 ltp_acpi ltp_acpi
-ltp_acpi_cpufreq ltp_acpi_cpufreq
+cpufreq_boost cpufreq_boost
 uaccess uaccess
 rcu_torture rcu_torture.sh
diff --git a/testcases/kernel/device-drivers/Makefile b/testcases/kernel/device-drivers/Makefile
index 37b6c64..a5a1745 100644
--- a/testcases/kernel/device-drivers/Makefile
+++ b/testcases/kernel/device-drivers/Makefile
@@ -20,6 +20,7 @@ include $(top_srcdir)/include/mk/env_pre.mk
 
 SUBDIRS		:= acpi \
 		   block \
+		   cpufreq \
 		   pci \
 		   rcu \
 		   rtc \
diff --git a/testcases/kernel/device-drivers/acpi/.gitignore b/testcases/kernel/device-drivers/acpi/.gitignore
index 4872ffd..6aa2c12 100644
--- a/testcases/kernel/device-drivers/acpi/.gitignore
+++ b/testcases/kernel/device-drivers/acpi/.gitignore
@@ -1,6 +1,5 @@
 /ltp_acpi_cmds.ko
 /ltp_acpi
-/ltp_acpi_cpufreq
 /*.mod.c
 /modules.order
 /.tmp_versions
diff --git a/testcases/kernel/device-drivers/acpi/Makefile b/testcases/kernel/device-drivers/acpi/Makefile
index 526604d..31bf26b 100644
--- a/testcases/kernel/device-drivers/acpi/Makefile
+++ b/testcases/kernel/device-drivers/acpi/Makefile
@@ -25,9 +25,7 @@ include $(top_srcdir)/include/mk/testcases.mk
 
 REQ_VERSION_MAJOR	:= 2
 REQ_VERSION_PATCH	:= 6
-MAKE_TARGETS		:= ltp_acpi_cpufreq ltp_acpi ltp_acpi_cmds.ko
-
-ltp_acpi_cpufreq: LDLIBS += -lrt
+MAKE_TARGETS		:= ltp_acpi ltp_acpi_cmds.ko
 
 include $(top_srcdir)/include/mk/module.mk
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c b/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c
deleted file mode 100644
index 423188e..0000000
--- a/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * Author: Alexey Kodanev <alexey.kodanev@oracle.com>
- *
- * Check support for disabling dynamic overclocking in acpi_cpufreq driver.
- * Required Linux 3.7+.
- *
- * The test compares time spent on sum calculation with/without
- * boost-disable bit. If boost is enabled we can get a slightly shorter
- * time period. Measure elapsed time instead of sysfs cpuinfo_cur_freq value,
- * because after the upstream commit 8673b83bf2f013379453b4779047bf3c6ae387e4,
- * current cpu frequency became target cpu frequency.
- */
-
-#define _GNU_SOURCE
-#include <sched.h>
-#include <time.h>
-
-#include "test.h"
-#include "usctest.h"
-#include "lapi/posix_clocks.h"
-#include "safe_macros.h"
-#include "safe_stdio.h"
-
-char *TCID = "ltp_acpi_cpufreq";
-
-#define SYSFS_CPU_DIR "/sys/devices/system/cpu/"
-
-const char boost[]	= SYSFS_CPU_DIR "cpufreq/boost";
-static int boost_value;
-
-const char governor[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_governor";
-static char governor_name[16];
-
-const char setspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_setspeed";
-const char maxspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_max_freq";
-
-static void cleanup(void)
-{
-	SAFE_FILE_PRINTF(NULL, boost, "%d", boost_value);
-
-	if (governor[0] != '\0')
-		SAFE_FILE_PRINTF(NULL, governor, "%s", governor_name);
-
-	TEST_CLEANUP;
-}
-
-static void setup(void)
-{
-	int fd;
-	tst_require_root(NULL);
-
-	fd = open(boost, O_RDWR);
-	if (fd == -1) {
-		tst_brkm(TCONF, NULL,
-			"acpi-cpufreq not loaded or overclock not supported");
-	}
-	close(fd);
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	SAFE_FILE_SCANF(NULL, boost, "%d", &boost_value);
-
-	/* change cpu0 scaling governor */
-	SAFE_FILE_SCANF(NULL, governor, "%s", governor_name);
-	SAFE_FILE_PRINTF(cleanup, governor, "%s", "userspace");
-
-	/* use only cpu0 */
-	cpu_set_t set;
-	CPU_ZERO(&set);
-	CPU_SET(0, &set);
-	if (sched_setaffinity(0, sizeof(cpu_set_t), &set) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "failed to set CPU0");
-
-	struct sched_param params;
-	params.sched_priority = sched_get_priority_max(SCHED_FIFO);
-	if (sched_setscheduler(getpid(), SCHED_FIFO, &params)) {
-		tst_resm(TWARN | TERRNO,
-			"failed to set FIFO sched with max priority");
-	}
-}
-
-static void set_speed(int freq)
-{
-	int set_freq;
-	SAFE_FILE_SCANF(cleanup, setspeed, "%d", &set_freq);
-
-	if (set_freq != freq) {
-		tst_resm(TINFO, "change target speed from %d KHz to %d KHz",
-			set_freq, freq);
-		SAFE_FILE_PRINTF(cleanup, setspeed, "%d", freq);
-	} else {
-		tst_resm(TINFO, "target speed is %d KHz", set_freq);
-	}
-}
-
-static int load_cpu(int max_freq_khz)
-{
-	int sum = 0, i = 0, total_time_ms;
-	struct timespec tv_start, tv_end;
-
-	const int max_sum = max_freq_khz / 1000;
-	const int units = 1000000; /* Mhz */
-
-	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_start);
-
-	do {
-		for (i = 0; i < units; ++i)
-			asm ("" : : : "memory");
-	} while (++sum < max_sum);
-
-	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_end);
-
-	total_time_ms = (tv_end.tv_sec - tv_start.tv_sec) * 1000 +
-		(tv_end.tv_nsec - tv_start.tv_nsec) / 1000000;
-
-	if (!total_time_ms)
-		tst_brkm(TBROK, cleanup, "time period is 0");
-
-	tst_resm(TINFO, "elapsed time is %d ms", total_time_ms);
-
-	return total_time_ms;
-}
-
-static void test_run(void)
-{
-	int boost_time, boost_off_time, max_freq_khz;
-	SAFE_FILE_SCANF(cleanup, maxspeed, "%d", &max_freq_khz);
-	set_speed(max_freq_khz);
-
-	/* Enable boost */
-	if (boost_value == 0)
-		SAFE_FILE_PRINTF(cleanup, boost, "1");
-	tst_resm(TINFO, "load CPU0 with boost enabled");
-	boost_time = load_cpu(max_freq_khz);
-
-	/* Disable boost */
-	SAFE_FILE_PRINTF(cleanup, boost, "0");
-	tst_resm(TINFO, "load CPU0 with boost disabled");
-	boost_off_time = load_cpu(max_freq_khz);
-
-	boost_off_time *= .98;
-
-	tst_resm((boost_time < boost_off_time) ? TPASS : TFAIL,
-		"compare time spent with and without boost (-2%%)");
-}
-
-int main(int argc, char *argv[])
-{
-	const char *msg;
-	msg = parse_opts(argc, argv, NULL, NULL);
-	if (msg != NULL)
-		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-
-	setup();
-
-	test_run();
-
-	cleanup();
-
-	tst_exit();
-}
diff --git a/testcases/kernel/device-drivers/cpufreq/.gitignore b/testcases/kernel/device-drivers/cpufreq/.gitignore
new file mode 100644
index 0000000..ee09908
--- /dev/null
+++ b/testcases/kernel/device-drivers/cpufreq/.gitignore
@@ -0,0 +1 @@
+/cpufreq_boost
diff --git a/testcases/kernel/device-drivers/cpufreq/Makefile b/testcases/kernel/device-drivers/cpufreq/Makefile
new file mode 100644
index 0000000..3021d22
--- /dev/null
+++ b/testcases/kernel/device-drivers/cpufreq/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+top_srcdir	?= ../../../..
+include $(top_srcdir)/include/mk/testcases.mk
+
+LDLIBS += -lrt
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
new file mode 100644
index 0000000..423188e
--- /dev/null
+++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+ *
+ * Check support for disabling dynamic overclocking in acpi_cpufreq driver.
+ * Required Linux 3.7+.
+ *
+ * The test compares time spent on sum calculation with/without
+ * boost-disable bit. If boost is enabled we can get a slightly shorter
+ * time period. Measure elapsed time instead of sysfs cpuinfo_cur_freq value,
+ * because after the upstream commit 8673b83bf2f013379453b4779047bf3c6ae387e4,
+ * current cpu frequency became target cpu frequency.
+ */
+
+#define _GNU_SOURCE
+#include <sched.h>
+#include <time.h>
+
+#include "test.h"
+#include "usctest.h"
+#include "lapi/posix_clocks.h"
+#include "safe_macros.h"
+#include "safe_stdio.h"
+
+char *TCID = "ltp_acpi_cpufreq";
+
+#define SYSFS_CPU_DIR "/sys/devices/system/cpu/"
+
+const char boost[]	= SYSFS_CPU_DIR "cpufreq/boost";
+static int boost_value;
+
+const char governor[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_governor";
+static char governor_name[16];
+
+const char setspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_setspeed";
+const char maxspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_max_freq";
+
+static void cleanup(void)
+{
+	SAFE_FILE_PRINTF(NULL, boost, "%d", boost_value);
+
+	if (governor[0] != '\0')
+		SAFE_FILE_PRINTF(NULL, governor, "%s", governor_name);
+
+	TEST_CLEANUP;
+}
+
+static void setup(void)
+{
+	int fd;
+	tst_require_root(NULL);
+
+	fd = open(boost, O_RDWR);
+	if (fd == -1) {
+		tst_brkm(TCONF, NULL,
+			"acpi-cpufreq not loaded or overclock not supported");
+	}
+	close(fd);
+
+	tst_sig(FORK, DEF_HANDLER, cleanup);
+
+	SAFE_FILE_SCANF(NULL, boost, "%d", &boost_value);
+
+	/* change cpu0 scaling governor */
+	SAFE_FILE_SCANF(NULL, governor, "%s", governor_name);
+	SAFE_FILE_PRINTF(cleanup, governor, "%s", "userspace");
+
+	/* use only cpu0 */
+	cpu_set_t set;
+	CPU_ZERO(&set);
+	CPU_SET(0, &set);
+	if (sched_setaffinity(0, sizeof(cpu_set_t), &set) < 0)
+		tst_brkm(TBROK | TERRNO, cleanup, "failed to set CPU0");
+
+	struct sched_param params;
+	params.sched_priority = sched_get_priority_max(SCHED_FIFO);
+	if (sched_setscheduler(getpid(), SCHED_FIFO, &params)) {
+		tst_resm(TWARN | TERRNO,
+			"failed to set FIFO sched with max priority");
+	}
+}
+
+static void set_speed(int freq)
+{
+	int set_freq;
+	SAFE_FILE_SCANF(cleanup, setspeed, "%d", &set_freq);
+
+	if (set_freq != freq) {
+		tst_resm(TINFO, "change target speed from %d KHz to %d KHz",
+			set_freq, freq);
+		SAFE_FILE_PRINTF(cleanup, setspeed, "%d", freq);
+	} else {
+		tst_resm(TINFO, "target speed is %d KHz", set_freq);
+	}
+}
+
+static int load_cpu(int max_freq_khz)
+{
+	int sum = 0, i = 0, total_time_ms;
+	struct timespec tv_start, tv_end;
+
+	const int max_sum = max_freq_khz / 1000;
+	const int units = 1000000; /* Mhz */
+
+	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_start);
+
+	do {
+		for (i = 0; i < units; ++i)
+			asm ("" : : : "memory");
+	} while (++sum < max_sum);
+
+	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_end);
+
+	total_time_ms = (tv_end.tv_sec - tv_start.tv_sec) * 1000 +
+		(tv_end.tv_nsec - tv_start.tv_nsec) / 1000000;
+
+	if (!total_time_ms)
+		tst_brkm(TBROK, cleanup, "time period is 0");
+
+	tst_resm(TINFO, "elapsed time is %d ms", total_time_ms);
+
+	return total_time_ms;
+}
+
+static void test_run(void)
+{
+	int boost_time, boost_off_time, max_freq_khz;
+	SAFE_FILE_SCANF(cleanup, maxspeed, "%d", &max_freq_khz);
+	set_speed(max_freq_khz);
+
+	/* Enable boost */
+	if (boost_value == 0)
+		SAFE_FILE_PRINTF(cleanup, boost, "1");
+	tst_resm(TINFO, "load CPU0 with boost enabled");
+	boost_time = load_cpu(max_freq_khz);
+
+	/* Disable boost */
+	SAFE_FILE_PRINTF(cleanup, boost, "0");
+	tst_resm(TINFO, "load CPU0 with boost disabled");
+	boost_off_time = load_cpu(max_freq_khz);
+
+	boost_off_time *= .98;
+
+	tst_resm((boost_time < boost_off_time) ? TPASS : TFAIL,
+		"compare time spent with and without boost (-2%%)");
+}
+
+int main(int argc, char *argv[])
+{
+	const char *msg;
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	test_run();
+
+	cleanup();
+
+	tst_exit();
+}
-- 
1.7.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] device-drivers/cpufreq: add intel_pstate driver to boost test
  2014-12-04 17:20 [LTP] [PATCH 1/2] device-drivers/ltp_acpi_cpufreq: move it to cpufreq/cpufreq_boost Alexey Kodanev
@ 2014-12-04 17:20 ` Alexey Kodanev
  2014-12-08 11:42   ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kodanev @ 2014-12-04 17:20 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 .../kernel/device-drivers/cpufreq/cpufreq_boost.c  |   67 +++++++++++---------
 1 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
index 423188e..941e4db 100644
--- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
+++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
+ * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -37,22 +37,33 @@
 #include "safe_macros.h"
 #include "safe_stdio.h"
 
-char *TCID = "ltp_acpi_cpufreq";
+char *TCID = "cpufreq_boost";
 
 #define SYSFS_CPU_DIR "/sys/devices/system/cpu/"
 
-const char boost[]	= SYSFS_CPU_DIR "cpufreq/boost";
+struct cpufreq_driver_info {
+	char *name;
+	int off;
+	char *on_str;
+	char *off_str;
+	char *file;
+};
+static const struct cpufreq_driver_info cdrv[] = {
+	{ "acpi_cpufreq", 0, "1", "0", SYSFS_CPU_DIR "cpufreq/boost" },
+	{ "intel_pstate", 1, "0", "1", SYSFS_CPU_DIR "intel_pstate/no_turbo" },
+};
+static int id = -1;
+
 static int boost_value;
 
 const char governor[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_governor";
 static char governor_name[16];
 
-const char setspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_setspeed";
 const char maxspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_max_freq";
 
 static void cleanup(void)
 {
-	SAFE_FILE_PRINTF(NULL, boost, "%d", boost_value);
+	SAFE_FILE_PRINTF(NULL, cdrv[id].file, "%d", boost_value);
 
 	if (governor[0] != '\0')
 		SAFE_FILE_PRINTF(NULL, governor, "%s", governor_name);
@@ -63,22 +74,32 @@ static void cleanup(void)
 static void setup(void)
 {
 	int fd;
+	unsigned int i;
 	tst_require_root(NULL);
 
-	fd = open(boost, O_RDWR);
-	if (fd == -1) {
-		tst_brkm(TCONF, NULL,
-			"acpi-cpufreq not loaded or overclock not supported");
+	for (i = 0; i < ARRAY_SIZE(cdrv); ++i) {
+		fd = open(cdrv[i].file, O_RDWR);
+		if (fd == -1)
+			continue;
+
+		id = i;
+		close(fd);
+		break;
 	}
-	close(fd);
+
+	if (id == -1)
+		tst_brkm(TCONF, NULL, "overclock not supported");
+
+	tst_resm(TINFO, "found '%s' driver, sysfs knob '%s'",
+		cdrv[id].name, cdrv[id].file);
 
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-	SAFE_FILE_SCANF(NULL, boost, "%d", &boost_value);
+	SAFE_FILE_SCANF(NULL, cdrv[i].file, "%d", &boost_value);
 
 	/* change cpu0 scaling governor */
 	SAFE_FILE_SCANF(NULL, governor, "%s", governor_name);
-	SAFE_FILE_PRINTF(cleanup, governor, "%s", "userspace");
+	SAFE_FILE_PRINTF(cleanup, governor, "%s", "performance");
 
 	/* use only cpu0 */
 	cpu_set_t set;
@@ -95,20 +116,6 @@ static void setup(void)
 	}
 }
 
-static void set_speed(int freq)
-{
-	int set_freq;
-	SAFE_FILE_SCANF(cleanup, setspeed, "%d", &set_freq);
-
-	if (set_freq != freq) {
-		tst_resm(TINFO, "change target speed from %d KHz to %d KHz",
-			set_freq, freq);
-		SAFE_FILE_PRINTF(cleanup, setspeed, "%d", freq);
-	} else {
-		tst_resm(TINFO, "target speed is %d KHz", set_freq);
-	}
-}
-
 static int load_cpu(int max_freq_khz)
 {
 	int sum = 0, i = 0, total_time_ms;
@@ -141,16 +148,16 @@ static void test_run(void)
 {
 	int boost_time, boost_off_time, max_freq_khz;
 	SAFE_FILE_SCANF(cleanup, maxspeed, "%d", &max_freq_khz);
-	set_speed(max_freq_khz);
+	tst_resm(TINFO, "maximum speed is %d KHz", max_freq_khz);
 
 	/* Enable boost */
-	if (boost_value == 0)
-		SAFE_FILE_PRINTF(cleanup, boost, "1");
+	if (boost_value == cdrv[id].off)
+		SAFE_FILE_PRINTF(cleanup, cdrv[id].file, cdrv[id].on_str);
 	tst_resm(TINFO, "load CPU0 with boost enabled");
 	boost_time = load_cpu(max_freq_khz);
 
 	/* Disable boost */
-	SAFE_FILE_PRINTF(cleanup, boost, "0");
+	SAFE_FILE_PRINTF(cleanup, cdrv[id].file, cdrv[id].off_str);
 	tst_resm(TINFO, "load CPU0 with boost disabled");
 	boost_off_time = load_cpu(max_freq_khz);
 
-- 
1.7.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 2/2] device-drivers/cpufreq: add intel_pstate driver to boost test
  2014-12-04 17:20 ` [LTP] [PATCH 2/2] device-drivers/cpufreq: add intel_pstate driver to boost test Alexey Kodanev
@ 2014-12-08 11:42   ` Cyril Hrubis
       [not found]     ` <5485D893.4030403@oracle.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2014-12-08 11:42 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

On Thu, Dec 04, 2014 at 08:20:57PM +0300, Alexey Kodanev wrote:
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
>  .../kernel/device-drivers/cpufreq/cpufreq_boost.c  |   67 +++++++++++---------
>  1 files changed, 37 insertions(+), 30 deletions(-)
> 
> diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> index 423188e..941e4db 100644
> --- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> +++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
> + * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.

This should rather be "Copyright (c) 2013-2014 ..."

>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License as
> @@ -37,22 +37,33 @@
>  #include "safe_macros.h"
>  #include "safe_stdio.h"
>  
> -char *TCID = "ltp_acpi_cpufreq";
> +char *TCID = "cpufreq_boost";
>  
>  #define SYSFS_CPU_DIR "/sys/devices/system/cpu/"
>  
> -const char boost[]	= SYSFS_CPU_DIR "cpufreq/boost";
> +struct cpufreq_driver_info {
> +	char *name;
> +	int off;
> +	char *on_str;
> +	char *off_str;
> +	char *file;
> +};
> +static const struct cpufreq_driver_info cdrv[] = {
> +	{ "acpi_cpufreq", 0, "1", "0", SYSFS_CPU_DIR "cpufreq/boost" },
> +	{ "intel_pstate", 1, "0", "1", SYSFS_CPU_DIR "intel_pstate/no_turbo" },
> +};
> +static int id = -1;
> +
>  static int boost_value;
>  
>  const char governor[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_governor";
>  static char governor_name[16];
>  
> -const char setspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_setspeed";
>  const char maxspeed[]	= SYSFS_CPU_DIR "cpu0/cpufreq/scaling_max_freq";
>  
>  static void cleanup(void)
>  {
> -	SAFE_FILE_PRINTF(NULL, boost, "%d", boost_value);
> +	SAFE_FILE_PRINTF(NULL, cdrv[id].file, "%d", boost_value);
>  
>  	if (governor[0] != '\0')
>  		SAFE_FILE_PRINTF(NULL, governor, "%s", governor_name);
> @@ -63,22 +74,32 @@ static void cleanup(void)
>  static void setup(void)
>  {
>  	int fd;
> +	unsigned int i;
>  	tst_require_root(NULL);
>  
> -	fd = open(boost, O_RDWR);
> -	if (fd == -1) {
> -		tst_brkm(TCONF, NULL,
> -			"acpi-cpufreq not loaded or overclock not supported");
> +	for (i = 0; i < ARRAY_SIZE(cdrv); ++i) {
> +		fd = open(cdrv[i].file, O_RDWR);
> +		if (fd == -1)
> +			continue;
> +
> +		id = i;
> +		close(fd);

Will simple access() suffice here or do we have to actually open the
file?


Otherwise it looks Ok.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 2/2] device-drivers/cpufreq: add intel_pstate driver to boost test
       [not found]     ` <5485D893.4030403@oracle.com>
@ 2014-12-08 18:02       ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2014-12-08 18:02 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> > Will simple access() suffice here or do we have to actually open the
> > file?
> 
> We have to open it, it was changed from access to open in this commit:
> 
> commit 0a91955ab91bf518ff56a44bb2969b0cb549a979
> Date:   Wed May 7 17:03:33 2014 +0400
> 
>      device-drivers/acpi/ltp_acpi_cpufreq: fix checking for write permission
> 
>      If access(some_file, W_OK) is executed by root it will return 
> success even
>      if file has read-only permission. Use 'open' to test sysfs file for 
> write
>      permission.
> 
> Doc updated as well:
> 
> commit fb3da0a1f3a4f1b836e50033cb8acf7c6d0c5a05
> Date:   Tue May 13 15:34:32 2014 +0400
> 
>      docs: add a paragraph about access() to Common Problems section

Ah, right, deja vu.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-08 18:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-04 17:20 [LTP] [PATCH 1/2] device-drivers/ltp_acpi_cpufreq: move it to cpufreq/cpufreq_boost Alexey Kodanev
2014-12-04 17:20 ` [LTP] [PATCH 2/2] device-drivers/cpufreq: add intel_pstate driver to boost test Alexey Kodanev
2014-12-08 11:42   ` Cyril Hrubis
     [not found]     ` <5485D893.4030403@oracle.com>
2014-12-08 18:02       ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox