Michal Hocko
20ab67a563
mm: workingset: fix NULL ptr in count_shadow_nodes
...
Commit 0a6b76dd23fa ("mm: workingset: make shadow node shrinker memcg
aware") has made the workingset shadow nodes shrinker memcg aware. The
implementation is not correct though because memcg_kmem_enabled() might
become true while we are doing a global reclaim when the sc->memcg might
be NULL which is exactly what Marek has seen:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000400
IP: [<ffffffff8122d520>] mem_cgroup_node_nr_lru_pages+0x20/0x40
PGD 0
Oops: 0000 [#1 ] SMP
CPU: 0 PID: 60 Comm: kswapd0 Tainted: G O 4.8.10-12.pvops.qubes.x86_64 #1
task: ffff880011863b00 task.stack: ffff880011868000
RIP: mem_cgroup_node_nr_lru_pages+0x20/0x40
RSP: e02b:ffff88001186bc70 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff88001186bd20 RCX: 0000000000000002
RDX: 000000000000000c RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffff88001186bc70 R08: 28f5c28f5c28f5c3 R09: 0000000000000000
R10: 0000000000006c34 R11: 0000000000000333 R12: 00000000000001f6
R13: ffffffff81c6f6a0 R14: 0000000000000000 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff880013c00000(0000) knlGS:ffff880013d00000
CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000400 CR3: 00000000122f2000 CR4: 0000000000042660
Call Trace:
count_shadow_nodes+0x9a/0xa0
shrink_slab.part.42+0x119/0x3e0
shrink_node+0x22c/0x320
kswapd+0x32c/0x700
kthread+0xd8/0xf0
ret_from_fork+0x1f/0x40
Code: 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 3b 35 dd eb b1 00 55 48 89 e5 73 2c 89 d2 31 c9 31 c0 4c 63 ce 48 0f a3 ca 73 13 <4a> 8b b4 cf 00 04 00 00 41 89 c8 4a 03 84 c6 80 00 00 00 83 c1
RIP mem_cgroup_node_nr_lru_pages+0x20/0x40
RSP <ffff88001186bc70>
CR2: 0000000000000400
---[ end trace 100494b9edbdfc4d ]---
This patch fixes the issue by checking sc->memcg rather than
memcg_kmem_enabled() which is sufficient because shrink_slab makes sure
that only memcg aware shrinkers will get non-NULL memcgs and only if
memcg_kmem_enabled is true.
Fixes: 0a6b76dd23fa ("mm: workingset: make shadow node shrinker memcg aware")
Link: http://lkml.kernel.org/r/20161201132156.21450-1-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Reported-by: Marek Marczykowski-Górecki <marmarek@mimuw.edu.pl>
Tested-by: Marek Marczykowski-Górecki <marmarek@mimuw.edu.pl>
Acked-by: Vladimir Davydov <vdavydov.dev@gmail.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Balbir Singh <bsingharora@gmail.com>
Cc: <stable@vger.kernel.org> [4.6+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-12-02 18:48:03 -08:00
..
2016-11-30 16:32:52 -08:00
2016-08-04 14:19:16 -06:00
2016-07-26 16:19:19 -07:00
2016-10-11 15:06:33 -07:00
2016-01-27 09:09:57 -05:00
2015-07-17 16:39:54 -07:00
2016-11-11 08:12:37 -08:00
2015-08-14 15:56:32 -07:00
2016-10-07 18:46:29 -07:00
2016-03-17 15:09:34 -07:00
2016-10-07 18:46:29 -07:00
2016-03-17 15:09:34 -07:00
2015-11-05 19:34:48 -08:00
2016-06-09 14:23:11 -07:00
2016-03-15 16:55:16 -07:00
2016-11-11 08:12:37 -08:00
2016-10-19 08:11:24 -07:00
2016-07-26 16:19:19 -07:00
2016-10-24 19:13:20 -07:00
2016-05-19 19:12:14 -07:00
2016-11-29 08:20:24 -08:00
2016-05-20 17:58:30 -07:00
2016-11-11 08:12:37 -08:00
2015-09-10 13:29:01 -07:00
2016-10-07 18:46:29 -07:00
2016-10-27 16:23:01 -07:00
2016-09-13 02:35:27 +02:00
2016-11-30 16:32:52 -08:00
2016-03-17 15:09:34 -07:00
2016-03-17 15:09:34 -07:00
2016-11-11 08:12:37 -08:00
2016-10-07 18:46:29 -07:00
2016-10-27 18:43:42 -07:00
2016-05-22 17:21:27 -07:00
2016-05-23 17:04:14 -07:00
2016-10-12 10:23:41 -07:00
2016-10-11 15:06:33 -07:00
2016-10-27 18:43:43 -07:00
2016-10-27 15:49:12 -07:00
2016-11-11 08:12:37 -08:00
2016-10-19 08:31:25 -07:00
2016-10-19 08:11:43 -07:00
2016-07-28 16:07:41 -07:00
2015-09-08 15:35:28 -07:00
2016-10-07 18:46:29 -07:00
2016-10-07 18:46:28 -07:00
2016-11-30 16:32:52 -08:00
2016-03-17 15:09:34 -07:00
2016-10-07 18:46:29 -07:00
2016-04-28 11:44:19 +02:00
2016-03-17 15:09:34 -07:00
2016-05-19 19:12:14 -07:00
2016-10-19 17:28:48 +02:00
2016-11-29 08:20:24 -08:00
2015-11-05 19:34:48 -08:00
2016-10-11 15:06:33 -07:00
2016-10-24 19:13:20 -07:00
2016-10-07 18:46:29 -07:00
2016-11-11 08:12:37 -08:00
2015-11-05 19:34:48 -08:00
2016-10-07 18:46:27 -07:00
2016-07-28 16:07:41 -07:00
2016-10-07 18:46:29 -07:00
2016-10-07 18:46:29 -07:00
2016-10-07 18:46:27 -07:00
2016-06-03 15:06:22 -07:00
2016-10-07 18:46:28 -07:00
2016-01-15 17:56:32 -08:00
2016-03-17 15:09:34 -07:00
2016-10-05 11:52:55 -04:00
2016-03-17 15:09:34 -07:00
2016-10-18 14:13:37 -07:00
2016-03-17 15:09:34 -07:00
2016-08-26 17:39:35 -07:00
2016-08-10 16:40:56 -07:00
2016-11-11 08:12:37 -08:00
2016-11-11 08:12:37 -08:00
2016-10-27 18:43:43 -07:00
2016-10-27 18:43:43 -07:00
2016-02-18 16:23:24 -08:00
2016-09-06 18:30:20 +02:00
2016-08-02 17:31:41 -04:00
2016-08-02 17:31:41 -04:00
2016-03-17 15:09:34 -07:00
2016-10-07 18:46:28 -07:00
2016-10-07 18:46:28 -07:00
2016-11-11 08:12:37 -08:00
2016-11-30 16:32:52 -08:00
2016-09-20 16:07:39 -07:00
2016-04-04 10:41:08 -07:00
2016-10-22 09:39:10 -07:00
2016-10-07 18:46:27 -07:00
2016-10-07 18:46:29 -07:00
2016-02-03 08:28:43 -08:00
2016-10-27 18:43:43 -07:00
2016-10-07 18:46:30 -07:00
2016-12-02 18:48:03 -08:00
2016-06-03 16:02:55 -07:00
2016-01-15 11:40:52 -08:00
2015-11-06 17:50:42 -08:00
2016-07-28 16:07:41 -07:00
2016-05-20 17:58:30 -07:00