CFS: quantifying effect of nice value on scheduled CPU time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



CFS:

>From my reading of the source, the 'nice'/static priority of a
SCHED_NORMAL task is used by the CFS scheduler by mapping it to a
weight (https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/kernel/sched/sched.h?id=refs/tags/v3.10.94#n918).
This weight comes in to play in 2 main areas:

1) When adjusting the currently running task's 'vruntime' :
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/kernel/sched/fair.c?id=84bb5b645ec5a54744180a1edc5dc72adc862457#n680

When the 'vruntime' is being updated for a task I see that if the
task's 'nice' value is less than 0 the execution time delta added to
its 'vruntime' is less than its actual execution time. Similarly, for
task's with 'nice' values greater than 0 the execution time delta
added to its 'vruntime' is larger than its actual execution time.

Essentially, vruntime = actual_execution_delta * NICE_0_LOAD / task_weight


2) When computing the ideal amount of time a task should execute
within a scheduling period:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/kernel/sched/fair.c?id=84bb5b645ec5a54744180a1edc5dc72adc862457#n650

It seems a task's ideal execution time is determined by its weight
relative to the total weight of all tasks on the same runqueue:
 ideal_execution_time = scheduling_period * task_weight /
total_weight_of_all_tasks_on_runqueue

With (1) and (2) above I don't exactly see how the comments above the
weight array definition are consistent with this:

/*
 * Nice levels are multiplicative, with a gentle 10% change for every
 * nice level changed. I.e. when a CPU-bound task goes from nice 0 to
 * nice 1, it will get ~10% less CPU time than another CPU-bound task
 * that remained on nice 0.
 *
 * The "10% effect" is relative and cumulative: from _any_ nice level,
 * if you go up 1 level, it's -10% CPU usage, if you go down 1 level
 * it's +10% CPU usage. (to achieve that we use a multiplier of 1.25.
 * If a task goes up by ~10% and another task goes down by ~10% then
 * the relative distance between them is ~25%.)
 */
static const int prio_to_weight[40] = {

If I take an example of 2 tasks both with weight=1024 (NICE_0) they
should each get 50% of the CPU time. If 1 of the tasks is reniced to
NICE_1 then the NICE_0 task will get 1024/(1024+820)=56% of the CPU
time and  the NICE_1 task will get 44% of the CPU time. I'm obviously
not understanding something since I can't come at those 10% figures in
the comments.

tl;dr: How does going from 1 nice level to the next get you to the 10%
figure mentioned in the comments of the 'prio_to_weight[]' above?

Thanks.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux