FAILED: patch "[PATCH] sched/fair: set_load_weight() must also call reweight_task()" failed to apply to 5.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y
git checkout FETCH_HEAD
git cherry-pick -x d329605287020c3d1c3b0dadc63d8208e7251382
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024072950-swab-uncharted-cf85@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^..
Possible dependencies:
d32960528702 ("sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks") 0dacee1bfa70 ("sched/pelt: Remove unused runnable load average")fe71bbb21ee1 ("sched/fair: calculate delta runnable load only when it's needed")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d329605287020c3d1c3b0dadc63d8208e7251382 Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Tue, 25 Jun 2024 15:29:58 -1000
Subject: [PATCH] sched/fair: set_load_weight() must also call reweight_task()
for SCHED_IDLE tasks
When a task's weight is being changed, set_load_weight() is called with @update_load set. As weight changes aren't trivial for the fair class, set_load_weight() calls fair.c::reweight_task() for fair class tasks.
However, set_load_weight() first tests task_has_idle_policy() on entry and skips calling reweight_task() for SCHED_IDLE tasks. This is buggy as SCHED_IDLE tasks are just fair tasks with a very low weight and they would incorrectly skip load, vlag and position updates.
Fix it by updating reweight_task() to take struct load_weight as idle weight can't be expressed with prio and making set_load_weight() call reweight_task() for SCHED_IDLE tasks too when @update_load is set.
kernel/sched/core.c +10 -13
@@ -1328,27 +1328,24 @@ int tg_nop(struct task_group *tg, void *data)void set_load_weight (struct task_struct *p,bool update_load) {int prio = p->static_prio -MAX_RT_PRIO ; -struct load_weight *load = &p->se.load; +struct load_weight lw; -/* -* SCHED_IDLE tasks get minimal weight: -*/ if (task_has_idle_policy (p)) { - load->weight =scale_load (WEIGHT_IDLEPRIO ); - load->inv_weight =WMULT_IDLEPRIO ; -return ; + lw.weight =scale_load (WEIGHT_IDLEPRIO ); + lw.inv_weight =WMULT_IDLEPRIO ; + }else { + lw.weight =scale_load (sched_prio_to_weight[prio]); + lw.inv_weight = sched_prio_to_wmult[prio]; }/* * SCHED_OTHER tasks have to update their load when changing their * weight */ -if (update_load && p->sched_class == &fair_sched_class) { -reweight_task (p, prio); - }else { - load->weight =scale_load (sched_prio_to_weight[prio]); - load->inv_weight = sched_prio_to_wmult[prio]; - } +if (update_load && p->sched_class == &fair_sched_class) +reweight_task (p, &lw); +else + p->se.load = lw; }#ifdef CONFIG_UCLAMP_TASK
kernel/sched/fair.c +3 -4
@@ -3835,15 +3835,14 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, } } -void reweight_task (struct task_struct *p,int prio) +void reweight_task (struct task_struct *p,const struct load_weight *lw) {struct sched_entity *se = &p->se;struct cfs_rq *cfs_rq =cfs_rq_of (se);struct load_weight *load = &se->load; -unsigned long weight =scale_load (sched_prio_to_weight[prio]); -reweight_entity (cfs_rq, se, weight); - load->inv_weight = sched_prio_to_wmult[prio]; +reweight_entity (cfs_rq, se, lw->weight); + load->inv_weight = lw->inv_weight; }static inline int throttled_hierarchy (struct cfs_rq *cfs_rq);
kernel/sched/sched.h +1 -1
@@ -2509,7 +2509,7 @@ extern void init_sched_dl_class(void);extern void init_sched_rt_class (void );extern void init_sched_fair_class (void ); -extern void reweight_task (struct task_struct *p,int prio); +extern void reweight_task (struct task_struct *p,const struct load_weight *lw);extern void resched_curr (struct rq *rq);extern void resched_cpu (int cpu);