There are several scheduling options in Linux, which can be set to a process with the help of a
chrt command line. And I can't seem to grasp one of them... Which is
SCHED_BATCH. In fact, it's description contradicts itself in several sources. But before, I'll summarize the facts I managed to get about all the scheduling options, as the different descriptions of
SCHED_BATCH references them.
SCHED_RR are basically real-time scheduling policies, with slight differences, no questions here mostly, they are always run first before any other processes.
SCHED_OTHER is the default policy, relying on
nice values of per process to assign priorities.
SCHED_DEADLINE - I haven't completely understood this one, it seems to be actually closer to
SCHED_FIFO but with set timers of execution, and may actually preempt
SCHED_RR tasks if those timers are reached.
SCHED_IDLE - basically "schedule only if otherwise the CPU would be idling", no questions here.
And now, there is
SCHED_BATCH, which I found out that is quite controversial. On one hand, in the original implementations notes back from 2002 it is said it's basically the same as
SCHED_IDLE for user code and
SCHED_OTHER for kernel code (to avoid kernel resources lock-up due to a process never being scheduled). In the MAN articles though it is said it's basically the same as
SCHED_OTHER but with a small penalty because it is considered CPU-bound.
Now, theese two
SCHED_BATCH explanations are not coherent one with another. Which one is the truth? Did
SCHED_BATCH got reimplemented somewhere along the way? Or someone misunderstood
SCHED_BATCH when was writing the MAN article? Which of the explanations is the true one?
UPDATE: additional research:
There's still a test I did. I have a process which was actually throttling other processes because of it's high load even with nice 19, but default
SCHED_OTHER setting. I've set it up as
SCHED_IDLE, and the problem of the throttling of the other processes was gone... And then I decided to try out
SCHED_BATCH for the same process (with the same nice 19 setting). And surprisingly enough,
SCHED_BATCH also didn't throttle my other processes, like
But it seems from the docs I linked above,
SCHED_IDLE may be also handled by the same code as
SCHED_BATCH, but with super-low priority. Although I'm kinda still lost in which cases it does use CFS (which is
SCHED_OTHER main implementation), and in which cases it uses the kernel/sched/idle.c implementation.
I definitely still don't have any conclusive answer, the tests and documentations are still not making too much sense to me. Tests showed that
SCHED_BATCH worked like actually
SCHED_IDLE would, but all documentation tells that it should work like