linux-stable/kernel
Rafael J. Wysocki 89737f6520 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
[ Adjust context ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-09 18:44:00 +02:00
..
bpf bpf: fix potential error return 2025-01-09 13:23:36 +01:00
cgroup cgroup: Fix compilation issue due to cgroup_mutex not being exported 2025-06-04 14:32:29 +02:00
configs
debug kdb: Use the passed prompt in kdb_position_cursor() 2024-08-19 05:33:40 +02:00
dma dma: fix call order in dmam_free_coherent 2024-08-19 05:33:41 +02:00
events perf/core: Prevent VMA split of buffer mappings 2025-08-28 16:21:23 +02:00
gcov
irq genirq/irqdesc: Honor caller provided affinity in alloc_desc() 2024-08-19 05:33:52 +02:00
livepatch
locking locking/lockdep: Decrease nr_unused_locks if lock unused in zap_class() 2025-05-02 07:39:15 +02:00
power PM: sleep: console: Fix the black screen issue 2025-08-28 16:21:25 +02:00
printk printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX 2025-03-13 12:43:02 +01:00
rcu rcu: Protect ->defer_qs_iw_pending from data race 2025-08-28 16:21:26 +02:00
sched cpufreq/sched: Explicitly synchronize limits_changed flag handling 2025-09-09 18:44:00 +02:00
time posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() 2025-06-27 11:02:57 +01:00
trace ftrace: Fix potential warning in trace_printk_seq during ftrace_dump 2025-09-04 14:05:53 +02:00
.gitignore
acct.c acct: perform last write from workqueue 2025-03-13 12:43:26 +01:00
async.c
audit_fsnotify.c
audit_tree.c
audit_watch.c
audit.c
audit.h
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
compat.c
configs.c
context_tracking.c
cpu_pm.c
cpu.c hrtimers: Handle CPU state correctly on hotplug 2025-02-01 18:18:51 +01:00
crash_core.c
crash_dump.c
cred.c
delayacct.c
dma.c
exec_domain.c
exit.c perf: Fix sample vs do_exit() 2025-06-27 11:02:58 +01:00
extable.c
fail_function.c
fork.c mm: drop the assumption that VM_SHARED always implies writable 2025-08-28 16:21:36 +02:00
freezer.c
futex.c
gen_kheaders.sh kheaders: Ignore silly-rename files 2025-02-01 18:18:51 +01:00
groups.c
hung_task.c
iomem.c
irq_work.c
jump_label.c
kallsyms.c
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kcov.c
kexec_core.c
kexec_elf.c kexec: initialize ELF lowest address to ULONG_MAX 2025-04-10 14:29:41 +02:00
kexec_file.c
kexec_internal.h
kexec.c
kheaders.c
kmod.c
kprobes.c
ksysfs.c
kthread.c kthread: fix task state in kthread worker if being frozen 2024-11-08 16:20:30 +01:00
latencytop.c
Makefile
module_signature.c
module_signing.c
module-internal.h
module.c
notifier.c
nsproxy.c
padata.c padata: fix sysfs store callback check 2025-03-13 12:42:56 +01:00
panic.c
params.c module: ensure that kobject_put() is safe for module type kobjects 2025-06-04 14:32:27 +02:00
pid_namespace.c
pid.c
profile.c
ptrace.c
range.c
reboot.c
relay.c
resource.c resource: fix region_intersects() vs add_memory_driver_managed() 2024-11-08 16:20:46 +01:00
rseq.c
seccomp.c
signal.c signal: Replace BUG_ON()s 2024-11-08 16:20:38 +01:00
smp.c smp: Add missing destroy_work_on_stack() call in smp_call_on_cpu() 2024-09-12 11:03:54 +02:00
smpboot.c
smpboot.h
softirq.c tasklet: Introduce new initialization API 2025-03-13 12:43:04 +01:00
stackleak.c
stacktrace.c
stop_machine.c
sys_ni.c
sys.c
sysctl_binary.c
sysctl-test.c
sysctl.c
task_work.c
taskstats.c
test_kprobes.c
torture.c
tracepoint.c
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c
up.c
user_namespace.c
user-return-notifier.c
user.c
utsname_sysctl.c
utsname.c
watchdog_hld.c watchdog/perf: properly initialize the turbo mode timestamp and rearm counter 2024-08-19 05:33:39 +02:00
watchdog.c
workqueue_internal.h
workqueue.c