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_FIFO and 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_FIFO/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:
I did some more digging, and found this kernel scheduler documentation, also by digging in the sched sources a bit it seems SCHED_BATCH is indeed handled by the same code as SCHED_OTHER.
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 SCHED_IDLE!
But it seems from the docs I linked above, SCHED_IDLE may be also handled by the same code as SCHED_OTHER and 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 SCHED_OTHER instead!
if()statements but there isn't a real code definition that I have found. Alt. Some very old discussions lead me to think it is basically sched_idle but able to preempt a sched_idle. (An idle cannot preempt another idle, they only get a turn when the scheduling timer comes around) sched_idle still uses the sched_normal RB-tree but equivalent to nice value 25.(not a true idle class to avoid possible deadlocks)