Linux – ionice `none: prio 0` equivalent to

ionicelinux

The ionice manual states that:

Note that before kernel 2.6.26 a process that has not asked for an io
priority formally uses "none" as scheduling class, but the io
scheduler will treat such processes as if it were in the best effort
class. The priority within the best effort class will be dynamically
derived from the cpu nice level of the process: io_priority =
(cpu_nice + 20) / 5.

For kernels after 2.6.26 with CFQ io scheduler a process that has not asked for an io priority inherits CPU scheduling class. The io
priority is derived from the cpu nice level of the process (same as
before kernel 2.6.26).

I am post 2.6.26, but that still leaves some open questions (I'm assuming CFQ):

  1. What is the inheritance mapping for the scheduled class? Does TS SCHED_OTHER = Best Effort (io class 2)?

  2. When using the ionice -p command to get the value, it returns none: prio 0. However, the formula mentioned in the ionice man would suggest that the same process (cpu nice of zero) would be best-effort: prio 4 since (0 + 20) / 5 = 4.

So my assumption at this point is that none: prio 0 = best-effort: prio 4, but I'm hoping someone can cite some kernel source in order to prove that this is authoritatively true.

Best Answer

1) From the docs sched-design-CFS.txt:

CFS stands for "Completely Fair Scheduler," and is the new "desktop" process scheduler implemented by Ingo Molnar and merged in Linux 2.6.23. It is the replacement for the previous vanilla scheduler's SCHED_OTHER interactivity code.

It seems you mixing up the O(1) scheduler with the CFQ io-scheduler.

So there are SCHED_{NORMAL, BATCH, IDLE} policies. IDLE does not have any priorities. And sched classes idle, best-effort and realtime.

2) Sadly you do not show what commands you typed. For example change init's io-scheduling to best-effort class

# ionice -p 1
none: prio 0
# ionice -c2 20 -p 1
# ionice -p 1
best-effort: prio 4