twx-linux/kernel/sched
Rafael J. Wysocki d70c078c26 cpufreq/sched: Explicitly synchronize limits_changed flag handling
[ Upstream commit 79443a7e9da3c9f68290a8653837e23aba0fa89f ]

The handling of the limits_changed flag in struct sugov_policy needs to
be explicitly synchronized to ensure that cpufreq policy limits updates
will not be missed in some cases.

Without that synchronization it is theoretically possible that
the limits_changed update in sugov_should_update_freq() will be
reordered with respect to the reads of the policy limits in
cpufreq_driver_resolve_freq() and in that case, if the limits_changed
update in sugov_limits() clobbers the one in sugov_should_update_freq(),
the new policy limits may not take effect for a long time.

Likewise, the limits_changed update in sugov_limits() may theoretically
get reordered with respect to the updates of the policy limits in
cpufreq_set_policy() and if sugov_should_update_freq() runs between
them, the policy limits change may be missed.

To ensure that the above situations will not take place, add memory
barriers preventing the reordering in question from taking place and
add READ_ONCE() and WRITE_ONCE() annotations around all of the
limits_changed flag updates to prevent the compiler from messing up
with that code.

Fixes: 600f5badb78c ("cpufreq: schedutil: Don't skip freq update when limits change")
Cc: 5.3+ <stable@vger.kernel.org> # 5.3+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/3376719.44csPzL39Z@rjwysocki.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-02 07:50:41 +02:00
..
autogroup.c
autogroup.h
build_policy.c
build_utility.c
clock.c
completion.c
core_sched.c
core.c sched/cpufreq: Rework schedutil governor performance estimation 2025-05-02 07:50:41 +02:00
cpuacct.c
cpudeadline.c sched/topology: Consolidate and clean up access to a CPU's max compute capacity 2025-05-02 07:50:41 +02:00
cpudeadline.h
cpufreq_schedutil.c cpufreq/sched: Explicitly synchronize limits_changed flag handling 2025-05-02 07:50:41 +02:00
cpufreq.c
cpupri.c
cpupri.h
cputime.c sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime 2024-08-14 13:58:47 +02:00
deadline.c sched/topology: Consolidate and clean up access to a CPU's max compute capacity 2025-05-02 07:50:41 +02:00
debug.c sched/debug: Provide slice length for fair tasks 2025-03-22 12:50:40 -07:00
fair.c sched/cpufreq: Rework schedutil governor performance estimation 2025-05-02 07:50:41 +02:00
features.h
idle.c sched/fair: Rename check_preempt_curr() to wakeup_preempt() 2024-12-14 20:00:18 +01:00
isolation.c sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU 2024-06-12 11:11:24 +02:00
loadavg.c
Makefile
membarrier.c
pelt.c
pelt.h
psi.c sched: psi: fix bogus pressure spikes from aggregation race 2024-10-10 11:58:03 +02:00
rt.c sched/topology: Consolidate and clean up access to a CPU's max compute capacity 2025-05-02 07:50:41 +02:00
sched-pelt.h
sched.h sched/cpufreq: Rework schedutil governor performance estimation 2025-05-02 07:50:41 +02:00
smp.h
stats.c profiling: remove profile=sleep support 2024-08-14 13:58:47 +02:00
stats.h sched: Move psi_account_irqtime() out of update_rq_clock_task() hotpath 2024-07-18 13:21:25 +02:00
stop_task.c sched: Unify runtime accounting across classes 2024-12-14 20:00:19 +01:00
swait.c
topology.c sched/topology: Consolidate and clean up access to a CPU's max compute capacity 2025-05-02 07:50:41 +02:00
wait_bit.c
wait.c