android_kernel_samsung_msm8976/kernel/sched
Phil Auld 00b32ad42d sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup
[ Upstream commit 2e8e19226398db8265a8e675fcc0118b9e80c9e8 ]

With extremely short cfs_period_us setting on a parent task group with a large
number of children the for loop in sched_cfs_period_timer() can run until the
watchdog fires. There is no guarantee that the call to hrtimer_forward_now()
will ever return 0.  The large number of children can make
do_sched_cfs_period_timer() take longer than the period.

 NMI watchdog: Watchdog detected hard LOCKUP on cpu 24
 RIP: 0010:tg_nop+0x0/0x10
  <IRQ>
  walk_tg_tree_from+0x29/0xb0
  unthrottle_cfs_rq+0xe0/0x1a0
  distribute_cfs_runtime+0xd3/0xf0
  sched_cfs_period_timer+0xcb/0x160
  ? sched_cfs_slack_timer+0xd0/0xd0
  __hrtimer_run_queues+0xfb/0x270
  hrtimer_interrupt+0x122/0x270
  smp_apic_timer_interrupt+0x6a/0x140
  apic_timer_interrupt+0xf/0x20
  </IRQ>

To prevent this we add protection to the loop that detects when the loop has run
too many times and scales the period and quota up, proportionally, so that the timer
can complete before then next period expires.  This preserves the relative runtime
quota while preventing the hard lockup.

A warning is issued reporting this state and the new values.

Signed-off-by: Phil Auld <pauld@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190319130005.25492-1-pauld@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:10 +02:00
..
auto_group.c sched/autogroup: Fix possible Spectre-v1 indexing for sched_prio_to_weight[] 2019-07-27 21:52:06 +02:00
auto_group.h
clock.c
core.c sched/core: Fix TASK_DEAD race in finish_task_switch() 2019-07-27 22:09:34 +02:00
cpuacct.c
cpuacct.h
cpudeadline.c
cpudeadline.h
cpupri.c
cpupri.h
cputime.c sched: Change thread_group_cputime() to use for_each_thread() 2019-07-27 22:09:16 +02:00
deadline.c
debug.c sched: print_rq(): Don't use tasklist_lock 2019-07-27 22:09:20 +02:00
fair.c sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup 2019-07-27 22:10:10 +02:00
features.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
idle_task.c
Makefile
rt.c
sched.h sched/core: Fix TASK_DEAD race in finish_task_switch() 2019-07-27 22:09:34 +02:00
sched_avg.c sched: Fix integer overflow in sched_update_nr_prod() 2016-09-29 02:12:18 -07:00
stats.c
stats.h
stop_task.c
wait.c