Skip to content

Commit 0dacee1

Browse files
vingu-linaroingomolnar
authored andcommitted
sched/pelt: Remove unused runnable load average
Now that runnable_load_avg is no more used, we can remove it to make space for a new signal. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Mel Gorman <mgorman@techsingularity.net> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: "Dietmar Eggemann <dietmar.eggemann@arm.com>" Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Phil Auld <pauld@redhat.com> Cc: Hillf Danton <hdanton@sina.com> Link: https://lore.kernel.org/r/20200224095223.13361-8-mgorman@techsingularity.net
1 parent fb86f5b commit 0dacee1

6 files changed

Lines changed: 43 additions & 171 deletions

File tree

‎include/linux/sched.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ struct util_est {
357357

358358
/*
359359
* The load_avg/util_avg accumulates an infinite geometric series
360-
* (see __update_load_avg() in kernel/sched/fair.c).
360+
* (see __update_load_avg_cfs_rq() in kernel/sched/pelt.c).
361361
*
362362
* [load_avg definition]
363363
*
@@ -401,11 +401,9 @@ struct util_est {
401401
struct sched_avg {
402402
u64 last_update_time;
403403
u64 load_sum;
404-
u64 runnable_load_sum;
405404
u32 util_sum;
406405
u32 period_contrib;
407406
unsigned long load_avg;
408-
unsigned long runnable_load_avg;
409407
unsigned long util_avg;
410408
struct util_est util_est;
411409
} ____cacheline_aligned;
@@ -449,7 +447,6 @@ struct sched_statistics {
449447
struct sched_entity {
450448
/* For load-balancing: */
451449
struct load_weight load;
452-
unsigned long runnable_weight;
453450
struct rb_node run_node;
454451
struct list_head group_node;
455452
unsigned int on_rq;

‎kernel/sched/core.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@ static void set_load_weight(struct task_struct *p, bool update_load)
761761
if (task_has_idle_policy(p)) {
762762
load->weight = scale_load(WEIGHT_IDLEPRIO);
763763
load->inv_weight = WMULT_IDLEPRIO;
764-
p->se.runnable_weight = load->weight;
765764
return;
766765
}
767766

@@ -774,7 +773,6 @@ static void set_load_weight(struct task_struct *p, bool update_load)
774773
} else {
775774
load->weight = scale_load(sched_prio_to_weight[prio]);
776775
load->inv_weight = sched_prio_to_wmult[prio];
777-
p->se.runnable_weight = load->weight;
778776
}
779777
}
780778

‎kernel/sched/debug.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,9 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group
402402
}
403403

404404
P(se->load.weight);
405-
P(se->runnable_weight);
406405
#ifdef CONFIG_SMP
407406
P(se->avg.load_avg);
408407
P(se->avg.util_avg);
409-
P(se->avg.runnable_load_avg);
410408
#endif
411409

412410
#undef PN_SCHEDSTAT
@@ -524,11 +522,8 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
524522
SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running);
525523
SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight);
526524
#ifdef CONFIG_SMP
527-
SEQ_printf(m, " .%-30s: %ld\n", "runnable_weight", cfs_rq->runnable_weight);
528525
SEQ_printf(m, " .%-30s: %lu\n", "load_avg",
529526
cfs_rq->avg.load_avg);
530-
SEQ_printf(m, " .%-30s: %lu\n", "runnable_load_avg",
531-
cfs_rq->avg.runnable_load_avg);
532527
SEQ_printf(m, " .%-30s: %lu\n", "util_avg",
533528
cfs_rq->avg.util_avg);
534529
SEQ_printf(m, " .%-30s: %u\n", "util_est_enqueued",
@@ -947,13 +942,10 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
947942
"nr_involuntary_switches", (long long)p->nivcsw);
948943

949944
P(se.load.weight);
950-
P(se.runnable_weight);
951945
#ifdef CONFIG_SMP
952946
P(se.avg.load_sum);
953-
P(se.avg.runnable_load_sum);
954947
P(se.avg.util_sum);
955948
P(se.avg.load_avg);
956-
P(se.avg.runnable_load_avg);
957949
P(se.avg.util_avg);
958950
P(se.avg.last_update_time);
959951
P(se.avg.util_est.ewma);

