Ethan Zhao
e7424c7688
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
Cc: <stable@vger.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>
Cc: Steve Muckle <smuckle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-12 17:14:54 +09:00
..
2023-05-12 16:43:17 +09:00
2017-10-03 17:19:26 +00:00
2018-05-30 13:19:56 +02:00
2018-05-30 13:19:56 +02:00
2017-09-02 07:07:53 +02:00
2023-05-12 16:45:57 +09:00
2016-08-26 14:42:08 +02:00
2023-05-12 17:04:38 +09:00
2020-02-04 13:48:58 +09:00
2020-02-04 13:48:58 +09:00
2020-02-04 13:48:58 +09:00
2023-05-12 16:45:19 +09:00
2023-05-12 16:45:59 +09:00
2023-05-12 17:06:03 +09:00
2015-10-21 15:18:35 +01:00
2018-01-10 09:29:51 +01:00
2018-02-17 13:21:18 +01:00
2016-01-22 18:04:28 -05:00
2016-04-04 09:46:47 -04:00
2017-08-24 17:12:18 -07:00
2018-05-30 07:50:49 +02:00
2016-07-29 17:54:17 -07:00
2023-05-12 16:43:50 +09:00
2023-05-12 16:43:50 +09:00
2017-01-06 10:40:13 +01:00
2018-05-01 16:49:34 +00:00
2015-12-03 10:24:08 -05:00
2017-03-26 13:05:58 +02:00
2020-02-04 13:48:58 +09:00
2019-05-06 21:14:10 +08:00
2015-11-24 09:56:43 +01:00
2015-09-03 02:42:20 +02:00
2023-05-12 16:56:08 +09:00
2017-10-12 22:31:24 +02:00
2016-06-30 18:05:09 -05:00
2016-01-14 16:00:49 -08:00
2015-04-12 21:03:31 +02:00
2018-07-18 13:22:08 +00:00
2017-07-21 07:42:21 +02:00
2023-05-12 16:46:21 +09:00
2016-07-28 16:07:41 -07:00
2016-01-20 17:09:18 -08:00
2018-05-19 10:27:00 +02:00
2018-01-10 09:29:52 +01:00
2016-10-11 15:06:33 -07:00
2015-11-23 09:44:58 +01:00
2017-12-14 09:28:24 +01:00
2023-04-21 13:52:34 +09:00
2016-01-20 17:09:18 -08:00
2015-05-12 09:46:00 +02:00
2023-05-12 16:39:07 +09:00
2018-06-05 10:28:57 +02:00
2016-09-01 17:52:01 -07:00
2016-01-20 17:09:18 -08:00
2016-08-02 19:35:27 -04:00
2015-10-23 17:55:10 +09:00
2018-04-08 12:12:43 +02:00
2016-08-02 19:35:30 -04:00
2023-05-12 16:38:55 +09:00
2016-02-09 11:54:23 +01:00
2023-04-21 13:52:34 +09:00
2017-03-12 06:41:45 +01:00
2018-02-28 10:18:34 +01:00
2016-04-11 22:43:43 +01:00
2023-04-21 13:52:34 +09:00
2015-09-01 08:40:25 -07:00
2016-02-16 13:04:58 -05:00
2017-05-20 14:28:40 +02:00
2018-06-03 02:57:35 -07:00
2015-11-09 15:53:39 -08:00
2017-05-25 15:44:38 +02:00
2018-04-13 19:47:53 +02:00
2016-07-15 10:41:42 +02:00
2017-06-14 15:05:54 +02:00
2015-01-17 10:02:23 +13:00
2015-09-10 13:29:01 -07:00
2018-05-30 07:50:29 +02:00
2018-04-24 09:34:09 +02:00
2018-05-22 16:58:02 +02:00
2018-05-30 07:50:18 +02:00
2023-05-12 16:55:46 +09:00
2016-10-11 15:06:33 -07:00
2016-03-01 20:36:56 +01:00
2023-05-12 16:46:40 +09:00
2017-02-14 15:25:42 -08:00
2023-05-12 16:43:35 +09:00
2016-09-13 14:41:36 +02:00
2018-05-30 13:19:56 +02:00
2016-05-20 17:58:30 -07:00
2023-05-12 17:14:54 +09:00
2016-08-02 19:35:02 -04:00
2016-11-03 16:55:58 -04:00
2016-08-22 10:01:49 -07:00
2018-05-09 09:50:20 +02:00
2016-02-29 09:53:09 +01:00
2017-06-17 06:41:51 +02:00
2018-01-10 09:29:52 +01:00
2016-09-05 13:52:39 +02:00
2016-09-22 20:00:36 -05:00
2018-04-03 11:15:30 -07:00
2016-09-22 20:00:36 -05:00
2018-05-09 19:39:28 -07:00
2018-05-09 19:39:28 -07:00
2017-11-15 15:53:17 +01:00
2018-08-07 14:43:24 +08:00