[CRIU] [PATCH] zdtm: set cpu.cfs_period_us to 100 during sched_policy00 test

Adrian Reber adrian at lisas.de
Tue Dec 6 06:45:42 PST 2016


From: Adrian Reber <areber at redhat.com>

To run the test zdtm/static/sched_policy00
/sys/fs/cgroup/cpu/user.slice/cpu.cfs_period_us needs to be non zero.
This changes it to 100 during the test and resets it to the original
value once the test finishes.

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 test/zdtm/static/sched_policy00.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/test/zdtm/static/sched_policy00.c b/test/zdtm/static/sched_policy00.c
index 9fe89a1..7312abd 100644
--- a/test/zdtm/static/sched_policy00.c
+++ b/test/zdtm/static/sched_policy00.c
@@ -6,6 +6,7 @@
 #include <signal.h>
 #include <string.h>
 #include <sched.h>
+#include <stdio.h>
 
 #include "zdtmtst.h"
 
@@ -26,6 +27,8 @@ int main(int argc, char ** argv)
 {
 	int pid, ret, err = 0;
 	struct sched_param p;
+	int old_rt_runtime_us = -1;
+	FILE *file;
 
 	test_init(argc, argv);
 
@@ -33,6 +36,20 @@ int main(int argc, char ** argv)
 	if (!pid)
 		return do_nothing();
 
+	file = fopen("/sys/fs/cgroup/cpu/user.slice/cpu.rt_runtime_us", "r");
+	if (file) {
+		ret = fscanf(file, "%d", &old_rt_runtime_us);
+		fclose(file);
+
+		if ((ret > 0) && (old_rt_runtime_us == 0)) {
+			file = fopen("/sys/fs/cgroup/cpu/user.slice/cpu.rt_runtime_us", "w");
+			if (file) {
+				fprintf(file, "100\n");
+				fclose(file);
+			}
+		}
+	}
+
 	p.sched_priority = parm;
 	if (sched_setscheduler(pid, SCHED_RR, &p)) {
 		pr_perror("Can't set policy");
@@ -59,5 +76,13 @@ int main(int argc, char ** argv)
 		pass();
 
 	kill(pid, SIGKILL);
+	if (old_rt_runtime_us != -1) {
+		file = fopen("/sys/fs/cgroup/cpu/user.slice/cpu.rt_runtime_us", "w");
+		if (file) {
+			fprintf(file, "%d\n", old_rt_runtime_us);
+			fclose(file);
+		}
+
+	}
 	return err;
 }
-- 
2.9.3



More information about the CRIU mailing list