Commit 6b50026
mm, pcp: allow restoring percpu_pagelist_fraction default
commit 7cd2b0a upstream.
Oleg reports a division by zero error on zero-length write() to the
percpu_pagelist_fraction sysctl:
divide error: 0000 [#1] SMP DEBUG_PAGEALLOC
CPU: 1 PID: 9142 Comm: badarea_io Not tainted 3.15.0-rc2-vm-nfs+ #19
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
task: ffff8800d5aeb6e0 ti: ffff8800d87a2000 task.ti: ffff8800d87a2000
RIP: 0010: percpu_pagelist_fraction_sysctl_handler+0x84/0x120
RSP: 0018:ffff8800d87a3e78 EFLAGS: 00010246
RAX: 0000000000000f89 RBX: ffff88011f7fd000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000010
RBP: ffff8800d87a3e98 R08: ffffffff81d002c8 R09: ffff8800d87a3f50
R10: 000000000000000b R11: 0000000000000246 R12: 0000000000000060
R13: ffffffff81c3c3e0 R14: ffffffff81cfddf8 R15: ffff8801193b0800
FS: 00007f614f1e9740(0000) GS:ffff88011f440000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00007f614f1fa000 CR3: 00000000d9291000 CR4: 00000000000006e0
Call Trace:
proc_sys_call_handler+0xb3/0xc0
proc_sys_write+0x14/0x20
vfs_write+0xba/0x1e0
SyS_write+0x46/0xb0
tracesys+0xe1/0xe6
However, if the percpu_pagelist_fraction sysctl is set by the user, it
is also impossible to restore it to the kernel default since the user
cannot write 0 to the sysctl.
This patch allows the user to write 0 to restore the default behavior.
It still requires a fraction equal to or larger than 8, however, as
stated by the documentation for sanity. If a value in the range [1, 7]
is written, the sysctl will return EINVAL.
This successfully solves the divide by zero issue at the same time.
Signed-off-by: David Rientjes <rientjes@google.com>
Reported-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>1 parent 78a97b5 commit 6b50026
3 files changed
+31
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
667 | | - | |
| 667 | + | |
| 668 | + | |
668 | 669 | | |
669 | 670 | | |
670 | 671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | 141 | | |
143 | 142 | | |
144 | 143 | | |
| |||
1287 | 1286 | | |
1288 | 1287 | | |
1289 | 1288 | | |
1290 | | - | |
| 1289 | + | |
1291 | 1290 | | |
1292 | 1291 | | |
1293 | 1292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
4079 | 4080 | | |
4080 | 4081 | | |
4081 | 4082 | | |
4082 | | - | |
| 4083 | + | |
4083 | 4084 | | |
4084 | 4085 | | |
4085 | 4086 | | |
| |||
4195 | 4196 | | |
4196 | 4197 | | |
4197 | 4198 | | |
4198 | | - | |
4199 | | - | |
| 4199 | + | |
| 4200 | + | |
4200 | 4201 | | |
4201 | 4202 | | |
4202 | 4203 | | |
| |||
5789 | 5790 | | |
5790 | 5791 | | |
5791 | 5792 | | |
5792 | | - | |
| 5793 | + | |
5793 | 5794 | | |
5794 | 5795 | | |
| 5796 | + | |
| 5797 | + | |
| 5798 | + | |
5795 | 5799 | | |
5796 | | - | |
5797 | | - | |
| 5800 | + | |
| 5801 | + | |
| 5802 | + | |
| 5803 | + | |
| 5804 | + | |
| 5805 | + | |
| 5806 | + | |
| 5807 | + | |
| 5808 | + | |
| 5809 | + | |
| 5810 | + | |
| 5811 | + | |
| 5812 | + | |
| 5813 | + | |
5798 | 5814 | | |
5799 | | - | |
5800 | 5815 | | |
5801 | | - | |
5802 | | - | |
| 5816 | + | |
| 5817 | + | |
5803 | 5818 | | |
5804 | | - | |
5805 | | - | |
| 5819 | + | |
| 5820 | + | |
5806 | 5821 | | |
| 5822 | + | |
5807 | 5823 | | |
5808 | | - | |
| 5824 | + | |
5809 | 5825 | | |
5810 | 5826 | | |
5811 | 5827 | | |
| |||
0 commit comments