Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/fair: Rename cfs_rq::avg_load to cfs_rq::sum_weight

The ::avg_load field is a long-standing misnomer: it says it's an
'average load', but in reality it's the momentary sum of the load
of all currently runnable tasks. We'd have to also perform a
division by nr_running (or use time-decay) to arrive at any sort
of average value.

This is clear from comments about the math of fair scheduling:

* \Sum w_i := cfs_rq->avg_load

The sum of all weights is ... the sum of all weights, not
the average of all weights.

To make it doubly confusing, there's also an ::avg_load
in the load-balancing struct sg_lb_stats, which *is* a
true average.

The second part of the field's name is a minor misnomer
as well: it says 'load', and it is indeed a load_weight
structure as it shares code with the load-balancer - but
it's only in an SMP load-balancing context where
load = weight, in the fair scheduling context the primary
purpose is the weighting of different nice levels.

So rename the field to ::sum_weight instead, which makes
the terminology of the EEVDF math match up with our
implementation of it:

* \Sum w_i := cfs_rq->sum_weight

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://patch.msgid.link/20251201064647.1851919-6-mingo@kernel.org

+9 -9
+8 -8
kernel/sched/fair.c
··· 608 608 * 609 609 * v0 := cfs_rq->zero_vruntime 610 610 * \Sum (v_i - v0) * w_i := cfs_rq->avg_vruntime 611 - * \Sum w_i := cfs_rq->avg_load 611 + * \Sum w_i := cfs_rq->sum_weight 612 612 * 613 613 * Since zero_vruntime closely tracks the per-task service, these 614 614 * deltas: (v_i - v), will be in the order of the maximal (virtual) lag ··· 625 625 s64 key = entity_key(cfs_rq, se); 626 626 627 627 cfs_rq->avg_vruntime += key * weight; 628 - cfs_rq->avg_load += weight; 628 + cfs_rq->sum_weight += weight; 629 629 } 630 630 631 631 static void ··· 635 635 s64 key = entity_key(cfs_rq, se); 636 636 637 637 cfs_rq->avg_vruntime -= key * weight; 638 - cfs_rq->avg_load -= weight; 638 + cfs_rq->sum_weight -= weight; 639 639 } 640 640 641 641 static inline 642 642 void avg_vruntime_update(struct cfs_rq *cfs_rq, s64 delta) 643 643 { 644 644 /* 645 - * v' = v + d ==> avg_vruntime' = avg_runtime - d*avg_load 645 + * v' = v + d ==> avg_vruntime' = avg_runtime - d*sum_weight 646 646 */ 647 - cfs_rq->avg_vruntime -= cfs_rq->avg_load * delta; 647 + cfs_rq->avg_vruntime -= cfs_rq->sum_weight * delta; 648 648 } 649 649 650 650 /* ··· 655 655 { 656 656 struct sched_entity *curr = cfs_rq->curr; 657 657 s64 avg = cfs_rq->avg_vruntime; 658 - long load = cfs_rq->avg_load; 658 + long load = cfs_rq->sum_weight; 659 659 660 660 if (curr && curr->on_rq) { 661 661 unsigned long weight = scale_load_down(curr->load.weight); ··· 723 723 { 724 724 struct sched_entity *curr = cfs_rq->curr; 725 725 s64 avg = cfs_rq->avg_vruntime; 726 - long load = cfs_rq->avg_load; 726 + long load = cfs_rq->sum_weight; 727 727 728 728 if (curr && curr->on_rq) { 729 729 unsigned long weight = scale_load_down(curr->load.weight); ··· 5131 5131 * 5132 5132 * vl_i = (W + w_i)*vl'_i / W 5133 5133 */ 5134 - load = cfs_rq->avg_load; 5134 + load = cfs_rq->sum_weight; 5135 5135 if (curr && curr->on_rq) 5136 5136 load += scale_load_down(curr->load.weight); 5137 5137
+1 -1
kernel/sched/sched.h
··· 679 679 unsigned int h_nr_idle; /* SCHED_IDLE */ 680 680 681 681 s64 avg_vruntime; 682 - u64 avg_load; 682 + u64 sum_weight; 683 683 684 684 u64 zero_vruntime; 685 685 #ifdef CONFIG_SCHED_CORE