Skip to content

Commit 6f35736

Browse files
committed
Merge tag 'sched_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fix from Borislav Petkov: "Fix a NULL-ptr dereference when recalculating a sched entity's weight" * tag 'sched_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/fair: Fix fault in reweight_entity
2 parents f5e0265 + 13765de commit 6f35736

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

kernel/sched/core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,9 @@ int tg_nop(struct task_group *tg, void *data)
12141214
}
12151215
#endif
12161216

1217-
static void set_load_weight(struct task_struct *p, bool update_load)
1217+
static void set_load_weight(struct task_struct *p)
12181218
{
1219+
bool update_load = !(READ_ONCE(p->__state) & TASK_NEW);
12191220
int prio = p->static_prio - MAX_RT_PRIO;
12201221
struct load_weight *load = &p->se.load;
12211222

@@ -4406,7 +4407,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
44064407
p->static_prio = NICE_TO_PRIO(0);
44074408

44084409
p->prio = p->normal_prio = p->static_prio;
4409-
set_load_weight(p, false);
4410+
set_load_weight(p);
44104411

44114412
/*
44124413
* We don't need the reset flag anymore after the fork. It has
@@ -6921,7 +6922,7 @@ void set_user_nice(struct task_struct *p, long nice)
69216922
put_prev_task(rq, p);
69226923

69236924
p->static_prio = NICE_TO_PRIO(nice);
6924-
set_load_weight(p, true);
6925+
set_load_weight(p);
69256926
old_prio = p->prio;
69266927
p->prio = effective_prio(p);
69276928

@@ -7212,7 +7213,7 @@ static void __setscheduler_params(struct task_struct *p,
72127213
*/
72137214
p->rt_priority = attr->sched_priority;
72147215
p->normal_prio = normal_prio(p);
7215-
set_load_weight(p, true);
7216+
set_load_weight(p);
72167217
}
72177218

72187219
/*
@@ -9445,7 +9446,7 @@ void __init sched_init(void)
94459446
#endif
94469447
}
94479448

9448-
set_load_weight(&init_task, false);
9449+
set_load_weight(&init_task);
94499450

94509451
/*
94519452
* The boot idle thread does lazy MMU switching as well:

0 commit comments

Comments
 (0)