kernel_optimize_test/kernel/sched
Juri Lelli 9a68fa0ebb sched/features: Fix hrtick reprogramming
[ Upstream commit 156ec6f42b8d300dbbf382738ff35c8bad8f4c3a ]

Hung tasks and RCU stall cases were reported on systems which were not
100% busy. Investigation of such unexpected cases (no sign of potential
starvation caused by tasks hogging the system) pointed out that the
periodic sched tick timer wasn't serviced anymore after a certain point
and that caused all machinery that depends on it (timers, RCU, etc.) to
stop working as well. This issues was however only reproducible if
HRTICK was enabled.

Looking at core dumps it was found that the rbtree of the hrtimer base
used also for the hrtick was corrupted (i.e. next as seen from the base
root and actual leftmost obtained by traversing the tree are different).
Same base is also used for periodic tick hrtimer, which might get "lost"
if the rbtree gets corrupted.

Much alike what described in commit 1f71addd34 ("tick/sched: Do not
mess with an enqueued hrtimer") there is a race window between
hrtimer_set_expires() in hrtick_start and hrtimer_start_expires() in
__hrtick_restart() in which the former might be operating on an already
queued hrtick hrtimer, which might lead to corruption of the base.

Use hrtick_start() (which removes the timer before enqueuing it back) to
ensure hrtick hrtimer reprogramming is entirely guarded by the base
lock, so that no race conditions can occur.

Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20210208073554.14629-2-juri.lelli@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-07 12:34:13 +01:00
..
autogroup.c
autogroup.h
clock.c
completion.c
core.c sched/features: Fix hrtick reprogramming 2021-03-07 12:34:13 +01:00
cpuacct.c
cpudeadline.c
cpudeadline.h
cpufreq_schedutil.c cpufreq: Introduce governor flags 2020-11-10 18:31:17 +01:00
cpufreq.c
cpupri.c
cpupri.h
cputime.c
deadline.c sched/deadline: Fix sched_dl_global_validate() 2020-12-30 11:52:59 +01:00
debug.c sched/debug: Fix memory corruption caused by multiple small reads of flags 2020-11-10 18:38:49 +01:00
fair.c sched/eas: Don't update misfit status if the task is pinned 2021-03-04 11:37:44 +01:00
features.h
idle.c rcu/nocb: Perform deferred wake up before last idle's need_resched() check 2021-03-04 11:38:35 +01:00
isolation.c
loadavg.c
Makefile
membarrier.c membarrier: Execute SYNC_CORE on the calling thread 2020-12-09 09:37:43 +01:00
pelt.c
pelt.h
psi.c
rt.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
sched-pelt.h
sched.h sched/features: Fix hrtick reprogramming 2021-03-07 12:34:13 +01:00
smp.h
stats.c
stats.h
stop_task.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
swait.c
topology.c Scheduler changes for v5.10: 2020-10-12 12:56:01 -07:00
wait_bit.c
wait.c