The current->normal_prio is locklessly accessed from sched_fork and
child's scheduler related initialization procedures heavily rely on
the value loaded. Thus we mark this load as READ_ONCE in case of
possible load tearing due to concurrent access from other paths, for
example if changes of parent's normal_prio happens to be requested
via some syscall.
Signed-off-by: Ze Gao <[email protected]>
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 944c3ae39861..37a13e4b734d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4699,7 +4699,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
/*
* Make sure we do not leak PI boosting priority to the child.
*/
- p->prio = current->normal_prio;
+ p->prio = READ_ONCE(current->normal_prio);
uclamp_fork(p);
--
2.40.1