A question about CFS

A question about CFS

Oleg Goldshmidt pub at goldshmidt.org
Tue Jun 9 21:37:49 IDT 2009


Shachar Shemesh <shachar at shemesh.biz> writes:

> Hi all,
> I'm trying to understand Linux's Completely Fair Scheduler better

Hi,

Disclaimer: i've never had a chance to look at the CFS nearly as
closely as the previous incarnation ["O(1)"]. I'll take a shot, though.

>    1.  How do the different priorities factor in? 

My understanding is that CFS is within a single priority level.

>      Obviously, the real time priorities do not (their scheduling
>      methods are well defined), but how about the nice values? The
>      "fair clock" is a property of "rq" (run queue)
>      - does that mean that each nice value has its own queue?

Yes, as in O(1). The implementation of the runqueue has changed in
CFS.
 
> If so, how do the relative priorities happen?

I am not sure what you mean by "relative priorities". Do you mean,
"niceness"? If so, there is a simple mapping of niceness to priority
in kernel/sched.c (unchanged from O(1)):

/*
 * Convert user-nice values [ -20 ... 0 ... 19 ]
 * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
 * and back.
 */
#define NICE_TO_PRIO(nice)      (MAX_RT_PRIO + (nice) + 20)
#define PRIO_TO_NICE(prio)      ((prio) - MAX_RT_PRIO - 20)
#define TASK_NICE(p)            PRIO_TO_NICE((p)->static_prio)
  

>    2.  Are those "all processes in the system", or just "ready
>        processes in the system"?

Only ready or running processes are scheduled - others don't even want
the CPU.

>      Wikipedia says that CFS treats wait time due to "sorry, no CPU
>      for you" and wait time due to "I don't need the CPU right now"
>      the same, so this suggests all processes.

I suspect you are a bit confused here, though it sounds like you've
made the right guess below. Accounting for sleep time when
deciding whom to give the CPU the soonest is related to recognizing
interactive processes: they typically sleep a lot waiting for user
input and such. In the O(1) scheduler such processes are allocated
additional time slices in the current epoch, in CFS their "fair share"
of the CPU is increased accordingly.

>    3.  The articles say that CFS gives extra priority for
>        interactive processes, but does not mention how. Is this just
>        a by product of the wall time - wait time calculation (makes
>        sense), or is there any additional tweaking going on that
>        does that?

See above.

-- 
Oleg Goldshmidt | pub at goldshmidt.org



More information about the Linux-il mailing list