‎kernel/sched/fair.c‎

Lines changed: 16 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,7 @@ void init_entity_runnable_average(struct sched_entity *se)
741741
* nothing has been attached to the task group yet.
742742
*/
743743
if (entity_is_task(se))
744-
sa->runnable_load_avg = sa->load_avg = scale_load_down(se->load.weight);
745-
746-
se->runnable_weight = se->load.weight;
744+
sa->load_avg = scale_load_down(se->load.weight);
747745

748746
/* when this task enqueue'ed, it will contribute to its cfs_rq's load_avg */
749747
}
@@ -2898,25 +2896,6 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
28982896
} while (0)
28992897

29002898
#ifdef CONFIG_SMP
2901-
static inline void
2902-
enqueue_runnable_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
2903-
{
2904-
cfs_rq->runnable_weight += se->runnable_weight;
2905-
2906-
cfs_rq->avg.runnable_load_avg += se->avg.runnable_load_avg;
2907-
cfs_rq->avg.runnable_load_sum += se_runnable(se) * se->avg.runnable_load_sum;
2908-
}
2909-
2910-
static inline void
2911-
dequeue_runnable_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
2912-
{
2913-
cfs_rq->runnable_weight -= se->runnable_weight;
2914-
2915-
sub_positive(&cfs_rq->avg.runnable_load_avg, se->avg.runnable_load_avg);
2916-
sub_positive(&cfs_rq->avg.runnable_load_sum,
2917-
se_runnable(se) * se->avg.runnable_load_sum);
2918-
}
2919-
29202899
static inline void
29212900
enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
29222901
{
@@ -2932,45 +2911,36 @@ dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
29322911
}
29332912
#else
29342913
static inline void
2935-
enqueue_runnable_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
2936-
static inline void
2937-
dequeue_runnable_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
2938-
static inline void
29392914
enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
29402915
static inline void
29412916
dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
29422917
#endif
29432918

29442919
static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
2945-
unsigned long weight, unsigned long runnable)
2920+
unsigned long weight)
29462921
{
29472922
if (se->on_rq) {
29482923
/* commit outstanding execution time */
29492924
if (cfs_rq->curr == se)
29502925
update_curr(cfs_rq);
29512926
account_entity_dequeue(cfs_rq, se);
2952-
dequeue_runnable_load_avg(cfs_rq, se);
29532927
}
29542928
dequeue_load_avg(cfs_rq, se);
29552929

2956-
se->runnable_weight = runnable;
29572930
update_load_set(&se->load, weight);
29582931

29592932
#ifdef CONFIG_SMP
29602933
do {
29612934
u32 divider = LOAD_AVG_MAX - 1024 + se->avg.period_contrib;
29622935

29632936
se->avg.load_avg = div_u64(se_weight(se) * se->avg.load_sum, divider);
2964-
se->avg.runnable_load_avg =
2965-
div_u64(se_runnable(se) * se->avg.runnable_load_sum, divider);
29662937
} while (0);
29672938
#endif
29682939

29692940
enqueue_load_avg(cfs_rq, se);
2970-
if (se->on_rq) {
2941+
if (se->on_rq)
29712942
account_entity_enqueue(cfs_rq, se);
2972-
enqueue_runnable_load_avg(cfs_rq, se);
2973-
}
2943+
29742944
}
29752945

29762946
void reweight_task(struct task_struct *p, int prio)
@@ -2980,7 +2950,7 @@ void reweight_task(struct task_struct *p, int prio)
29802950
struct load_weight *load = &se->load;
29812951
unsigned long weight = scale_load(sched_prio_to_weight[prio]);
29822952

2983-
reweight_entity(cfs_rq, se, weight, weight);
2953+
reweight_entity(cfs_rq, se, weight);
29842954
load->inv_weight = sched_prio_to_wmult[prio];
29852955
}
29862956

