Ethan Zhao
7ce12102de
sched/sysctl: Check user input value of sysctl_sched_time_avg
commit 5ccba44ba1 upstream.
System will hang if user set sysctl_sched_time_avg to 0:
[root@XXX ~]# sysctl kernel.sched_time_avg_ms=0
Stack traceback for pid 0
0xffff883f6406c600 0 0 1 3 R 0xffff883f6406cf50 *swapper/3
ffff883f7ccc3ae8 0000000000000018 ffffffff810c4dd0 0000000000000000
0000000000017800 ffff883f7ccc3d78 0000000000000003 ffff883f7ccc3bf8
ffffffff810c4fc9 ffff883f7ccc3c08 00000000810c5043 ffff883f7ccc3c08
Call Trace:
<IRQ> [<ffffffff810c4dd0>] ? update_group_capacity+0x110/0x200
[<ffffffff810c4fc9>] ? update_sd_lb_stats+0x109/0x600
[<ffffffff810c5507>] ? find_busiest_group+0x47/0x530
[<ffffffff810c5b84>] ? load_balance+0x194/0x900
[<ffffffff810ad5ca>] ? update_rq_clock.part.83+0x1a/0xe0
[<ffffffff810c6d42>] ? rebalance_domains+0x152/0x290
[<ffffffff810c6f5c>] ? run_rebalance_domains+0xdc/0x1d0
[<ffffffff8108a75b>] ? __do_softirq+0xfb/0x320
[<ffffffff8108ac85>] ? irq_exit+0x125/0x130
[<ffffffff810b3a17>] ? scheduler_ipi+0x97/0x160
[<ffffffff81052709>] ? smp_reschedule_interrupt+0x29/0x30
[<ffffffff8173a1be>] ? reschedule_interrupt+0x6e/0x80
<EOI> [<ffffffff815bc83c>] ? cpuidle_enter_state+0xcc/0x230
[<ffffffff815bc80c>] ? cpuidle_enter_state+0x9c/0x230
[<ffffffff815bc9d7>] ? cpuidle_enter+0x17/0x20
[<ffffffff810cd6dc>] ? cpu_startup_entry+0x38c/0x420
[<ffffffff81053373>] ? start_secondary+0x173/0x1e0
Because divide-by-zero error happens in function:
update_group_capacity()
update_cpu_capacity()
scale_rt_capacity()
{
...
total = sched_avg_period() + delta;
used = div_u64(avg, total);
...
}
To fix this issue, check user input value of sysctl_sched_time_avg, keep
it unchanged when hitting invalid input, and set the minimum limit of
sysctl_sched_time_avg to 1 ms.
Reported-by: James Puthukattukaran <james.puthukattukaran@oracle.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: efault@gmx.de
Cc: ethan.kernel@gmail.com
Cc: keescook@chromium.org
Cc: mcgrof@kernel.org
Link: http://lkml.kernel.org/r/1504504774-18253-1-git-send-email-ethan.zhao@oracle.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2018-01-01 20:50:53 +00:00
..
2015-05-09 23:16:19 +01:00
2017-11-11 13:34:31 +00:00
2017-11-26 13:51:08 +00:00
2014-12-14 16:23:52 +00:00
2017-09-15 18:30:49 +01:00
2017-11-26 13:51:07 +00:00
2012-10-10 03:31:09 +01:00
2014-12-14 16:23:56 +00:00
2017-11-11 13:34:29 +00:00
2014-01-03 04:33:17 +00:00
2016-08-22 22:37:19 +01:00
2013-01-03 03:32:56 +00:00
2015-10-13 03:46:08 +01:00
2012-05-31 00:43:51 +01:00
2017-03-16 02:18:29 +00:00
2017-10-12 15:27:22 +01:00
2011-11-06 19:44:47 -08:00
2012-04-13 08:33:50 -07:00
2016-08-22 22:37:12 +01:00
2014-11-05 20:27:46 +00:00
2011-11-06 19:44:47 -08:00
2017-09-15 18:30:57 +01:00
2017-09-15 18:30:57 +01:00
2016-02-27 14:28:41 +00:00
2012-01-03 16:14:32 -08:00
2016-02-27 14:28:42 +00:00
2011-12-05 13:28:46 -05:00
2014-08-06 18:07:38 +01:00
2013-05-30 14:35:00 +01:00
2017-09-15 18:30:44 +01:00
2011-12-06 18:18:13 +01:00
2015-11-17 15:54:40 +00:00
2017-08-26 02:13:59 +01:00
2012-02-13 11:16:59 -08:00
2013-03-06 03:24:01 +00:00
2016-02-27 14:28:42 +00:00
2015-05-09 23:16:24 +01:00
2017-09-15 18:30:57 +01:00
2015-08-12 16:33:12 +02:00
2013-01-03 03:33:08 +00:00
2012-07-12 04:31:59 +01:00
2016-04-01 01:54:34 +01:00
2014-07-11 13:33:50 +01:00
2017-02-23 03:51:01 +00:00
2014-07-11 13:33:50 +01:00
2015-05-09 23:16:18 +01:00
2013-01-03 03:32:53 +00:00
2013-04-25 20:25:34 +01:00
2014-06-09 13:29:10 +01:00
2014-08-06 18:07:38 +01:00
2016-02-27 14:28:49 +00:00
2011-11-14 12:50:40 +01:00
2012-07-25 04:11:09 +01:00
2015-03-06 00:39:19 +00:00
2012-10-17 03:50:03 +01:00
2017-10-12 15:27:08 +01:00
2017-09-15 18:30:54 +01:00
2013-02-06 04:33:49 +00:00
2015-08-07 00:32:19 +01:00
2011-11-06 19:44:47 -08:00
2013-06-19 02:17:00 +01:00
2016-05-01 00:05:20 +02:00
2018-01-01 20:50:53 +00:00
2015-02-20 00:49:34 +00:00
2013-03-06 03:23:52 +00:00
2014-06-09 13:29:04 +01:00
2014-06-09 13:28:55 +01:00
2011-11-06 19:44:47 -08:00
2012-12-06 11:20:21 +00:00
2014-04-02 00:58:54 +01:00