sched_setscheduler call fails with EPERM

Posted on

We are trying set real time priority for a given process by using sched_setscheduler call. This process gets spawned through one of the services in the systemctl .
This call works perfectly fine if docker daemon is not running on the system. Once the docker daemon starts, the sched_setscheduler call starts failing with EPERM i.e. Operation not permitted).

Version-Release number:
OS Version : RHEL 7.3
Docker Version : 1.13.0

We got it working by setting cpu.rt_cputime_us value in /sys/fs/cgroup/cpu/system.slice/user-sample.service/cpu.rt_cputime_us
This was set to 0 by default.

Before starting the service, the value of cpu.rt_runtime_us was 950000 in /sys/fs/cgroup/cpu/cpu.rt_runtime_us

cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us

950000

But the value in system.slice was set to 0.

cat /sys/fs/cgroup/cpu/system.slice/cpu.rt_runtime_us

0

When service user-sample.service was started, it was pulled into /sys/fs/cgroup/cpu/system.slice/, and the value of cpu.rt_runtime_us remained 0.

cat /sys/fs/cgroup/cpu/system.slice/user-sample.service/cpu.rt_runtime_us

0

If we set the value of cpu.rt_runtime_us at both /sys/fs/cgroup/cpu/system.slice/cpu.rt_runtime_us
and /sys/fs/cgroup/cpu/system.slice/user-sample.service/cpu.rt_runtime_us, it works fine.

We also noticed that for other parameter cpu.rt_period_us, the default value of 1000000, gets updated at all the levels i.e. both at
"/sys/fs/cgroup/cpu/system.slice/" and "/sys/fs/cgroup/cpu/system.slice/user-sample.service".

Same is not true for parameter cpu.rt_runtime_us.
Is it expected behavior? Does one has to set this parameter manually everytime a service is started?
Looks like on your system these values were set by default or is it some configuration which we are missing?

Thanks & Regards,

Responses