@@ -3092,50 +3062,6 @@ static long calc_group_shares(struct cfs_rq *cfs_rq)
30923062
*/
30933063
return clamp_t(long, shares, MIN_SHARES, tg_shares);
30943064
}
3095-
3096-
/*
3097-
* This calculates the effective runnable weight for a group entity based on
3098-
* the group entity weight calculated above.
3099-
*
3100-
* Because of the above approximation (2), our group entity weight is
3101-
* an load_avg based ratio (3). This means that it includes blocked load and
3102-
* does not represent the runnable weight.
3103-
*
3104-
* Approximate the group entity's runnable weight per ratio from the group
3105-
* runqueue:
3106-
*
3107-
* grq->avg.runnable_load_avg
3108-
* ge->runnable_weight = ge->load.weight * -------------------------- (7)
3109-
* grq->avg.load_avg
3110-
*
3111-
* However, analogous to above, since the avg numbers are slow, this leads to
3112-
* transients in the from-idle case. Instead we use:
3113-
*
3114-
* ge->runnable_weight = ge->load.weight *
3115-
*
3116-
* max(grq->avg.runnable_load_avg, grq->runnable_weight)
3117-
* ----------------------------------------------------- (8)
3118-
* max(grq->avg.load_avg, grq->load.weight)
3119-
*
3120-
* Where these max() serve both to use the 'instant' values to fix the slow
3121-
* from-idle and avoid the /0 on to-idle, similar to (6).
3122-
*/
3123-
static long calc_group_runnable(struct cfs_rq *cfs_rq, long shares)
3124-
{
3125-
long runnable, load_avg;
3126-
3127-
load_avg = max(cfs_rq->avg.load_avg,
3128-
scale_load_down(cfs_rq->load.weight));
3129-
3130-
runnable = max(cfs_rq->avg.runnable_load_avg,
3131-
scale_load_down(cfs_rq->runnable_weight));
3132-
3133-
runnable *= shares;
3134-
if (load_avg)
3135-
runnable /= load_avg;
3136-
3137-
return clamp_t(long, runnable, MIN_SHARES, shares);
3138-
}
31393065
#endif /* CONFIG_SMP */
31403066

31413067
static inline int throttled_hierarchy(struct cfs_rq *cfs_rq);
@@ -3147,7 +3073,7 @@ static inline int throttled_hierarchy(struct cfs_rq *cfs_rq);
31473073
static void update_cfs_group(struct sched_entity *se)
31483074
{
31493075
struct cfs_rq *gcfs_rq = group_cfs_rq(se);
3150-
long shares, runnable;
3076+
long shares;
31513077

31523078
if (!gcfs_rq)
31533079
return;
@@ -3156,16 +3082,15 @@ static void update_cfs_group(struct sched_entity *se)
31563082
return;
31573083

31583084
#ifndef CONFIG_SMP
3159-
runnable = shares = READ_ONCE(gcfs_rq->tg->shares);
3085+
shares = READ_ONCE(gcfs_rq->tg->shares);
31603086

31613087
if (likely(se->load.weight == shares))
31623088
return;
31633089
#else
31643090
shares = calc_group_shares(gcfs_rq);
3165-
runnable = calc_group_runnable(gcfs_rq, shares);
31663091
#endif
31673092

3168-
reweight_entity(cfs_rq_of(se), se, shares, runnable);
3093+
reweight_entity(cfs_rq_of(se), se, shares);
31693094
}
31703095

31713096
#else /* CONFIG_FAIR_GROUP_SCHED */
@@ -3290,11 +3215,11 @@ void set_task_rq_fair(struct sched_entity *se,
32903215
* _IFF_ we look at the pure running and runnable sums. Because they
32913216
* represent the very same entity, just at different points in the hierarchy.
32923217
*
3293-
* Per the above update_tg_cfs_util() is trivial and simply copies the running
3294-
* sum over (but still wrong, because the group entity and group rq do not have
3295-
* their PELT windows aligned).
3218+
* Per the above update_tg_cfs_util() is trivial * and simply copies the
3219+
* running sum over (but still wrong, because the group entity and group rq do
3220+
* not have their PELT windows aligned).
32963221
*
3297-
* However, update_tg_cfs_runnable() is more complex. So we have:
3222+
* However, update_tg_cfs_load() is more complex. So we have:
32983223
*
32993224
* ge->avg.load_avg = ge->load.weight * ge->avg.runnable_avg (2)
33003225
*
@@ -3375,11 +3300,11 @@ update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq
33753300
}
33763301

