Re: [PATCH v3] sched/fair: Fix fault in reweight_entity

From: Tadeusz Struk
Date: Wed Jan 26 2022 - 18:51:02 EST


On 1/26/22 05:53, Dietmar Eggemann wrote:
Can we then not get rid of `bool update_load` parameter of
set_load_weight() completely?

@@ -1214,8 +1214,9 @@ int tg_nop(struct task_group *tg, void *data)
}
#endif
-static void set_load_weight(struct task_struct *p, bool update_load)
+static void set_load_weight(struct task_struct *p)
{
+ int task_new = READ_ONCE(p->__state) & TASK_NEW;
int prio = p->static_prio - MAX_RT_PRIO;
struct load_weight *load = &p->se.load;
@@ -1232,7 +1233,7 @@ static void set_load_weight(struct task_struct *p, bool update_load)
* SCHED_OTHER tasks have to update their load when changing their
* weight
*/
- if (update_load && p->sched_class == &fair_sched_class) {
+ if (!task_new && p->sched_class == &fair_sched_class) {
reweight_task(p, prio);
} else {
load->weight = scale_load(sched_prio_to_weight[prio]);

That will also work. Let's agree on the best way to fix it.
Peter, what's your preference?

--
Thanks,
Tadeusz