[systemd-devel] Real-time scheduling doesn't work with StartupCPUWeight/CPUWeight

Robert Tiemann rtie at gmx.de
Wed Sep 14 13:03:22 UTC 2022


Hi!

I have optimized boot times for an embedded system by setting
StartupCPUWeight= and CPUWeight= for a few services. The startup
values are set to various values. All unit files I have touched also
contain the line "CPUWeight=100" so that the system is running with
defaults after startup. Some unit files contain Nice= assignments
(placed there before my optimizations, so I kept them in place).

Now, the problem is with one process in the system which requires
real-time priorities. It calls pthread_setschedparam() to configure
two of its threads for SCHED_RR policy at priority 99. This used to
work before my optimizations, but now pthread_setschedparam() fails
with EPERM error. I have added LimitRTPRIO=infinity, but it still
doesn't work. The threads are created and configured after the startup
phase has finished.

Removing the StartupCPUWeight= and CPUWeight= lines from all unit
files allows pthread_setschedparam() to succeed. It starts failing
when setting StartupCPUWeight= even for a single, unrelated service.

How can I have an optimized startup and still have real-time
priorities in that process?

The system is running systemd 250.5.

Best regards,
Robert


More information about the systemd-devel mailing list