33773302
static inline void
3378-
update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq)
3303+
update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq)
33793304
{
33803305
long delta_avg, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum;
3381-
unsigned long runnable_load_avg, load_avg;
3382-
u64 runnable_load_sum, load_sum = 0;
3306+
unsigned long load_avg;
3307+
u64 load_sum = 0;
33833308
s64 delta_sum;
33843309

33853310
if (!runnable_sum)
@@ -3427,20 +3352,6 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cf
34273352
se->avg.load_avg = load_avg;
34283353
add_positive(&cfs_rq->avg.load_avg, delta_avg);
34293354
add_positive(&cfs_rq->avg.load_sum, delta_sum);
3430-
3431-
runnable_load_sum = (s64)se_runnable(se) * runnable_sum;
3432-
runnable_load_avg = div_s64(runnable_load_sum, LOAD_AVG_MAX);
3433-
3434-
if (se->on_rq) {
3435-
delta_sum = runnable_load_sum -
3436-
se_weight(se) * se->avg.runnable_load_sum;
3437-
delta_avg = runnable_load_avg - se->avg.runnable_load_avg;
3438-
add_positive(&cfs_rq->avg.runnable_load_avg, delta_avg);
3439-
add_positive(&cfs_rq->avg.runnable_load_sum, delta_sum);
3440-
}
3441-
3442-
se->avg.runnable_load_sum = runnable_sum;
3443-
se->avg.runnable_load_avg = runnable_load_avg;
34443355
}
34453356

34463357
static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum)
@@ -3468,7 +3379,7 @@ static inline int propagate_entity_load_avg(struct sched_entity *se)
34683379
add_tg_cfs_propagate(cfs_rq, gcfs_rq->prop_runnable_sum);
34693380

34703381
update_tg_cfs_util(cfs_rq, se, gcfs_rq);
3471-
update_tg_cfs_runnable(cfs_rq, se, gcfs_rq);
3382+
update_tg_cfs_load(cfs_rq, se, gcfs_rq);
34723383

34733384
trace_pelt_cfs_tp(cfs_rq);
34743385
trace_pelt_se_tp(se);
@@ -3612,8 +3523,6 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
36123523
div_u64(se->avg.load_avg * se->avg.load_sum, se_weight(se));
36133524
}
36143525

3615-
se->avg.runnable_load_sum = se->avg.load_sum;
3616-
36173526
enqueue_load_avg(cfs_rq, se);
36183527
cfs_rq->avg.util_avg += se->avg.util_avg;
36193528
cfs_rq->avg.util_sum += se->avg.util_sum;
@@ -4074,14 +3983,12 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
40743983
/*
40753984
* When enqueuing a sched_entity, we must:
40763985
* - Update loads to have both entity and cfs_rq synced with now.
4077-
* - Add its load to cfs_rq->runnable_avg
40783986
* - For group_entity, update its weight to reflect the new share of
40793987
* its group cfs_rq
40803988
* - Add its new weight to cfs_rq->load.weight
40813989
*/
40823990
update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH);
40833991
update_cfs_group(se);
4084-
enqueue_runnable_load_avg(cfs_rq, se);
40853992
account_entity_enqueue(cfs_rq, se);
40863993

40873994
if (flags & ENQUEUE_WAKEUP)
@@ -4158,13 +4065,11 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
41584065
/*
41594066
* When dequeuing a sched_entity, we must:
41604067
* - Update loads to have both entity and cfs_rq synced with now.
4161-
* - Subtract its load from the cfs_rq->runnable_avg.
41624068
* - Subtract its previous weight from cfs_rq->load.weight.
41634069
* - For group entity, update its weight to reflect the new share
41644070
* of its group cfs_rq.
41654071
*/
41664072
update_load_avg(cfs_rq, se, UPDATE_TG);
4167-
dequeue_runnable_load_avg(cfs_rq, se);
41684073

41694074
update_stats_dequeue(cfs_rq, se, flags);
41704075

@@ -7649,9 +7554,6 @@ static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
76497554
if (cfs_rq->avg.util_sum)
76507555
return false;
76517556

7652-
if (cfs_rq->avg.runnable_load_sum)
7653-
return false;
7654-
76557557
return true;
76567558
}
76577559

0 commit comments

Comments
 (0)