Commit 3e153605 authored by Adrian Reber's avatar Adrian Reber Committed by Pavel Emelyanov

zdtm: set cpu.cfs_period_us to 100 during sched_policy00 test

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.

travis-ci: success for zdtm: set cpu.cfs_period_us to 100 during sched_policy00 test
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent b108c752
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <sched.h> #include <sched.h>
#include <stdio.h>
#include "zdtmtst.h" #include "zdtmtst.h"
...@@ -26,6 +27,8 @@ int main(int argc, char ** argv) ...@@ -26,6 +27,8 @@ int main(int argc, char ** argv)
{ {
int pid, ret, err = 0; int pid, ret, err = 0;
struct sched_param p; struct sched_param p;
int old_rt_runtime_us = -1;
FILE *file;
test_init(argc, argv); test_init(argc, argv);
...@@ -33,6 +36,20 @@ int main(int argc, char ** argv) ...@@ -33,6 +36,20 @@ int main(int argc, char ** argv)
if (!pid) if (!pid)
return do_nothing(); 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; p.sched_priority = parm;
if (sched_setscheduler(pid, SCHED_RR, &p)) { if (sched_setscheduler(pid, SCHED_RR, &p)) {
pr_perror("Can't set policy"); pr_perror("Can't set policy");
...@@ -59,5 +76,13 @@ int main(int argc, char ** argv) ...@@ -59,5 +76,13 @@ int main(int argc, char ** argv)
pass(); pass();
kill(pid, SIGKILL); 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; return err;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment