linux/kernel
Stephen Dickey a64f42d1df ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks
Currently, the sched code checks if the rq clock has been
updated after its lock has been held when CONFIG_SCHED_DEBUG
is enabled. It tracks this by clearing the RQCF_UPDATED bit
when a lock is acquired and setting it upon a subsequent
update_rq_clock() call. It warns if rq clock is read without
RQCF_UPDATED flag indicating the code path missed updating
the clock.

When migrate_tasks() is called during a pause_cpus() event,
the local variable orf is updated with the contents of *rf,
prior to the call to update_rq_clock(). As a result, when
migrate_tasks() restores *rf from the local variable the
RQCF_UPDATED flag is lost. This clearing out of the
RQCF_UPDATED flag leads to a warning when the next task
is being pushed out.

For example in migrate_tasks()

   orf = rf; // save flags, RQCF_UPDATE cleared
   update_rq_clock() // set RQCF_UPDATE
   for()
      ...
      __migrate_task(dead_rq, new_cpu)
      ...
      --> if migration, restore dead_rq's flags with orf.
         --> We loose RQCF_UPDATE
	 rq_relock(dead_rq, orf)

This leaves the current cpu's rq clock_update_flags with the
RQCF_UPDATED flag cleared, an error condition with
CONFIG_SCHED_DEBUG enabled.

Fix the issue for by ensuring that the local variable orf
has the RQCF_UPDATED flag set, allowing the current
CPU's rq to have the flag set and leaving it in a good state
for future usage.

pause_cpus() is currently Android specific. As cpu_pause does
not rely on stop_machine_cpuslocked() like the regular
hotunplug path does, there's a risk for another CPU to
read the rq_clock, after we cleared RQCF_UPDATE, when using
pause_cpus(). This change will have little or no impact outside
of Android currently. If pause_cpus() or drain_rq_cpu_stop()
are merged upstream this change should be merged as well.

Bug: 186222712
Change-Id: Id241122e1449cdd4dcd15f94eb68735b40e3d6f5
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-04-28 21:28:55 +00:00
..
bpf This is the 5.10.32 stable release 2021-04-22 11:12:08 +02:00
cgroup ANDROID: cgroup: Add vendor hook for cpuset. 2021-04-21 13:31:39 -07:00
configs
debug kgdb: fix to kill breakpoints on initmem after boot 2021-03-04 11:38:46 +01:00
dma
entry x86/entry: Move nmi entry/exit into common code 2021-03-17 17:06:36 +01:00
events This is the 5.10.24 stable release 2021-03-19 09:42:56 +01:00
gcov gcov: re-fix clang-11+ support 2021-04-14 08:41:58 +02:00
irq Merge 5.10.26 into android12-5.10-lts 2021-03-25 17:15:27 +01:00
kcsan kcsan: Rewrite kcsan_prandom_u32_max() without prandom_u32_state() 2021-03-04 11:37:37 +01:00
livepatch
locking This is the 5.10.32 stable release 2021-04-22 11:12:08 +02:00
power Merge 5.10.27 into android12-5.10 2021-04-02 15:25:50 +02:00
printk ANDROID: logbuf: vendor hook for logbuf dump on oops 2021-04-15 20:02:45 +00:00
rcu FROMGIT: rcu/tree: Add a trace event for RCU CPU stall warnings 2021-03-11 21:06:44 +09:00
sched ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks 2021-04-28 21:28:55 +00:00
time FROMGIT: tick/broadcast: Allow late registered device to enter oneshot mode 2021-04-23 16:25:34 +00:00
trace Merge 5.10.31 into android12-5.10 2021-04-16 16:01:44 +02:00
.gitignore
acct.c
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
cfi.c ANDROID: cfi: switch to synchronize_rcu_expedited() 2021-02-16 18:09:38 +00:00
compat.c
configs.c
context_tracking.c
cpu_pm.c
cpu.c ANDROID: cpu/hotplug: failure to offline 2nd to last cpu 2021-03-11 21:32:28 +00:00
crash_core.c
crash_dump.c
cred.c ANDROID: kernel: Add vendor hook in creds 2021-03-15 15:37:57 +00:00
delayacct.c
dma.c
exec_domain.c
exit.c ANDROID: vendor_hooks: Add hooks for memory when debug 2021-03-19 04:54:07 +00:00
extable.c
fail_function.c
fork.c ANDROID: sched: Add vendor hooks for sched. 2021-04-23 18:42:38 -07:00
freezer.c Revert "kernel: freezer should treat PF_IO_WORKER like PF_KTHREAD for freezing" 2021-04-07 15:00:14 +02:00
futex.c Merge 5.10.26 into android12-5.10-lts 2021-03-25 17:15:27 +01:00
gen_kheaders.sh
groups.c
hung_task.c
iomem.c
irq_work.c
jump_label.c static_call: Fix static_call_update() sanity check 2021-03-25 09:04:18 +01:00
kallsyms.c
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kcov.c
kexec_core.c
kexec_elf.c
kexec_file.c ima: Free IMA measurement buffer after kexec syscall 2021-03-04 11:37:50 +01:00
kexec_internal.h
kexec.c
kheaders.c
kmod.c
kprobes.c kprobes: Fix to delay the kprobes jump optimization 2021-03-04 11:38:35 +01:00
ksysfs.c
kthread.c Merge 5.10.14 into android12-5.10 2021-02-08 20:05:12 -08:00
latencytop.c
Makefile Merge 5.10.20 into android12-5.10 2021-03-07 12:33:33 +01:00
module_signature.c module: harden ELF info handling 2021-03-25 09:04:11 +01:00
module_signing.c module: harden ELF info handling 2021-03-25 09:04:11 +01:00
module-internal.h
module.c Merge 5.10.26 into android12-5.10-lts 2021-03-25 17:15:27 +01:00
notifier.c
nsproxy.c
padata.c
panic.c
params.c
pid_namespace.c
pid.c
profile.c
ptrace.c
range.c
reboot.c
regset.c
relay.c
resource.c
rseq.c
scftorture.c
scs.c
seccomp.c Merge 5.10.20 into android12-5.10 2021-03-07 12:33:33 +01:00
signal.c ANDROID: Add vendor hooks to signal. 2021-04-09 02:30:55 +00:00
smp.c ANDROID: smp: fix preprocessor conditional warning 2021-04-14 18:33:17 +00:00
smpboot.c kthread: Extract KTHREAD_IS_PER_CPU 2021-02-07 15:37:17 +01:00
smpboot.h
softirq.c
stackleak.c
stacktrace.c ANDROID: stacktrace: export stack_trace_save_tsk/regs 2021-04-13 13:18:04 +00:00
static_call.c static_call: Align static_call_is_init() patching condition 2021-04-07 15:00:06 +02:00
stop_machine.c
sys_ni.c
sys.c ANDROID: Add vendor hooks when syscall prctl finished 2021-03-08 16:18:51 +00:00
sysctl-test.c
sysctl.c This is the 5.10.24 stable release 2021-03-19 09:42:56 +01:00
task_work.c FROMGIT: kasan: record task_work_add() call stack 2021-03-24 15:09:18 -07:00
taskstats.c
test_kprobes.c
torture.c
tracepoint.c ANDROID: vendor_hooks: Allow multiple attachments to restricted hooks 2021-03-31 09:08:06 +00:00
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c
up.c
user_namespace.c
user-return-notifier.c
user.c ANDROID: export find_user() & free_uid()for GKI purpose. 2021-04-23 03:37:41 +00:00
usermode_driver.c bpf: Fix umd memory leak in copy_process() 2021-03-30 14:32:03 +02:00
utsname_sysctl.c
utsname.c
watch_queue.c
watchdog_hld.c
watchdog.c
workqueue_internal.h
workqueue.c Merge 5.10.30 into android12-5.10 2021-04-15 14:23:41 +02:00