linux-yocto/kernel/sched
Rafael J. Wysocki ad3a999b8b cpufreq/sched: Explicitly synchronize limits_changed flag handling
[ Upstream commit 79443a7e9d ]

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: 600f5badb7 ("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
[ bw_min => bw_dl ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-09 18:54:18 +02:00
..
autogroup.c
autogroup.h
build_policy.c
build_utility.c
clock.c
completion.c
core_sched.c
core.c sched: Clarify wake_up_q()'s write to task->wake_q.next 2025-03-28 21:58:51 +01:00
cpuacct.c
cpudeadline.c
cpudeadline.h
cpufreq_schedutil.c cpufreq/sched: Explicitly synchronize limits_changed flag handling 2025-09-09 18:54:18 +02:00
cpufreq.c
cpupri.c sched/rt: Fix live lock between select_fallback_rq() and RT push 2023-10-06 14:57:02 +02:00
cpupri.h
cputime.c sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime 2024-08-14 13:52:50 +02:00
deadline.c sched/deadline: Use online cpus for validating runtime 2025-04-10 14:33:39 +02:00
debug.c
fair.c sched/fair: Bump sd->max_newidle_lb_cost when newidle balance fails 2025-08-28 16:25:56 +02:00
features.h
idle.c kernel/sched: Modify initial boot task idle setup 2023-10-06 14:57:02 +02:00
isolation.c sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU 2024-06-12 11:03:00 +02:00
loadavg.c sched: Change nr_uninterruptible type to unsigned long 2025-07-24 08:51:54 +02:00
Makefile
membarrier.c sched/membarrier: reduce the ability to hammer on sys_membarrier 2024-02-23 09:12:52 +01:00
pelt.c
pelt.h
psi.c sched: psi: fix bogus pressure spikes from aggregation race 2024-10-17 15:22:06 +02:00
rt.c sched/rt: sysctl_sched_rr_timeslice show default timeslice after reset 2024-03-01 13:26:24 +01:00
sched-pelt.h
sched.h sched: Change nr_uninterruptible type to unsigned long 2025-07-24 08:51:54 +02:00
smp.h
stats.c profiling: remove profile=sleep support 2024-08-14 13:52:50 +02:00
stats.h sched/psi: Use task->psi_flags to clear in CPU migration 2025-02-21 13:48:54 +01:00
stop_task.c
swait.c
topology.c sched/fair: Allow disabling sched_balance_newidle with sched_relax_domain_level 2024-06-12 11:03:33 +02:00
wait_bit.c
wait.c