[5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

49 messages, 9 authors, 2020-03-18 · open the first message on its own page

[5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-02-18 10:46:16

Todays next fails to boot on a POWER9 PowerVM logical partition
with following trace:

[    8.767660] random: systemd: uninitialized urandom read (16 bytes read)
[    8.768629] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.768635] Faulting instruction address: 0xc0000000003d55f4
[    8.768641] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.768645] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.768650] Modules linked in:
[    8.768655] CPU: 19 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest #1
[    8.768660] NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
[    8.768666] REGS: c0000008b37836d0 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest)
[    8.768671] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.768679] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1
[    8.768679] GPR00: c0000000003d5b94 c0000008b3783960 c00000000155d400 c0000008b301f500
[    8.768679] GPR04: 0000000000000dc0 0000000000000002 c0000000003443d8 c0000008bb398620
[    8.768679] GPR08: 00000008ba2f0000 0000000000000001 0000000000000000 0000000000000000
[    8.768679] GPR12: 0000000024004844 c00000001ec52a00 0000000000000000 0000000000000000
[    8.768679] GPR16: c0000008a1b20048 c000000001595898 c000000001750c18 0000000000000002
[    8.768679] GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122
[    8.768679] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443d8
[    8.768679] GPR28: c0000008b301f500 c0000008bb398620 0000000000000000 c00c000002287180
[    8.768727] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
[    8.768732] LR [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768735] Call Trace:
[    8.768739] [c0000008b3783960] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[    8.768745] [c0000008b3783a40] [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768751] [c0000008b3783a70] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[    8.768757] [c0000008b3783af0] [c0000000003443d8] kvmalloc_node+0x58/0x110
[    8.768763] [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[    8.768769] [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[    8.768775] [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.768781] [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[    8.768786] [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[    8.768792] [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[    8.768797] [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[    8.768804] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.768808] Instruction dump:
[    8.768811] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088
[    8.768818] 3ea2000c 3ab57070 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a
[    8.768826] ---[ end trace 631af2cb73507891 ]---
[    8.770876]
[    9.770887] Kernel panic - not syncing: Fatal exception

Bisect reveals the problem was introduced in next-20200217 by following commit 

commit a75056fc1e7c 
mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node

I can boot the kernel successfully if the patch is reverted. 

Boot log attached.

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Kirill Tkhai <hidden>
Date: 2020-02-18 10:51:22

Hi, Sachin,

On 18.02.2020 13:45, Sachin Sant wrote:
Todays next fails to boot on a POWER9 PowerVM logical partition
with following trace:

[    8.767660] random: systemd: uninitialized urandom read (16 bytes read)
[    8.768629] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.768635] Faulting instruction address: 0xc0000000003d55f4
[    8.768641] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.768645] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.768650] Modules linked in:
[    8.768655] CPU: 19 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest #1
[    8.768660] NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
[    8.768666] REGS: c0000008b37836d0 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest)
[    8.768671] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.768679] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1
[    8.768679] GPR00: c0000000003d5b94 c0000008b3783960 c00000000155d400 c0000008b301f500
[    8.768679] GPR04: 0000000000000dc0 0000000000000002 c0000000003443d8 c0000008bb398620
[    8.768679] GPR08: 00000008ba2f0000 0000000000000001 0000000000000000 0000000000000000
[    8.768679] GPR12: 0000000024004844 c00000001ec52a00 0000000000000000 0000000000000000
[    8.768679] GPR16: c0000008a1b20048 c000000001595898 c000000001750c18 0000000000000002
[    8.768679] GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122
[    8.768679] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443d8
[    8.768679] GPR28: c0000008b301f500 c0000008bb398620 0000000000000000 c00c000002287180
[    8.768727] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
[    8.768732] LR [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768735] Call Trace:
[    8.768739] [c0000008b3783960] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[    8.768745] [c0000008b3783a40] [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768751] [c0000008b3783a70] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[    8.768757] [c0000008b3783af0] [c0000000003443d8] kvmalloc_node+0x58/0x110
[    8.768763] [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[    8.768769] [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[    8.768775] [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.768781] [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[    8.768786] [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[    8.768792] [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[    8.768797] [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[    8.768804] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.768808] Instruction dump:
[    8.768811] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088
[    8.768818] 3ea2000c 3ab57070 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a
[    8.768826] ---[ end trace 631af2cb73507891 ]---
[    8.770876]
[    9.770887] Kernel panic - not syncing: Fatal exception

Bisect reveals the problem was introduced in next-20200217 by following commit 

commit a75056fc1e7c 
mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node

I can boot the kernel successfully if the patch is reverted. 

could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/

?

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Kirill Tkhai <hidden>
Date: 2020-02-18 11:02:03

On 18.02.2020 13:50, Kirill Tkhai wrote:
Hi, Sachin,

On 18.02.2020 13:45, Sachin Sant wrote:
quoted
Todays next fails to boot on a POWER9 PowerVM logical partition
with following trace:

[    8.767660] random: systemd: uninitialized urandom read (16 bytes read)
[    8.768629] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.768635] Faulting instruction address: 0xc0000000003d55f4
[    8.768641] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.768645] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.768650] Modules linked in:
[    8.768655] CPU: 19 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest #1
[    8.768660] NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
[    8.768666] REGS: c0000008b37836d0 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest)
[    8.768671] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.768679] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1
[    8.768679] GPR00: c0000000003d5b94 c0000008b3783960 c00000000155d400 c0000008b301f500
[    8.768679] GPR04: 0000000000000dc0 0000000000000002 c0000000003443d8 c0000008bb398620
[    8.768679] GPR08: 00000008ba2f0000 0000000000000001 0000000000000000 0000000000000000
[    8.768679] GPR12: 0000000024004844 c00000001ec52a00 0000000000000000 0000000000000000
[    8.768679] GPR16: c0000008a1b20048 c000000001595898 c000000001750c18 0000000000000002
[    8.768679] GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122
[    8.768679] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443d8
[    8.768679] GPR28: c0000008b301f500 c0000008bb398620 0000000000000000 c00c000002287180
[    8.768727] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
[    8.768732] LR [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768735] Call Trace:
[    8.768739] [c0000008b3783960] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[    8.768745] [c0000008b3783a40] [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768751] [c0000008b3783a70] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[    8.768757] [c0000008b3783af0] [c0000000003443d8] kvmalloc_node+0x58/0x110
[    8.768763] [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[    8.768769] [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[    8.768775] [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.768781] [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[    8.768786] [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[    8.768792] [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[    8.768797] [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[    8.768804] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.768808] Instruction dump:
[    8.768811] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088
[    8.768818] 3ea2000c 3ab57070 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a
[    8.768826] ---[ end trace 631af2cb73507891 ]---
[    8.770876]
[    9.770887] Kernel panic - not syncing: Fatal exception

Bisect reveals the problem was introduced in next-20200217 by following commit 

commit a75056fc1e7c 
mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node

I can boot the kernel successfully if the patch is reverted. 

could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/
After you tried the above patch instead of the problem patch,
do one more test and apply the below on current linux-next.
Please, say which of the patches makes your kernel bootable again.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..7b9b48dcbc60 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
 		if (!old)
 			return 0;
 
-		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
+		new = kmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
 		if (!new)
 			return -ENOMEM;
 
@@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
 	mutex_lock(&memcg_shrinker_map_mutex);
 	size = memcg_shrinker_map_size;
 	for_each_node(nid) {
-		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
+		map = kzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
 		if (!map) {
 			memcg_free_shrinker_maps(memcg);
 			ret = -ENOMEM;

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Kirill Tkhai <hidden>
Date: 2020-02-18 11:35:15

On 18.02.2020 14:01, Kirill Tkhai wrote:
quoted hunk
On 18.02.2020 13:50, Kirill Tkhai wrote:
quoted
Hi, Sachin,

On 18.02.2020 13:45, Sachin Sant wrote:
quoted
Todays next fails to boot on a POWER9 PowerVM logical partition
with following trace:

[    8.767660] random: systemd: uninitialized urandom read (16 bytes read)
[    8.768629] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.768635] Faulting instruction address: 0xc0000000003d55f4
[    8.768641] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.768645] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.768650] Modules linked in:
[    8.768655] CPU: 19 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest #1
[    8.768660] NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
[    8.768666] REGS: c0000008b37836d0 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest)
[    8.768671] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.768679] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1
[    8.768679] GPR00: c0000000003d5b94 c0000008b3783960 c00000000155d400 c0000008b301f500
[    8.768679] GPR04: 0000000000000dc0 0000000000000002 c0000000003443d8 c0000008bb398620
[    8.768679] GPR08: 00000008ba2f0000 0000000000000001 0000000000000000 0000000000000000
[    8.768679] GPR12: 0000000024004844 c00000001ec52a00 0000000000000000 0000000000000000
[    8.768679] GPR16: c0000008a1b20048 c000000001595898 c000000001750c18 0000000000000002
[    8.768679] GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122
[    8.768679] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443d8
[    8.768679] GPR28: c0000008b301f500 c0000008bb398620 0000000000000000 c00c000002287180
[    8.768727] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
[    8.768732] LR [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768735] Call Trace:
[    8.768739] [c0000008b3783960] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[    8.768745] [c0000008b3783a40] [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.768751] [c0000008b3783a70] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[    8.768757] [c0000008b3783af0] [c0000000003443d8] kvmalloc_node+0x58/0x110
[    8.768763] [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[    8.768769] [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[    8.768775] [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.768781] [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[    8.768786] [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[    8.768792] [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[    8.768797] [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[    8.768804] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.768808] Instruction dump:
[    8.768811] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088
[    8.768818] 3ea2000c 3ab57070 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a
[    8.768826] ---[ end trace 631af2cb73507891 ]---
[    8.770876]
[    9.770887] Kernel panic - not syncing: Fatal exception

Bisect reveals the problem was introduced in next-20200217 by following commit 

commit a75056fc1e7c 
mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node

I can boot the kernel successfully if the patch is reverted. 

could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/
After you tried the above patch instead of the problem patch,
do one more test and apply the below on current linux-next.
Please, say which of the patches makes your kernel bootable again.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..7b9b48dcbc60 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
 		if (!old)
 			return 0;
 
-		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
+		new = kmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
 		if (!new)
 			return -ENOMEM;
 
@@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
 	mutex_lock(&memcg_shrinker_map_mutex);
 	size = memcg_shrinker_map_size;
 	for_each_node(nid) {
-		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
+		map = kzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
 		if (!map) {
 			memcg_free_shrinker_maps(memcg);
 			ret = -ENOMEM;
Hm, though vmalloc() itself should not bring a problem, since it's already used
in profile_init(), which goes before cgroup_init() in start_kernel(), and
CONFIG_PROFILING=y is enabled in every powerpc defconfig.

Ok, I'm waiting for results of your tests.

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-02-18 11:38:49

On 18-Feb-2020, at 4:20 PM, Kirill Tkhai [off-list ref] wrote:

Hi, Sachin,

On 18.02.2020 13:45, Sachin Sant wrote:
quoted
commit a75056fc1e7c 
mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node

I can boot the kernel successfully if the patch is reverted. 

could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/

?
With this original patch I can boot the machine successfully.

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-02-18 11:40:57

quoted hunk
quoted
could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/
After you tried the above patch instead of the problem patch,
do one more test and apply the below on current linux-next.
Please, say which of the patches makes your kernel bootable again.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..7b9b48dcbc60 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
		if (!old)
			return 0;

-		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
+		new = kmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
		if (!new)
			return -ENOMEM;
@@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
	mutex_lock(&memcg_shrinker_map_mutex);
	size = memcg_shrinker_map_size;
	for_each_node(nid) {
-		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
+		map = kzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
		if (!map) {
			memcg_free_shrinker_maps(memcg);
			ret = -ENOMEM;
With this incremental patch applied on top of current linux-next, machine fails to boot

[    8.868433] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.868439] Faulting instruction address: 0xc0000000003d55f4
[    8.868444] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.868449] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.868453] Modules linked in:
[    8.868458] CPU: 18 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest+ #4
[    8.868463] NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
[    8.868468] REGS: c0000008b3783710 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest+)
[    8.868474] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.868481] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1 
[    8.868481] GPR00: c0000000003d5b94 c0000008b37839a0 c00000000155d400 c0000008b301f500 
[    8.868481] GPR04: 0000000000000dc0 0000000000000002 c0000000003fee38 c0000008bb298620 
[    8.868481] GPR08: 00000008ba1f0000 0000000000000001 0000000000000000 0000000000000000 
[    8.868481] GPR12: 0000000024004844 c00000001ec54200 0000000000000000 0000000000000000 
[    8.868481] GPR16: c0000008a1a60048 c000000001595898 c000000001750c18 0000000000000002 
[    8.868481] GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122 
[    8.868481] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003fee38 
[    8.868481] GPR28: c0000008b301f500 c0000008bb298620 0000000000000000 c00c000002286d00 
[    8.868529] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
[    8.868534] LR [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.868538] Call Trace:
[    8.868541] [c0000008b37839a0] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[    8.868547] [c0000008b3783a80] [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.868553] [c0000008b3783ab0] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[    8.868559] [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[    8.868565] [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[    8.868571] [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.868577] [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[    8.868583] [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[    8.868589] [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[    8.868594] [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[    8.868601] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.868605] Instruction dump:
[    8.868608] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088 
[    8.868615] 3ea2000c 3ab57070 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a 
[    8.868623] ---[ end trace f9b8e3c36493f430 ]---
[    8.870690] 
[    9.870701] Kernel panic - not syncing: Fatal exception

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Kirill Tkhai <hidden>
Date: 2020-02-18 11:53:26

On 18.02.2020 14:38, Sachin Sant wrote:
quoted
On 18-Feb-2020, at 4:20 PM, Kirill Tkhai [off-list ref] wrote:

Hi, Sachin,

On 18.02.2020 13:45, Sachin Sant wrote:
quoted
commit a75056fc1e7c 
mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node

I can boot the kernel successfully if the patch is reverted. 

could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/

?
With this original patch I can boot the machine successfully.
Ok, thanks.

I think, there is no a problem in the commited patch, since mem_cgroup_css_alloc()
is called from the place, where any memory allocations have to be allowed. This
is one of the reason, memory_cgrp_subsys.early_init is 0, and all nodes allocations
should be availeble there.

The problem is not in vmalloc() itself, since the second patch with kmalloc_node()
also fails on your setup. Maybe, the reproduction depends on amount of allocated
memory. For me this looks like a problem in powerpc, but it would be interesting
to hear some comments from powerpc guys.

For now we may replace the commited patch with v2 (https://patchwork.kernel.org/patch/11360007/)
containing workaround, which we have in another alloc_mem_cgroup_per_node_info() allocations.

Kirill

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-18 11:55:31

On Tue 18-02-20 17:10:47, Sachin Sant wrote:
quoted
quoted
could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/
After you tried the above patch instead of the problem patch,
do one more test and apply the below on current linux-next.
Please, say which of the patches makes your kernel bootable again.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..7b9b48dcbc60 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
		if (!old)
			return 0;

-		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
+		new = kmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
		if (!new)
			return -ENOMEM;
@@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
	mutex_lock(&memcg_shrinker_map_mutex);
	size = memcg_shrinker_map_size;
	for_each_node(nid) {
-		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
+		map = kzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
		if (!map) {
			memcg_free_shrinker_maps(memcg);
			ret = -ENOMEM;
With this incremental patch applied on top of current linux-next, machine fails to boot
Your calltrace points to a standard system call path. I do not see any
reason why that commit should cause any problems. Do you see the
same when applying the patch you managed to bisect to on top of Linus
tree? Just to rule out any other potential problems in linux-next?
This all smells like a corrupted slab allocator. Which allocator do
you use?
[    8.868433] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.868439] Faulting instruction address: 0xc0000000003d55f4
[    8.868444] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.868449] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.868453] Modules linked in:
[    8.868458] CPU: 18 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-next-20200218-autotest+ #4
[    8.868463] NIP:  c0000000003d55f4 LR: c0000000003d5b94 CTR: 0000000000000000
[    8.868468] REGS: c0000008b3783710 TRAP: 0300   Not tainted  (5.6.0-rc2-next-20200218-autotest+)
[    8.868474] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.868481] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1 
[    8.868481] GPR00: c0000000003d5b94 c0000008b37839a0 c00000000155d400 c0000008b301f500 
[    8.868481] GPR04: 0000000000000dc0 0000000000000002 c0000000003fee38 c0000008bb298620 
[    8.868481] GPR08: 00000008ba1f0000 0000000000000001 0000000000000000 0000000000000000 
[    8.868481] GPR12: 0000000024004844 c00000001ec54200 0000000000000000 0000000000000000 
[    8.868481] GPR16: c0000008a1a60048 c000000001595898 c000000001750c18 0000000000000002 
[    8.868481] GPR20: c000000001750c28 c000000001624470 0000000fffffffe0 5deadbeef0000122 
[    8.868481] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003fee38 
[    8.868481] GPR28: c0000008b301f500 c0000008bb298620 0000000000000000 c00c000002286d00 
[    8.868529] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
[    8.868534] LR [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.868538] Call Trace:
[    8.868541] [c0000008b37839a0] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[    8.868547] [c0000008b3783a80] [c0000000003d5b94] __slab_alloc+0x34/0x60
[    8.868553] [c0000008b3783ab0] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[    8.868559] [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[    8.868565] [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[    8.868571] [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.868577] [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[    8.868583] [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[    8.868589] [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[    8.868594] [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[    8.868601] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.868605] Instruction dump:
[    8.868608] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088 
[    8.868615] 3ea2000c 3ab57070 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a 
[    8.868623] ---[ end trace f9b8e3c36493f430 ]---
[    8.870690] 
[    9.870701] Kernel panic - not syncing: Fatal exception

Thanks
-Sachin
-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-02-18 14:00:56

On 18-Feb-2020, at 5:25 PM, Michal Hocko [off-list ref] wrote:

On Tue 18-02-20 17:10:47, Sachin Sant wrote:
quoted
quoted
quoted
could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/
After you tried the above patch instead of the problem patch,
do one more test and apply the below on current linux-next.
Please, say which of the patches makes your kernel bootable again.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..7b9b48dcbc60 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
		if (!old)
			return 0;

-		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
+		new = kmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
		if (!new)
			return -ENOMEM;
@@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
	mutex_lock(&memcg_shrinker_map_mutex);
	size = memcg_shrinker_map_size;
	for_each_node(nid) {
-		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
+		map = kzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
		if (!map) {
			memcg_free_shrinker_maps(memcg);
			ret = -ENOMEM;
With this incremental patch applied on top of current linux-next, machine fails to boot
Your calltrace points to a standard system call path. I do not see any
reason why that commit should cause any problems. Do you see the
same when applying the patch you managed to bisect to on top of Linus
tree? Just to rule out any other potential problems in linux-next?
Yes, I can recreate the same problem with the patch applied on top of
5.6.0-rc2. 

CONFIG_SLUB is enabled in my case. I have attached the .config.
The LPAR has 34GB of memory allocated.

[    8.766078] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.766083] Faulting instruction address: 0xc0000000003d38a4
[    8.766089] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.766093] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.766098] Modules linked in:
[    8.766103] CPU: 12 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-autotest+ #2
[    8.766107] NIP:  c0000000003d38a4 LR: c0000000003d3e44 CTR: 0000000000000000
[    8.766113] REGS: c0000008b37836e0 TRAP: 0300   Not tainted  (5.6.0-rc2-autotest+)
[    8.766118] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.766125] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1 
[    8.766125] GPR00: c0000000003d3e44 c0000008b3783970 c00000000155d500 c0000008b301f500 
[    8.766125] GPR04: 0000000000000dc0 0000000000000002 c0000000003443f8 c0000008bac98620 
[    8.766125] GPR08: 00000008b9bf0000 0000000000000001 0000000000000000 0000000000000000 
[    8.766125] GPR12: 0000000024004844 c00000001ec5d200 0000000000000000 0000000000000000 
[    8.766125] GPR16: c000000007be2048 c000000001595818 c000000001750c98 0000000000000002 
[    8.766125] GPR20: c000000001750ca8 c000000001624470 0000000fffffffe0 5deadbeef0000122 
[    8.766125] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443f8 
[    8.766125] GPR28: c0000008b301f500 c0000008bac98620 0000000000000000 c00c000002286fc0 
[    8.766172] NIP [c0000000003d38a4] ___slab_alloc+0x1f4/0x760
[    8.766177] LR [c0000000003d3e44] __slab_alloc+0x34/0x60
[    8.766181] Call Trace:
[    8.766184] [c0000008b3783970] [c0000000003d39e4] ___slab_alloc+0x334/0x760 (unreliable)
[    8.766191] [c0000008b3783a50] [c0000000003d3e44] __slab_alloc+0x34/0x60
[    8.766196] [c0000008b3783a80] [c0000000003d5250] __kmalloc_node+0x110/0x490
[    8.766203] [c0000008b3783b00] [c0000000003443f8] kvmalloc_node+0x58/0x110
[    8.766208] [c0000008b3783b40] [c0000000003fcf58] mem_cgroup_css_online+0x108/0x270
[    8.766215] [c0000008b3783ba0] [c000000000236078] online_css+0x48/0xd0
[    8.766220] [c0000008b3783bd0] [c00000000023eebc] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.766226] [c0000008b3783cb0] [c000000000242728] cgroup_mkdir+0x228/0x5f0
[    8.766232] [c0000008b3783d20] [c00000000051ab48] kernfs_iop_mkdir+0xb8/0x170
[    8.766238] [c0000008b3783d50] [c00000000043a7c0] vfs_mkdir+0x110/0x230
[    8.766243] [c0000008b3783da0] [c00000000043e8a0] do_mkdirat+0xb0/0x1a0
[    8.766249] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.766253] Instruction dump:
[    8.766257] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088 
[    8.766264] 3ea2000c 3ab56f70 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a 
[    8.766271] ---[ end trace d651c32e3d9219fb ]---
[    8.768347] 
[    9.768359] Kernel panic - not syncing: Fatal exception

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-18 14:26:27

On Tue 18-02-20 19:30:33, Sachin Sant wrote:
quoted
On 18-Feb-2020, at 5:25 PM, Michal Hocko [off-list ref] wrote:

On Tue 18-02-20 17:10:47, Sachin Sant wrote:
quoted
quoted
quoted
could you please test your boot with original patch from here:

https://patchwork.kernel.org/patch/11360007/
After you tried the above patch instead of the problem patch,
do one more test and apply the below on current linux-next.
Please, say which of the patches makes your kernel bootable again.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..7b9b48dcbc60 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
		if (!old)
			return 0;

-		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
+		new = kmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
		if (!new)
			return -ENOMEM;
@@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
	mutex_lock(&memcg_shrinker_map_mutex);
	size = memcg_shrinker_map_size;
	for_each_node(nid) {
-		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
+		map = kzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
		if (!map) {
			memcg_free_shrinker_maps(memcg);
			ret = -ENOMEM;
With this incremental patch applied on top of current linux-next, machine fails to boot
Your calltrace points to a standard system call path. I do not see any
reason why that commit should cause any problems. Do you see the
same when applying the patch you managed to bisect to on top of Linus
tree? Just to rule out any other potential problems in linux-next?
Yes, I can recreate the same problem with the patch applied on top of
5.6.0-rc2. 
And just to make sure. This was with http://lkml.kernel.org/r/fff0e636-4c36-ed10-281c-8cdb0687c839@virtuozzo.com
right?

If yes, is it possible that the specific node is somehow crippled (e.g.
some nodes don't have any memory and thus the allocator blows up)? In
other words what is the numa topology? (numactl -H)
CONFIG_SLUB is enabled in my case. I have attached the .config.
The LPAR has 34GB of memory allocated.

[    8.766078] BUG: Kernel NULL pointer dereference on read at 0x000073b0
[    8.766083] Faulting instruction address: 0xc0000000003d38a4
[    8.766089] Oops: Kernel access of bad area, sig: 11 [#1]
[    8.766093] LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
[    8.766098] Modules linked in:
[    8.766103] CPU: 12 PID: 1 Comm: systemd Not tainted 5.6.0-rc2-autotest+ #2
[    8.766107] NIP:  c0000000003d38a4 LR: c0000000003d3e44 CTR: 0000000000000000
[    8.766113] REGS: c0000008b37836e0 TRAP: 0300   Not tainted  (5.6.0-rc2-autotest+)
[    8.766118] MSR:  8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 24004844  XER: 00000000
[    8.766125] CFAR: c00000000000dec4 DAR: 00000000000073b0 DSISR: 40000000 IRQMASK: 1 
[    8.766125] GPR00: c0000000003d3e44 c0000008b3783970 c00000000155d500 c0000008b301f500 
[    8.766125] GPR04: 0000000000000dc0 0000000000000002 c0000000003443f8 c0000008bac98620 
[    8.766125] GPR08: 00000008b9bf0000 0000000000000001 0000000000000000 0000000000000000 
[    8.766125] GPR12: 0000000024004844 c00000001ec5d200 0000000000000000 0000000000000000 
[    8.766125] GPR16: c000000007be2048 c000000001595818 c000000001750c98 0000000000000002 
[    8.766125] GPR20: c000000001750ca8 c000000001624470 0000000fffffffe0 5deadbeef0000122 
[    8.766125] GPR24: 0000000000000001 0000000000000dc0 0000000000000002 c0000000003443f8 
[    8.766125] GPR28: c0000008b301f500 c0000008bac98620 0000000000000000 c00c000002286fc0 
[    8.766172] NIP [c0000000003d38a4] ___slab_alloc+0x1f4/0x760
[    8.766177] LR [c0000000003d3e44] __slab_alloc+0x34/0x60
[    8.766181] Call Trace:
[    8.766184] [c0000008b3783970] [c0000000003d39e4] ___slab_alloc+0x334/0x760 (unreliable)
[    8.766191] [c0000008b3783a50] [c0000000003d3e44] __slab_alloc+0x34/0x60
[    8.766196] [c0000008b3783a80] [c0000000003d5250] __kmalloc_node+0x110/0x490
[    8.766203] [c0000008b3783b00] [c0000000003443f8] kvmalloc_node+0x58/0x110
[    8.766208] [c0000008b3783b40] [c0000000003fcf58] mem_cgroup_css_online+0x108/0x270
[    8.766215] [c0000008b3783ba0] [c000000000236078] online_css+0x48/0xd0
[    8.766220] [c0000008b3783bd0] [c00000000023eebc] cgroup_apply_control_enable+0x2ec/0x4d0
[    8.766226] [c0000008b3783cb0] [c000000000242728] cgroup_mkdir+0x228/0x5f0
[    8.766232] [c0000008b3783d20] [c00000000051ab48] kernfs_iop_mkdir+0xb8/0x170
[    8.766238] [c0000008b3783d50] [c00000000043a7c0] vfs_mkdir+0x110/0x230
[    8.766243] [c0000008b3783da0] [c00000000043e8a0] do_mkdirat+0xb0/0x1a0
[    8.766249] [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68
[    8.766253] Instruction dump:
[    8.766257] 7c421378 e95f0000 714a0001 4082fff0 4bffff64 60000000 60000000 faa10088 
[    8.766264] 3ea2000c 3ab56f70 7b4a1f24 7d55502a <e94a73b0> 2faa0000 409e0394 3d02002a 
[    8.766271] ---[ end trace d651c32e3d9219fb ]---
[    8.768347] 
[    9.768359] Kernel panic - not syncing: Fatal exception

Thanks
-Sachin


-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-02-18 15:11:23

quoted
Yes, I can recreate the same problem with the patch applied on top of
5.6.0-rc2. 
And just to make sure. This was with http://lkml.kernel.org/r/fff0e636-4c36-ed10-281c-8cdb0687c839@virtuozzo.com
right?
Yes, the same patch.
If yes, is it possible that the specific node is somehow crippled (e.g.
some nodes don't have any memory and thus the allocator blows up)? In
other words what is the numa topology? (numactl -H)
Here is the o/p of numactl

# numactl -H
available: 2 nodes (0-1)
node 0 cpus:
node 0 size: 0 MB
node 0 free: 0 MB
node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
node 1 size: 35247 MB
node 1 free: 30907 MB
node distances:
node   0   1 
  0:  10  40 
  1:  40  10 
# 

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-18 15:24:45

On Tue 18-02-20 20:41:12, Sachin Sant wrote:
quoted
quoted
Yes, I can recreate the same problem with the patch applied on top of
5.6.0-rc2. 
And just to make sure. This was with http://lkml.kernel.org/r/fff0e636-4c36-ed10-281c-8cdb0687c839@virtuozzo.com
right?
Yes, the same patch.
quoted
If yes, is it possible that the specific node is somehow crippled (e.g.
some nodes don't have any memory and thus the allocator blows up)? In
other words what is the numa topology? (numactl -H)
Here is the o/p of numactl

# numactl -H
available: 2 nodes (0-1)
node 0 cpus:
node 0 size: 0 MB
node 0 free: 0 MB
OK, so what I expected. The node0 is memory less or simply not present
at all. Fun!

Anyway, I do not think it is expected that kmalloc_node just blows up
on those nodes. The page allocator simply falls back to the closest
node. Something for kmalloc maintainers I believe.

A short summary. kmalloc_node blows up when trying to allocate from a
memory less node.
node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
node 1 size: 35247 MB
node 1 free: 30907 MB
node distances:
node   0   1 
  0:  10  40 
  1:  40  10 
# 

Thanks
-Sachin
-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Christopher Lameter <hidden>
Date: 2020-02-22 03:38:12

On Tue, 18 Feb 2020, Michal Hocko wrote:
Anyway, I do not think it is expected that kmalloc_node just blows up
on those nodes. The page allocator simply falls back to the closest
node. Something for kmalloc maintainers I believe.
That is the case for an unconstrained allocation. kmalloc_node means that
you want memory from that node. And If there is no such node then it is an
error.
A short summary. kmalloc_node blows up when trying to allocate from a
memory less node.
Use kmalloc instead? And set a memory allocation policy?

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-24 08:58:16

On Sat 22-02-20 03:38:11, Cristopher Lameter wrote:
On Tue, 18 Feb 2020, Michal Hocko wrote:
quoted
Anyway, I do not think it is expected that kmalloc_node just blows up
on those nodes. The page allocator simply falls back to the closest
node. Something for kmalloc maintainers I believe.
That is the case for an unconstrained allocation. kmalloc_node means that
you want memory from that node. And If there is no such node then it is an
error.
Hmm, nasty. Is there any reason why kmalloc_node behaves differently
from the page allocator?
quoted
A short summary. kmalloc_node blows up when trying to allocate from a
memory less node.
Use kmalloc instead? And set a memory allocation policy?
The current code (memcg_expand_one_shrinker_map resp. memcg_alloc_shrinker_maps)
already use kvmalloc. Kirill's patch wanted to make those data structure
on the respective node and kvmalloc_node sounded like the right thing to
do. It comes as a surprise that the kernel simply blows up on a memory
less node rather than falling back to a close node gracefully. I suspect
this already happens when the target node is out of memory, right?

How would a memory allocation policy help in this case btw.?

-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Christopher Lameter <hidden>
Date: 2020-02-26 18:25:30

On Mon, 24 Feb 2020, Michal Hocko wrote:
Hmm, nasty. Is there any reason why kmalloc_node behaves differently
from the page allocator?
The page allocator will do the same thing if you pass GFP_THISNODE and
insist on allocating memory from a node that does not exist.

quoted
quoted
A short summary. kmalloc_node blows up when trying to allocate from a
memory less node.
Use kmalloc instead? And set a memory allocation policy?
The current code (memcg_expand_one_shrinker_map resp. memcg_alloc_shrinker_maps)
already use kvmalloc. Kirill's patch wanted to make those data structure
on the respective node and kvmalloc_node sounded like the right thing to
do. It comes as a surprise that the kernel simply blows up on a memory
less node rather than falling back to a close node gracefully. I suspect
this already happens when the target node is out of memory, right?
No. If the target node is out of memory then direct reclaim is going to be
invovked.
How would a memory allocation policy help in this case btw.?
It would allow fallback to other nodes.

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-26 18:41:56

On Wed 26-02-20 18:25:28, Cristopher Lameter wrote:
On Mon, 24 Feb 2020, Michal Hocko wrote:
quoted
Hmm, nasty. Is there any reason why kmalloc_node behaves differently
from the page allocator?
The page allocator will do the same thing if you pass GFP_THISNODE and
insist on allocating memory from a node that does not exist.
I do not think that the page allocator would blow up even with
GFP_THISNODE. The allocation would just fail on memory less node.

Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.

-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Christopher Lameter <hidden>
Date: 2020-02-26 18:44:15

On Wed, 26 Feb 2020, Michal Hocko wrote:
Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.
Kmalloc_node does not support memory policies etc. Only kmalloc does.
kmalloc_node is mostly used by subsystems that have determined the active
nodes and want a targeted allocation on those nodes.

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-26 19:02:14

On Wed 26-02-20 18:44:13, Cristopher Lameter wrote:
On Wed, 26 Feb 2020, Michal Hocko wrote:
quoted
Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.
Kmalloc_node does not support memory policies etc. Only kmalloc does.
kmalloc_node is mostly used by subsystems that have determined the active
nodes and want a targeted allocation on those nodes.
 
I am sorry but I have hard time to follow your responses here. They open
more questions than they answer for me. The primary point here is that
kmalloc_node on a memory less node blows up and panics the kernel. I
strongly believe this is a bug. We cannot really make all callers of
kmalloc_node and co. to be hotplug aware.

Another question is the semantic of kmalloc_node when the node cannot
satisfy the request. I have always thought that the allocation would
simply fall back to any other node unless __GFP_THISNODE is explicitly
specified.

-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: David Rientjes <rientjes@google.com>
Date: 2020-02-26 20:32:00

On Wed, 26 Feb 2020, Michal Hocko wrote:
On Wed 26-02-20 18:44:13, Cristopher Lameter wrote:
quoted
On Wed, 26 Feb 2020, Michal Hocko wrote:
quoted
Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.
Kmalloc_node does not support memory policies etc. Only kmalloc does.
kmalloc_node is mostly used by subsystems that have determined the active
nodes and want a targeted allocation on those nodes.
 
I am sorry but I have hard time to follow your responses here. They open
more questions than they answer for me. The primary point here is that
kmalloc_node on a memory less node blows up and panics the kernel. I
strongly believe this is a bug. We cannot really make all callers of
kmalloc_node and co. to be hotplug aware.

Another question is the semantic of kmalloc_node when the node cannot
satisfy the request. I have always thought that the allocation would
simply fall back to any other node unless __GFP_THISNODE is explicitly
specified.
Am I right in classifying this as a trade-off between an 
unlikely(!node_state(nid, N_MEMORY)) directly in kmalloc_node() vs fixing 
up a caller passing a memoryless nid?

Seems like we wouldn't want to penalize kmalloc_node() for making such a 
check for 99.99% of allocators that don't need it and would rather do a 
node_to_mem_node(nid) or numa_mem_id() in the caller?

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-26 20:52:20

On Wed 26-02-20 12:31:56, David Rientjes wrote:
On Wed, 26 Feb 2020, Michal Hocko wrote:
quoted
On Wed 26-02-20 18:44:13, Cristopher Lameter wrote:
quoted
On Wed, 26 Feb 2020, Michal Hocko wrote:
quoted
Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.
Kmalloc_node does not support memory policies etc. Only kmalloc does.
kmalloc_node is mostly used by subsystems that have determined the active
nodes and want a targeted allocation on those nodes.
 
I am sorry but I have hard time to follow your responses here. They open
more questions than they answer for me. The primary point here is that
kmalloc_node on a memory less node blows up and panics the kernel. I
strongly believe this is a bug. We cannot really make all callers of
kmalloc_node and co. to be hotplug aware.

Another question is the semantic of kmalloc_node when the node cannot
satisfy the request. I have always thought that the allocation would
simply fall back to any other node unless __GFP_THISNODE is explicitly
specified.
Am I right in classifying this as a trade-off between an 
unlikely(!node_state(nid, N_MEMORY)) directly in kmalloc_node() vs fixing 
up a caller passing a memoryless nid?
The thing is that any check for node online/populated followed by the
allocation is inherently racy without using memory hotplug locking
around that and I am pretty sure this is a step into a wrong direction.

Is there any problem to initialize slub internal data structures for all
possible nodes? This wouldn't require any checks into hot paths.

-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Vlastimil Babka <hidden>
Date: 2020-02-26 21:46:00

On 2/26/20 7:41 PM, Michal Hocko wrote:
On Wed 26-02-20 18:25:28, Cristopher Lameter wrote:
quoted
On Mon, 24 Feb 2020, Michal Hocko wrote:
quoted
Hmm, nasty. Is there any reason why kmalloc_node behaves differently
from the page allocator?
The page allocator will do the same thing if you pass GFP_THISNODE and
insist on allocating memory from a node that does not exist.
I do not think that the page allocator would blow up even with
GFP_THISNODE. The allocation would just fail on memory less node.

Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.
Seems like SLAB at least behaves like the page allocator. See
____cache_alloc_node() where it basically does:

page = cache_grow_begin(cachep, gfp_exact_node(flags), nodeid);
...
if (!page)
	fallback_alloc(cachep, flags)

gfp_exact_node() adds __GFP_THISNODE among other things, so the initial
attempt does try to stick only to the given node. But fallback_alloc()
doesn't. In fact, even if kmalloc_node() was called with __GFP_THISNODE
then it wouldn't work as intended, as fallback_alloc() doesn't get the
nodeid, but instead will use numa_mem_id(). That part could probably be
improved.

SLUB's ___slab_alloc() has for example this:
if (node != NUMA_NO_NODE && !node_present_pages(node))
    searchnode = node_to_mem_node(node);

That's from Joonsoo's 2014 commit a561ce00b09e ("slub: fall back to
node_to_mem_node() node if allocating on memoryless node"), suggesting
that the scenario in this bug report should work. Perhaps it just got
broken unintentionally later.

And AFAICS the whole path leading to alloc_slab_page() also doesn't add
__GFP_THISNODE, but will keep it if caller passed it, and ultimately it
does:


if (node == NUMA_NO_NODE)
    page = alloc_pages(flags, order);
else
    page = __alloc_pages_node(node, flags, order);

So yeah looks like SLUB's kmalloc_node() is supposed to behave like the
page allocator's __alloc_pages_node() and respect __GFP_THISNODE but not
enforce it by itself. There's probably just some missing data structure
initialization somewhere right now for memoryless nodes.

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Vlastimil Babka <hidden>
Date: 2020-02-26 22:29:33

On 2/26/20 10:45 PM, Vlastimil Babka wrote:

if (node == NUMA_NO_NODE)
    page = alloc_pages(flags, order);
else
    page = __alloc_pages_node(node, flags, order);

So yeah looks like SLUB's kmalloc_node() is supposed to behave like the
page allocator's __alloc_pages_node() and respect __GFP_THISNODE but not
enforce it by itself. There's probably just some missing data structure
initialization somewhere right now for memoryless nodes.
Upon more digging, I think the problem could manifest if
node_to_mem_node(0) (_node_numa_mem_[0]) returned 0 instead of 1,
because it wasn't initialized properly for a memoryless node. Can you
e.g. print it somewhere?

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-27 12:03:04

On Wed 26-02-20 22:45:52, Vlastimil Babka wrote:
On 2/26/20 7:41 PM, Michal Hocko wrote:
quoted
On Wed 26-02-20 18:25:28, Cristopher Lameter wrote:
quoted
On Mon, 24 Feb 2020, Michal Hocko wrote:
quoted
Hmm, nasty. Is there any reason why kmalloc_node behaves differently
from the page allocator?
The page allocator will do the same thing if you pass GFP_THISNODE and
insist on allocating memory from a node that does not exist.
I do not think that the page allocator would blow up even with
GFP_THISNODE. The allocation would just fail on memory less node.

Besides that kmalloc_node shouldn't really have an implicit GFP_THISNODE
semantic right? At least I do not see anything like that documented
anywhere.
Seems like SLAB at least behaves like the page allocator. See
____cache_alloc_node() where it basically does:

page = cache_grow_begin(cachep, gfp_exact_node(flags), nodeid);
...
if (!page)
	fallback_alloc(cachep, flags)

gfp_exact_node() adds __GFP_THISNODE among other things, so the initial
attempt does try to stick only to the given node. But fallback_alloc()
doesn't. In fact, even if kmalloc_node() was called with __GFP_THISNODE
then it wouldn't work as intended, as fallback_alloc() doesn't get the
nodeid, but instead will use numa_mem_id(). That part could probably be
improved.

SLUB's ___slab_alloc() has for example this:
if (node != NUMA_NO_NODE && !node_present_pages(node))
Hmm, just a quick note. Shouldn't this be node_managed_pages? In most
cases the difference is negligible but I can imagine crazy setups where
all present pages are simply consumed.
    searchnode = node_to_mem_node(node);

That's from Joonsoo's 2014 commit a561ce00b09e ("slub: fall back to
node_to_mem_node() node if allocating on memoryless node"), suggesting
that the scenario in this bug report should work. Perhaps it just got
broken unintentionally later.
A very good reference. Thanks!
And AFAICS the whole path leading to alloc_slab_page() also doesn't add
__GFP_THISNODE, but will keep it if caller passed it, and ultimately it
does:


if (node == NUMA_NO_NODE)
    page = alloc_pages(flags, order);
else
    page = __alloc_pages_node(node, flags, order);

So yeah looks like SLUB's kmalloc_node() is supposed to behave like the
page allocator's __alloc_pages_node() and respect __GFP_THISNODE but not
enforce it by itself. There's probably just some missing data structure
initialization somewhere right now for memoryless nodes.
Thanks for the confirmation!
-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-27 12:12:18

On Wed 26-02-20 23:29:24, Vlastimil Babka wrote:
On 2/26/20 10:45 PM, Vlastimil Babka wrote:
quoted

if (node == NUMA_NO_NODE)
    page = alloc_pages(flags, order);
else
    page = __alloc_pages_node(node, flags, order);

So yeah looks like SLUB's kmalloc_node() is supposed to behave like the
page allocator's __alloc_pages_node() and respect __GFP_THISNODE but not
enforce it by itself. There's probably just some missing data structure
initialization somewhere right now for memoryless nodes.
Upon more digging, I think the problem could manifest if
node_to_mem_node(0) (_node_numa_mem_[0]) returned 0 instead of 1,
because it wasn't initialized properly for a memoryless node. Can you
e.g. print it somewhere?
A very good hint indeed. I would do this
diff --git a/include/linux/topology.h b/include/linux/topology.h
index eb2fe6edd73c..d9f1b6737e4d 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -137,6 +137,8 @@ static inline void set_numa_mem(int node)
 {
 	this_cpu_write(_numa_mem_, node);
 	_node_numa_mem_[numa_node_id()] = node;
+	pr_info("%s %d -> %d\n", __FUNCTION__, numa_node_id(), node);
+	dump_stack();
 }
 #endif
 
Btw. it would be also helpful to get
`faddr2line ___slab_alloc+0x334' from your kernel Sachin.
-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-02-27 16:01:21

quoted hunk
On 27-Feb-2020, at 5:42 PM, Michal Hocko [off-list ref] wrote:

A very good hint indeed. I would do this
diff --git a/include/linux/topology.h b/include/linux/topology.h
index eb2fe6edd73c..d9f1b6737e4d 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -137,6 +137,8 @@ static inline void set_numa_mem(int node)
{
	this_cpu_write(_numa_mem_, node);
	_node_numa_mem_[numa_node_id()] = node;
+	pr_info("%s %d -> %d\n", __FUNCTION__, numa_node_id(), node);
+	dump_stack();
}
#endif

Btw. it would be also helpful to get
`faddr2line ___slab_alloc+0x334' from your kernel Sachin.
[linux-next]# ./scripts/faddr2line ./vmlinux ___slab_alloc+0x334 
___slab_alloc+0x334/0x760:
new_slab_objects at mm/slub.c:2478
(inlined by) ___slab_alloc at mm/slub.c:2628
[linux-next]# 

I have also attached boot log with a kernel that include about change.
I see the following o/p during boot:

[    0.005269] set_numa_mem 1 -> 1
[    0.005270] CPU: 12 PID: 0 Comm: swapper/12 Not tainted 5.6.0-rc3-next-20200227-autotest+ #6
[    0.005271] Call Trace:
[    0.005272] [c0000008b37dfe80] [c000000000b5d948] dump_stack+0xbc/0x104 (unreliable)
[    0.005274] [c0000008b37dfec0] [c000000000059320] start_secondary+0x600/0x6e0
[    0.005277] [c0000008b37dff90] [c00000000000ac54] start_secondary_prolog+0x10/0x14

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Vlastimil Babka <hidden>
Date: 2020-02-27 16:16:46

On 2/27/20 5:00 PM, Sachin Sant wrote:
quoted
On 27-Feb-2020, at 5:42 PM, Michal Hocko [off-list ref] wrote:

A very good hint indeed. I would do this
diff --git a/include/linux/topology.h b/include/linux/topology.h
index eb2fe6edd73c..d9f1b6737e4d 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -137,6 +137,8 @@ static inline void set_numa_mem(int node)
{
	this_cpu_write(_numa_mem_, node);
	_node_numa_mem_[numa_node_id()] = node;
+	pr_info("%s %d -> %d\n", __FUNCTION__, numa_node_id(), node);
+	dump_stack();
}
#endif

Btw. it would be also helpful to get
`faddr2line ___slab_alloc+0x334' from your kernel Sachin.
[linux-next]# ./scripts/faddr2line ./vmlinux ___slab_alloc+0x334 
___slab_alloc+0x334/0x760:
new_slab_objects at mm/slub.c:2478
(inlined by) ___slab_alloc at mm/slub.c:2628
[linux-next]# 
Hmm that doesn't look relevant, but that address was marked as unreliable, no?
Don't we actually need this one?

[    8.768727] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
I have also attached boot log with a kernel that include about change.
I see the following o/p during boot:

[    0.005269] set_numa_mem 1 -> 1
So there's no "set_numa_mem 0 -> X", specifically not
"set_numa_mem 0 -> 1" which I would have expected. That seems to confirm my
suspicion that the arch code doesn't set up the memoryless node 0 properly.
[    0.005270] CPU: 12 PID: 0 Comm: swapper/12 Not tainted 5.6.0-rc3-next-20200227-autotest+ #6
[    0.005271] Call Trace:
[    0.005272] [c0000008b37dfe80] [c000000000b5d948] dump_stack+0xbc/0x104 (unreliable)
[    0.005274] [c0000008b37dfec0] [c000000000059320] start_secondary+0x600/0x6e0
[    0.005277] [c0000008b37dff90] [c00000000000ac54] start_secondary_prolog+0x10/0x14

Thanks
-Sachin

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-02-27 18:26:56

[Cc ppc maintainers]
On Thu 27-02-20 17:16:41, Vlastimil Babka wrote:
On 2/27/20 5:00 PM, Sachin Sant wrote:
quoted
quoted
On 27-Feb-2020, at 5:42 PM, Michal Hocko [off-list ref] wrote:

A very good hint indeed. I would do this
diff --git a/include/linux/topology.h b/include/linux/topology.h
index eb2fe6edd73c..d9f1b6737e4d 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -137,6 +137,8 @@ static inline void set_numa_mem(int node)
{
	this_cpu_write(_numa_mem_, node);
	_node_numa_mem_[numa_node_id()] = node;
+	pr_info("%s %d -> %d\n", __FUNCTION__, numa_node_id(), node);
+	dump_stack();
}
#endif

Btw. it would be also helpful to get
`faddr2line ___slab_alloc+0x334' from your kernel Sachin.
[linux-next]# ./scripts/faddr2line ./vmlinux ___slab_alloc+0x334 
___slab_alloc+0x334/0x760:
new_slab_objects at mm/slub.c:2478
(inlined by) ___slab_alloc at mm/slub.c:2628
[linux-next]# 
Hmm that doesn't look relevant, but that address was marked as unreliable, no?
Don't we actually need this one?

[    8.768727] NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
quoted
I have also attached boot log with a kernel that include about change.
I see the following o/p during boot:

[    0.005269] set_numa_mem 1 -> 1
So there's no "set_numa_mem 0 -> X", specifically not
"set_numa_mem 0 -> 1" which I would have expected. That seems to confirm my
suspicion that the arch code doesn't set up the memoryless node 0 properly.
Please have a look at http://lkml.kernel.org/r/52EF4673-7292-4C4C-B459-AF583951BA48@linux.vnet.ibm.com
for the boot log with the debugging patch which tracks set_numa_mem.
This seems to lead to a crash in the slab allocator bebcause
node_to_mem_node(0) for memory less node resolves to the memory less
node http://lkml.kernel.org/r/dd450314-d428-6776-af07-f92c04c7b967@suse.cz.
The original report is http://lkml.kernel.org/r/3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com
quoted
[    0.005270] CPU: 12 PID: 0 Comm: swapper/12 Not tainted 5.6.0-rc3-next-20200227-autotest+ #6
[    0.005271] Call Trace:
[    0.005272] [c0000008b37dfe80] [c000000000b5d948] dump_stack+0xbc/0x104 (unreliable)
[    0.005274] [c0000008b37dfec0] [c000000000059320] start_secondary+0x600/0x6e0
[    0.005277] [c0000008b37dff90] [c00000000000ac54] start_secondary_prolog+0x10/0x14

Thanks
-Sachin
-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michal Hocko <mhocko@kernel.org>
Date: 2020-03-10 15:01:24

On Thu 27-02-20 19:26:54, Michal Hocko wrote:
[Cc ppc maintainers]
[...]
Please have a look at http://lkml.kernel.org/r/52EF4673-7292-4C4C-B459-AF583951BA48@linux.vnet.ibm.com
for the boot log with the debugging patch which tracks set_numa_mem.
This seems to lead to a crash in the slab allocator bebcause
node_to_mem_node(0) for memory less node resolves to the memory less
node http://lkml.kernel.org/r/dd450314-d428-6776-af07-f92c04c7b967@suse.cz.
The original report is http://lkml.kernel.org/r/3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com
ping 
-- 
Michal Hocko
SUSE Labs

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2020-03-12 12:18:55

Michal Hocko [off-list ref] writes:
On Thu 27-02-20 19:26:54, Michal Hocko wrote:
quoted
[Cc ppc maintainers]
[...]
quoted
Please have a look at http://lkml.kernel.org/r/52EF4673-7292-4C4C-B459-AF583951BA48@linux.vnet.ibm.com
for the boot log with the debugging patch which tracks set_numa_mem.
This seems to lead to a crash in the slab allocator bebcause
node_to_mem_node(0) for memory less node resolves to the memory less
node http://lkml.kernel.org/r/dd450314-d428-6776-af07-f92c04c7b967@suse.cz.
The original report is http://lkml.kernel.org/r/3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com
ping 
The obvious fix is:
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 37c12e3bab9e..33b1fca0b258 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -892,6 +892,7 @@ void smp_prepare_boot_cpu(void)
 	paca_ptrs[boot_cpuid]->__current = current;
 #endif
 	set_numa_node(numa_cpu_lookup_table[boot_cpuid]);
+	set_numa_mem(local_memory_node(numa_cpu_lookup_table[boot_cpuid]));
 	current_set[boot_cpuid] = current;
 }

But that doesn't work because smp_prepare_boot_cpu() is called too
early:

asmlinkage __visible void __init start_kernel(void)
{
	...
	smp_prepare_boot_cpu();	/* arch-specific boot-cpu hooks */
	boot_cpu_hotplug_init();

	build_all_zonelists(NULL);


And local_memory_node() uses first_zones_zonelist() which doesn't work
prior to build_all_zonelists() being called.


The patch below might work. Sachin can you test this? I tried faking up
a system with a memoryless node zero but couldn't get it to even start
booting.

cheers

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 9b4f5fb719e0..d1f11437f6c4 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -282,6 +282,9 @@ void __init mem_init(void)
 	 */
 	BUILD_BUG_ON(MMU_PAGE_COUNT > 16);
 
+	BUG_ON(smp_processor_id() != boot_cpuid);
+	set_numa_mem(local_memory_node(numa_cpu_lookup_table[boot_cpuid]));
+
 #ifdef CONFIG_SWIOTLB
 	/*
 	 * Some platforms (e.g. 85xx) limit DMA-able memory way below

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-03-12 16:56:41

The patch below might work. Sachin can you test this? I tried faking up
a system with a memoryless node zero but couldn't get it to even start
booting.
The patch did not help. The kernel crashed during
the boot with the same call trace.

BUG_ON() introduced with the patch was not triggered.

Thanks
-Sachin
quoted hunk
cheers

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 9b4f5fb719e0..d1f11437f6c4 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -282,6 +282,9 @@ void __init mem_init(void)
	 */
	BUILD_BUG_ON(MMU_PAGE_COUNT > 16);

+	BUG_ON(smp_processor_id() != boot_cpuid);
+	set_numa_mem(local_memory_node(numa_cpu_lookup_table[boot_cpuid]));
+
#ifdef CONFIG_SWIOTLB
	/*
	 * Some platforms (e.g. 85xx) limit DMA-able memory way below

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2020-03-13 10:48:11

Sachin Sant [off-list ref] writes:
quoted
The patch below might work. Sachin can you test this? I tried faking up
a system with a memoryless node zero but couldn't get it to even start
booting.
The patch did not help. The kernel crashed during
the boot with the same call trace.

BUG_ON() introduced with the patch was not triggered.
OK, that's weird.

I eventually managed to get a memoryless node going in sim, and it
appears to work there.

eg in dmesg:

  [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fffa2f80-0x2000fffa7fff]
  [    0.000000][    T0] numa:     NODE_DATA(0) on node 1
  [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fff9df00-0x2000fffa2f7f]
  ...
  [    0.000000][    T0] Early memory node ranges
  [    0.000000][    T0]   node   1: [mem 0x0000000000000000-0x00000000ffffffff]
  [    0.000000][    T0]   node   1: [mem 0x0000200000000000-0x00002000ffffffff]
  [    0.000000][    T0] Could not find start_pfn for node 0
  [    0.000000][    T0] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000000000]
  [    0.000000][    T0] On node 0 totalpages: 0
  [    0.000000][    T0] Initmem setup node 1 [mem 0x0000000000000000-0x00002000ffffffff]
  [    0.000000][    T0] On node 1 totalpages: 131072
  
  # dmesg | grep set_numa
  [    0.000000][    T0] set_numa_mem: mem node for 0 = 1
  [    0.005654][    T0] set_numa_mem: mem node for 1 = 1

So is the problem more than just node zero having no memory?

cheers

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Srikar Dronamraju <hidden>
Date: 2020-03-13 11:12:58

* Michael Ellerman [off-list ref] [2020-03-13 21:48:06]:
Sachin Sant [off-list ref] writes:
quoted
quoted
The patch below might work. Sachin can you test this? I tried faking up
a system with a memoryless node zero but couldn't get it to even start
booting.
The patch did not help. The kernel crashed during
the boot with the same call trace.

BUG_ON() introduced with the patch was not triggered.
OK, that's weird.

I eventually managed to get a memoryless node going in sim, and it
appears to work there.

eg in dmesg:

  [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fffa2f80-0x2000fffa7fff]
  [    0.000000][    T0] numa:     NODE_DATA(0) on node 1
  [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fff9df00-0x2000fffa2f7f]
  ...
  [    0.000000][    T0] Early memory node ranges
  [    0.000000][    T0]   node   1: [mem 0x0000000000000000-0x00000000ffffffff]
  [    0.000000][    T0]   node   1: [mem 0x0000200000000000-0x00002000ffffffff]
  [    0.000000][    T0] Could not find start_pfn for node 0
  [    0.000000][    T0] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000000000]
  [    0.000000][    T0] On node 0 totalpages: 0
  [    0.000000][    T0] Initmem setup node 1 [mem 0x0000000000000000-0x00002000ffffffff]
  [    0.000000][    T0] On node 1 totalpages: 131072
  
  # dmesg | grep set_numa
  [    0.000000][    T0] set_numa_mem: mem node for 0 = 1
  [    0.005654][    T0] set_numa_mem: mem node for 1 = 1

So is the problem more than just node zero having no memory?
The problem would happen with possible nodes which are not yet present. i.e
no cpus, no memory attached to those nodes.

Please look at
http://lore.kernel.org/lkml/20200312131438.GB3277@linux.vnet.ibm.com/t/#u
for more details.

The summary being: pgdat/Node_Data for such nodes is not allocated. Hence
the node_present_pages(nid) called  where nid is a possible but not yet
present node fails. Currently node_present_pages(nid) and node_to_mem_node
don't seem to be equipped to handle possible but not present nodes.
cheers
-- 
Thanks and Regards
Srikar Dronamraju

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Vlastimil Babka <hidden>
Date: 2020-03-13 11:35:39

On 3/13/20 12:12 PM, Srikar Dronamraju wrote:
* Michael Ellerman [off-list ref] [2020-03-13 21:48:06]:
quoted
Sachin Sant [off-list ref] writes:
quoted
quoted
The patch below might work. Sachin can you test this? I tried faking up
a system with a memoryless node zero but couldn't get it to even start
booting.
The patch did not help. The kernel crashed during
the boot with the same call trace.

BUG_ON() introduced with the patch was not triggered.
OK, that's weird.

I eventually managed to get a memoryless node going in sim, and it
appears to work there.

eg in dmesg:

  [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fffa2f80-0x2000fffa7fff]
  [    0.000000][    T0] numa:     NODE_DATA(0) on node 1
  [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fff9df00-0x2000fffa2f7f]
  ...
  [    0.000000][    T0] Early memory node ranges
  [    0.000000][    T0]   node   1: [mem 0x0000000000000000-0x00000000ffffffff]
  [    0.000000][    T0]   node   1: [mem 0x0000200000000000-0x00002000ffffffff]
  [    0.000000][    T0] Could not find start_pfn for node 0
  [    0.000000][    T0] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000000000]
  [    0.000000][    T0] On node 0 totalpages: 0
  [    0.000000][    T0] Initmem setup node 1 [mem 0x0000000000000000-0x00002000ffffffff]
  [    0.000000][    T0] On node 1 totalpages: 131072
  
  # dmesg | grep set_numa
  [    0.000000][    T0] set_numa_mem: mem node for 0 = 1
  [    0.005654][    T0] set_numa_mem: mem node for 1 = 1

So is the problem more than just node zero having no memory?
The problem would happen with possible nodes which are not yet present. i.e
no cpus, no memory attached to those nodes.

Please look at
http://lore.kernel.org/lkml/20200312131438.GB3277@linux.vnet.ibm.com/t/#u
for more details.

The summary being: pgdat/Node_Data for such nodes is not allocated. Hence
Michael's log shows that his pgdat is still allocated. But perhaps Sachin had
also your 3 patches from the other thread applied, in addition to Michael's
patch. So in his case pgdat for node 0 would indeed be no longer allocated, and
thus SLUB code was crashing in node_present_pages() instead.
the node_present_pages(nid) called  where nid is a possible but not yet
present node fails. Currently node_present_pages(nid) and node_to_mem_node
don't seem to be equipped to handle possible but not present nodes.
quoted
cheers

Re: [5.6.0-rc2-next-20200218/powerpc] Boot failure on POWER9

From: Sachin Sant <hidden>
Date: 2020-03-15 01:30:58

On 13-Mar-2020, at 5:05 PM, Vlastimil Babka [off-list ref] wrote:

On 3/13/20 12:12 PM, Srikar Dronamraju wrote:
quoted
* Michael Ellerman [off-list ref] [2020-03-13 21:48:06]:
quoted
Sachin Sant [off-list ref] writes:
quoted
quoted
The patch below might work. Sachin can you test this? I tried faking up
a system with a memoryless node zero but couldn't get it to even start
booting.
The patch did not help. The kernel crashed during
the boot with the same call trace.

BUG_ON() introduced with the patch was not triggered.
OK, that's weird.

I eventually managed to get a memoryless node going in sim, and it
appears to work there.

eg in dmesg:

 [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fffa2f80-0x2000fffa7fff]
 [    0.000000][    T0] numa:     NODE_DATA(0) on node 1
 [    0.000000][    T0] numa:   NODE_DATA [mem 0x2000fff9df00-0x2000fffa2f7f]
 ...
 [    0.000000][    T0] Early memory node ranges
 [    0.000000][    T0]   node   1: [mem 0x0000000000000000-0x00000000ffffffff]
 [    0.000000][    T0]   node   1: [mem 0x0000200000000000-0x00002000ffffffff]
 [    0.000000][    T0] Could not find start_pfn for node 0
 [    0.000000][    T0] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000000000]
 [    0.000000][    T0] On node 0 totalpages: 0
 [    0.000000][    T0] Initmem setup node 1 [mem 0x0000000000000000-0x00002000ffffffff]
 [    0.000000][    T0] On node 1 totalpages: 131072

 # dmesg | grep set_numa
 [    0.000000][    T0] set_numa_mem: mem node for 0 = 1
 [    0.005654][    T0] set_numa_mem: mem node for 1 = 1

So is the problem more than just node zero having no memory?
I tried with just the patch Michael suggested on top of March 13 next tree.
I still see the same failure. Here is a snippet from the log

[    0.000000] numa:   NODE_DATA [mem 0x8bfedc900-0x8bfee3fff]
[    0.000000] numa:     NODE_DATA(0) on node 1
[    0.000000] numa:   NODE_DATA [mem 0x8bfed5200-0x8bfedc8ff]
[    0.000000] rfi-flush: fallback displacement flush available
[    0.000000] rfi-flush: mttrig type flush available
[    0.000000] link-stack-flush: software flush enabled.
[    0.000000] count-cache-flush: software flush disabled.
[    0.000000] stf-barrier: eieio barrier available
[    0.000000] lpar: H_BLOCK_REMOVE supports base psize:0 psize:0 block size:8
[    0.000000] lpar: H_BLOCK_REMOVE supports base psize:0 psize:2 block size:8
[    0.000000] lpar: H_BLOCK_REMOVE supports base psize:0 psize:10 block size:8
[    0.000000] lpar: H_BLOCK_REMOVE supports base psize:2 psize:2 block size:8
[    0.000000] lpar: H_BLOCK_REMOVE supports base psize:2 psize:10 block size:8
[    0.000000] PPC64 nvram contains 15360 bytes
[    0.000000] barrier-nospec: using ORI speculation barrier
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x00000008bfffffff]
[    0.000000]   Device   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   1: [mem 0x0000000000000000-0x00000008bfffffff]
[    0.000000] Could not find start_pfn for node 0
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000000000000]
[    0.000000] Initmem setup node 1 [mem 0x0000000000000000-0x00000008bfffffff]
[    0.000000] percpu: Embedded 11 pages/cpu s624024 r0 d96872 u1048576
[    0.000000] Built 2 zonelists, mobility grouping on.  Total pages: 572880

Have attached the complete boot log.

Thanks
-Sachin

[PATCH 0/4] Fix kmalloc_node on offline nodes

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:20:45

Sachin recently reported that linux-next was no more bootable on few
systems.
https://lore.kernel.org/linux-next/3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com/

# numactl -H
available: 2 nodes (0-1)
node 0 cpus:
node 0 size: 0 MB
node 0 free: 0 MB
node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
node 1 size: 35247 MB
node 1 free: 30907 MB
node distances:
node   0   1
  0:  10  40
  1:  40  10
#

Sachin bisected the problem to Commit a75056fc1e7c ("mm/memcontrol.c: allocate
shrinker_map on appropriate NUMA node")

The root cause analysis showed that mm/slub and powerpc/numa had some shortcomings
with respect to offline nodes.

This patch series is on top of patches posted at
https://lore.kernel.org/linuxppc-dev/20200311110237.5731-1-srikar@linux.vnet.ibm.com/t/#u

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sachin Sant <redacted>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Christopher Lameter <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Joonsoo Kim <redacted>
Cc: Kirill Tkhai <redacted>
Cc: Vlastimil Babka <redacted>
Cc: Srikar Dronamraju <redacted>
Cc: Bharata B Rao <redacted>

Srikar Dronamraju (4):
  mm: Check for node_online in node_present_pages
  mm/slub: Use mem_node to allocate a new slab
  mm: Implement reset_numa_mem
  powerpc/numa: Set fallback nodes for offline nodes

 arch/powerpc/mm/numa.c         | 11 ++++++++++-
 include/asm-generic/topology.h |  3 +++
 include/linux/mmzone.h         |  6 ++++--
 include/linux/topology.h       |  7 +++++++
 mm/slub.c                      | 19 ++++++++-----------
 5 files changed, 32 insertions(+), 14 deletions(-)

--
2.18.1

[PATCH 1/4] mm: Check for node_online in node_present_pages

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:20:48

Calling a kmalloc_node on a possible node which is not yet onlined can
lead to panic. Currently node_present_pages() doesn't verify the node is
online before accessing the pgdat for the node. However pgdat struct may
not be available resulting in a crash.

NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760
LR [c0000000003d5b94] __slab_alloc+0x34/0x60
Call Trace:
[c0000008b3783960] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable)
[c0000008b3783a40] [c0000000003d5b94] __slab_alloc+0x34/0x60
[c0000008b3783a70] [c0000000003d6fa0] __kmalloc_node+0x110/0x490
[c0000008b3783af0] [c0000000003443d8] kvmalloc_node+0x58/0x110
[c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270
[c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0
[c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0
[c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0
[c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0
[c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230
[c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0
[c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68

Fix this by verifying the node is online before accessing the pgdat
structure. Fix the same for node_spanned_pages() too.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sachin Sant <redacted>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Christopher Lameter <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Joonsoo Kim <redacted>
Cc: Kirill Tkhai <redacted>
Cc: Vlastimil Babka <redacted>
Cc: Srikar Dronamraju <redacted>
Cc: Bharata B Rao <redacted>

Reported-by: Sachin Sant <redacted>
Tested-by: Sachin Sant <redacted>
Signed-off-by: Srikar Dronamraju <redacted>
---
 include/linux/mmzone.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f3f264826423..88078a3b95e5 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -756,8 +756,10 @@ typedef struct pglist_data {
 	atomic_long_t		vm_stat[NR_VM_NODE_STAT_ITEMS];
 } pg_data_t;
 
-#define node_present_pages(nid)	(NODE_DATA(nid)->node_present_pages)
-#define node_spanned_pages(nid)	(NODE_DATA(nid)->node_spanned_pages)
+#define node_present_pages(nid)		\
+	(node_online(nid) ? NODE_DATA(nid)->node_present_pages : 0)
+#define node_spanned_pages(nid)		\
+	(node_online(nid) ? NODE_DATA(nid)->node_spanned_pages : 0)
 #ifdef CONFIG_FLAT_NODE_MEM_MAP
 #define pgdat_page_nr(pgdat, pagenr)	((pgdat)->node_mem_map + (pagenr))
 #else
-- 
2.18.1

[PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:20:51

Currently while allocating a slab for a offline node, we use its
associated node_numa_mem to search for a partial slab. If we don't find
a partial slab, we try allocating a slab from the offline node using
__alloc_pages_node. However this is bound to fail.

NIP [c00000000039a300] __alloc_pages_nodemask+0x130/0x3b0
LR [c00000000039a3c4] __alloc_pages_nodemask+0x1f4/0x3b0
Call Trace:
[c0000008b36837f0] [c00000000039a3b4] __alloc_pages_nodemask+0x1e4/0x3b0 (unreliable)
[c0000008b3683870] [c0000000003d1ff8] new_slab+0x128/0xcf0
[c0000008b3683950] [c0000000003d6060] ___slab_alloc+0x410/0x820
[c0000008b3683a40] [c0000000003d64a4] __slab_alloc+0x34/0x60
[c0000008b3683a70] [c0000000003d78b0] __kmalloc_node+0x110/0x490
[c0000008b3683af0] [c000000000343a08] kvmalloc_node+0x58/0x110
[c0000008b3683b30] [c0000000003ffd44] mem_cgroup_css_online+0x104/0x270
[c0000008b3683b90] [c000000000234e08] online_css+0x48/0xd0
[c0000008b3683bc0] [c00000000023dedc] cgroup_apply_control_enable+0x2ec/0x4d0
[c0000008b3683ca0] [c0000000002416f8] cgroup_mkdir+0x228/0x5f0
[c0000008b3683d10] [c000000000520360] kernfs_iop_mkdir+0x90/0xf0
[c0000008b3683d50] [c00000000043e400] vfs_mkdir+0x110/0x230
[c0000008b3683da0] [c000000000441ee0] do_mkdirat+0xb0/0x1a0
[c0000008b3683e20] [c00000000000b278] system_call+0x5c/0x68

Mitigate this by allocating the new slab from the node_numa_mem.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sachin Sant <redacted>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Christopher Lameter <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Joonsoo Kim <redacted>
Cc: Kirill Tkhai <redacted>
Cc: Vlastimil Babka <redacted>
Cc: Srikar Dronamraju <redacted>
Cc: Bharata B Rao <redacted>

Reported-by: Sachin Sant <redacted>
Tested-by: Sachin Sant <redacted>
Signed-off-by: Srikar Dronamraju <redacted>
---
 mm/slub.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 1c55bf7892bf..fdf7f38f96e6 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1970,14 +1970,8 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
 		struct kmem_cache_cpu *c)
 {
 	void *object;
-	int searchnode = node;
 
-	if (node == NUMA_NO_NODE)
-		searchnode = numa_mem_id();
-	else if (!node_present_pages(node))
-		searchnode = node_to_mem_node(node);
-
-	object = get_partial_node(s, get_node(s, searchnode), c, flags);
+	object = get_partial_node(s, get_node(s, node), c, flags);
 	if (object || node != NUMA_NO_NODE)
 		return object;
 
@@ -2470,6 +2464,11 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
 
 	WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));
 
+	if (node == NUMA_NO_NODE)
+		node = numa_mem_id();
+	else if (!node_present_pages(node))
+		node = node_to_mem_node(node);
+
 	freelist = get_partial(s, flags, node, c);
 
 	if (freelist)
@@ -2569,12 +2568,10 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
 redo:
 
 	if (unlikely(!node_match(page, node))) {
-		int searchnode = node;
-
 		if (node != NUMA_NO_NODE && !node_present_pages(node))
-			searchnode = node_to_mem_node(node);
+			node = node_to_mem_node(node);
 
-		if (unlikely(!node_match(page, searchnode))) {
+		if (unlikely(!node_match(page, node))) {
 			stat(s, ALLOC_NODE_MISMATCH);
 			deactivate_slab(s, page, c->freelist, c);
 			goto new_slab;
-- 
2.18.1

[PATCH 3/4] mm: Implement reset_numa_mem

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:20:55

For a memoryless or offline nodes, node_numa_mem refers to a N_MEMORY
fallback node. Currently kernel has an API set_numa_mem that sets
node_numa_mem for memoryless node. However this API cannot be used for
offline nodes. Hence all offline nodes will have their node_numa_mem set
to 0. However systems can themselves have node 0 as offline i.e
memoryless and cpuless at this time. In such cases,
node_to_mem_node() fails to provide a N_MEMORY fallback node.

Mitigate this by having a new API that sets the default node_numa_mem for
offline nodes to be first_memory_node.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sachin Sant <redacted>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Christopher Lameter <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Joonsoo Kim <redacted>
Cc: Kirill Tkhai <redacted>
Cc: Vlastimil Babka <redacted>
Cc: Srikar Dronamraju <redacted>
Cc: Bharata B Rao <redacted>

Reported-by: Sachin Sant <redacted>
Tested-by: Sachin Sant <redacted>
Signed-off-by: Srikar Dronamraju <redacted>
---
 include/asm-generic/topology.h | 3 +++
 include/linux/topology.h       | 7 +++++++
 2 files changed, 10 insertions(+)
diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index 238873739550..e803ee7850e6 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -68,6 +68,9 @@
 #ifndef set_numa_mem
 #define set_numa_mem(node)
 #endif
+#ifndef reset_numa_mem
+#define reset_numa_mem(node)
+#endif
 #ifndef set_cpu_numa_mem
 #define set_cpu_numa_mem(cpu, node)
 #endif
diff --git a/include/linux/topology.h b/include/linux/topology.h
index eb2fe6edd73c..bebda80038bf 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -147,6 +147,13 @@ static inline int node_to_mem_node(int node)
 }
 #endif
 
+#ifndef reset_numa_mem
+static inline void reset_numa_mem(int node)
+{
+	_node_numa_mem_[node] = first_memory_node;
+}
+#endif
+
 #ifndef numa_mem_id
 /* Returns the number of the nearest Node with memory */
 static inline int numa_mem_id(void)
-- 
2.18.1

[PATCH 4/4] powerpc/numa: Set fallback nodes for offline nodes

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:23:33

Currently fallback nodes for offline nodes aren't set. Hence by default
node 0 ends up being the default node. However node 0 might be offline.

Fix this by explicitly setting fallback node. Ensure first_memory_node
is set before kernel does explicit setting of fallback node.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sachin Sant <redacted>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Christopher Lameter <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Joonsoo Kim <redacted>
Cc: Kirill Tkhai <redacted>
Cc: Vlastimil Babka <redacted>
Cc: Srikar Dronamraju <redacted>
Cc: Bharata B Rao <redacted>

Reported-by: Sachin Sant <redacted>
Tested-by: Sachin Sant <redacted>
Signed-off-by: Srikar Dronamraju <redacted>
---
 arch/powerpc/mm/numa.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 281531340230..6e97ab6575cb 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -827,7 +827,16 @@ void __init dump_numa_cpu_topology(void)
 	if (!numa_enabled)
 		return;
 
-	for_each_online_node(node) {
+	for_each_node(node) {
+		/*
+		 * For all possible but not yet online nodes, ensure their
+		 * node_numa_mem is set correctly so that kmalloc_node works
+		 * for such nodes.
+		 */
+		if (!node_online(node)) {
+			reset_numa_mem(node);
+			continue;
+		}
 		pr_info("Node %d CPUs:", node);
 
 		count = 0;
-- 
2.18.1

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Vlastimil Babka <hidden>
Date: 2020-03-17 13:34:30

On 3/17/20 2:17 PM, Srikar Dronamraju wrote:
Currently while allocating a slab for a offline node, we use its
associated node_numa_mem to search for a partial slab. If we don't find
a partial slab, we try allocating a slab from the offline node using
__alloc_pages_node. However this is bound to fail.

NIP [c00000000039a300] __alloc_pages_nodemask+0x130/0x3b0
LR [c00000000039a3c4] __alloc_pages_nodemask+0x1f4/0x3b0
Call Trace:
[c0000008b36837f0] [c00000000039a3b4] __alloc_pages_nodemask+0x1e4/0x3b0 (unreliable)
[c0000008b3683870] [c0000000003d1ff8] new_slab+0x128/0xcf0
[c0000008b3683950] [c0000000003d6060] ___slab_alloc+0x410/0x820
[c0000008b3683a40] [c0000000003d64a4] __slab_alloc+0x34/0x60
[c0000008b3683a70] [c0000000003d78b0] __kmalloc_node+0x110/0x490
[c0000008b3683af0] [c000000000343a08] kvmalloc_node+0x58/0x110
[c0000008b3683b30] [c0000000003ffd44] mem_cgroup_css_online+0x104/0x270
[c0000008b3683b90] [c000000000234e08] online_css+0x48/0xd0
[c0000008b3683bc0] [c00000000023dedc] cgroup_apply_control_enable+0x2ec/0x4d0
[c0000008b3683ca0] [c0000000002416f8] cgroup_mkdir+0x228/0x5f0
[c0000008b3683d10] [c000000000520360] kernfs_iop_mkdir+0x90/0xf0
[c0000008b3683d50] [c00000000043e400] vfs_mkdir+0x110/0x230
[c0000008b3683da0] [c000000000441ee0] do_mkdirat+0xb0/0x1a0
[c0000008b3683e20] [c00000000000b278] system_call+0x5c/0x68

Mitigate this by allocating the new slab from the node_numa_mem.
Are you sure this is really needed and the other 3 patches are not enough for
the current SLUB code to work as needed? It seems you are changing the semantics
here...
quoted hunk
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1970,14 +1970,8 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
 		struct kmem_cache_cpu *c)
 {
 	void *object;
-	int searchnode = node;
 
-	if (node == NUMA_NO_NODE)
-		searchnode = numa_mem_id();
-	else if (!node_present_pages(node))
-		searchnode = node_to_mem_node(node);
-
-	object = get_partial_node(s, get_node(s, searchnode), c, flags);
+	object = get_partial_node(s, get_node(s, node), c, flags);
 	if (object || node != NUMA_NO_NODE)>  		return object;

      return get_any_partial(s, flags, c);
I.e. here in this if(), now node will never equal NUMA_NO_NODE (thanks to the
hunk below), thus the get_any_partial() call becomes dead code?
quoted hunk
@@ -2470,6 +2464,11 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
 
 	WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));
 
+	if (node == NUMA_NO_NODE)
+		node = numa_mem_id();
+	else if (!node_present_pages(node))
+		node = node_to_mem_node(node);
+
 	freelist = get_partial(s, flags, node, c);
 
 	if (freelist)
@@ -2569,12 +2568,10 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
 redo:
 
 	if (unlikely(!node_match(page, node))) {
-		int searchnode = node;
-
 		if (node != NUMA_NO_NODE && !node_present_pages(node))
-			searchnode = node_to_mem_node(node);
+			node = node_to_mem_node(node);
 
-		if (unlikely(!node_match(page, searchnode))) {
+		if (unlikely(!node_match(page, node))) {
 			stat(s, ALLOC_NODE_MISMATCH);
 			deactivate_slab(s, page, c->freelist, c);
 			goto new_slab;

Re: [PATCH 1/4] mm: Check for node_online in node_present_pages

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:37:14

* Srikar Dronamraju [off-list ref] [2020-03-17 18:47:50]:
quoted hunk
Reported-by: Sachin Sant <redacted>
Tested-by: Sachin Sant <redacted>
Signed-off-by: Srikar Dronamraju <redacted>
---
 include/linux/mmzone.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f3f264826423..88078a3b95e5 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -756,8 +756,10 @@ typedef struct pglist_data {
 	atomic_long_t		vm_stat[NR_VM_NODE_STAT_ITEMS];
 } pg_data_t;

-#define node_present_pages(nid)	(NODE_DATA(nid)->node_present_pages)
-#define node_spanned_pages(nid)	(NODE_DATA(nid)->node_spanned_pages)
+#define node_present_pages(nid)		\
+	(node_online(nid) ? NODE_DATA(nid)->node_present_pages : 0)
+#define node_spanned_pages(nid)		\
+	(node_online(nid) ? NODE_DATA(nid)->node_spanned_pages : 0)
 #ifdef CONFIG_FLAT_NODE_MEM_MAP
 #define pgdat_page_nr(pgdat, pagenr)	((pgdat)->node_mem_map + (pagenr))
 #else
If we indeed start having pgdat/NODE_DATA for even offline nodes as Michal
Hocko, then we may not this particular patch.

-- 
Thanks and Regards
Srikar Dronamraju

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 13:45:36

* Vlastimil Babka [off-list ref] [2020-03-17 14:34:25]:
On 3/17/20 2:17 PM, Srikar Dronamraju wrote:
quoted
Currently while allocating a slab for a offline node, we use its
associated node_numa_mem to search for a partial slab. If we don't find
a partial slab, we try allocating a slab from the offline node using
__alloc_pages_node. However this is bound to fail.

NIP [c00000000039a300] __alloc_pages_nodemask+0x130/0x3b0
LR [c00000000039a3c4] __alloc_pages_nodemask+0x1f4/0x3b0
Call Trace:
[c0000008b36837f0] [c00000000039a3b4] __alloc_pages_nodemask+0x1e4/0x3b0 (unreliable)
[c0000008b3683870] [c0000000003d1ff8] new_slab+0x128/0xcf0
[c0000008b3683950] [c0000000003d6060] ___slab_alloc+0x410/0x820
[c0000008b3683a40] [c0000000003d64a4] __slab_alloc+0x34/0x60
[c0000008b3683a70] [c0000000003d78b0] __kmalloc_node+0x110/0x490
[c0000008b3683af0] [c000000000343a08] kvmalloc_node+0x58/0x110
[c0000008b3683b30] [c0000000003ffd44] mem_cgroup_css_online+0x104/0x270
[c0000008b3683b90] [c000000000234e08] online_css+0x48/0xd0
[c0000008b3683bc0] [c00000000023dedc] cgroup_apply_control_enable+0x2ec/0x4d0
[c0000008b3683ca0] [c0000000002416f8] cgroup_mkdir+0x228/0x5f0
[c0000008b3683d10] [c000000000520360] kernfs_iop_mkdir+0x90/0xf0
[c0000008b3683d50] [c00000000043e400] vfs_mkdir+0x110/0x230
[c0000008b3683da0] [c000000000441ee0] do_mkdirat+0xb0/0x1a0
[c0000008b3683e20] [c00000000000b278] system_call+0x5c/0x68

Mitigate this by allocating the new slab from the node_numa_mem.
Are you sure this is really needed and the other 3 patches are not enough for
the current SLUB code to work as needed? It seems you are changing the semantics
here...
The other 3 patches are not enough because we don't carry the searchnode
when the actual alloc_pages_node gets called. 

With only the 3 patches, we see the above Panic, its signature is slightly
different from what Sachin first reported and which I have carried in 1st
patch.
quoted
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1970,14 +1970,8 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
 		struct kmem_cache_cpu *c)
 {
 	void *object;
-	int searchnode = node;
 
-	if (node == NUMA_NO_NODE)
-		searchnode = numa_mem_id();
-	else if (!node_present_pages(node))
-		searchnode = node_to_mem_node(node);
-
-	object = get_partial_node(s, get_node(s, searchnode), c, flags);
+	object = get_partial_node(s, get_node(s, node), c, flags);
 	if (object || node != NUMA_NO_NODE)>  		return object;

      return get_any_partial(s, flags, c);
I.e. here in this if(), now node will never equal NUMA_NO_NODE (thanks to the
hunk below), thus the get_any_partial() call becomes dead code?
quoted
@@ -2470,6 +2464,11 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
 
 	WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));
 
+	if (node == NUMA_NO_NODE)
+		node = numa_mem_id();
+	else if (!node_present_pages(node))
+		node = node_to_mem_node(node);
+
 	freelist = get_partial(s, flags, node, c);
 
 	if (freelist)
@@ -2569,12 +2568,10 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
 redo:
 
 	if (unlikely(!node_match(page, node))) {
-		int searchnode = node;
-
 		if (node != NUMA_NO_NODE && !node_present_pages(node))
-			searchnode = node_to_mem_node(node);
+			node = node_to_mem_node(node);
 
-		if (unlikely(!node_match(page, searchnode))) {
+		if (unlikely(!node_match(page, node))) {
 			stat(s, ALLOC_NODE_MISMATCH);
 			deactivate_slab(s, page, c->freelist, c);
 			goto new_slab;
-- 
Thanks and Regards
Srikar Dronamraju

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Vlastimil Babka <hidden>
Date: 2020-03-17 13:53:40

On 3/17/20 2:45 PM, Srikar Dronamraju wrote:
* Vlastimil Babka [off-list ref] [2020-03-17 14:34:25]:
quoted
On 3/17/20 2:17 PM, Srikar Dronamraju wrote:
quoted
Currently while allocating a slab for a offline node, we use its
associated node_numa_mem to search for a partial slab. If we don't find
a partial slab, we try allocating a slab from the offline node using
__alloc_pages_node. However this is bound to fail.

NIP [c00000000039a300] __alloc_pages_nodemask+0x130/0x3b0
LR [c00000000039a3c4] __alloc_pages_nodemask+0x1f4/0x3b0
Call Trace:
[c0000008b36837f0] [c00000000039a3b4] __alloc_pages_nodemask+0x1e4/0x3b0 (unreliable)
[c0000008b3683870] [c0000000003d1ff8] new_slab+0x128/0xcf0
[c0000008b3683950] [c0000000003d6060] ___slab_alloc+0x410/0x820
[c0000008b3683a40] [c0000000003d64a4] __slab_alloc+0x34/0x60
[c0000008b3683a70] [c0000000003d78b0] __kmalloc_node+0x110/0x490
[c0000008b3683af0] [c000000000343a08] kvmalloc_node+0x58/0x110
[c0000008b3683b30] [c0000000003ffd44] mem_cgroup_css_online+0x104/0x270
[c0000008b3683b90] [c000000000234e08] online_css+0x48/0xd0
[c0000008b3683bc0] [c00000000023dedc] cgroup_apply_control_enable+0x2ec/0x4d0
[c0000008b3683ca0] [c0000000002416f8] cgroup_mkdir+0x228/0x5f0
[c0000008b3683d10] [c000000000520360] kernfs_iop_mkdir+0x90/0xf0
[c0000008b3683d50] [c00000000043e400] vfs_mkdir+0x110/0x230
[c0000008b3683da0] [c000000000441ee0] do_mkdirat+0xb0/0x1a0
[c0000008b3683e20] [c00000000000b278] system_call+0x5c/0x68

Mitigate this by allocating the new slab from the node_numa_mem.
Are you sure this is really needed and the other 3 patches are not enough for
the current SLUB code to work as needed? It seems you are changing the semantics
here...
The other 3 patches are not enough because we don't carry the searchnode
when the actual alloc_pages_node gets called. 

With only the 3 patches, we see the above Panic, its signature is slightly
different from what Sachin first reported and which I have carried in 1st
patch.
Ah, I see. So that's the missing pgdat after your series [1] right?

That sounds like an argument for Michal's suggestions that pgdats exist and have
correctly populated zonelists for all possible nodes.
node_to_mem_node() could be just a shortcut for the first zone's node in the
zonelist, so that fallback follows the topology.

[1]
https://lore.kernel.org/linuxppc-dev/20200311110237.5731-1-srikar@linux.vnet.ibm.com/t/#m76e5b4c4084380b1d4b193d5aa0359b987f2290e
quoted
quoted
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1970,14 +1970,8 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
 		struct kmem_cache_cpu *c)
 {
 	void *object;
-	int searchnode = node;
 
-	if (node == NUMA_NO_NODE)
-		searchnode = numa_mem_id();
-	else if (!node_present_pages(node))
-		searchnode = node_to_mem_node(node);
-
-	object = get_partial_node(s, get_node(s, searchnode), c, flags);
+	object = get_partial_node(s, get_node(s, node), c, flags);
 	if (object || node != NUMA_NO_NODE)>  		return object;

      return get_any_partial(s, flags, c);
I.e. here in this if(), now node will never equal NUMA_NO_NODE (thanks to the
hunk below), thus the get_any_partial() call becomes dead code?
quoted
@@ -2470,6 +2464,11 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
 
 	WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));
 
+	if (node == NUMA_NO_NODE)
+		node = numa_mem_id();
+	else if (!node_present_pages(node))
+		node = node_to_mem_node(node);
+
 	freelist = get_partial(s, flags, node, c);
 
 	if (freelist)
@@ -2569,12 +2568,10 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
 redo:
 
 	if (unlikely(!node_match(page, node))) {
-		int searchnode = node;
-
 		if (node != NUMA_NO_NODE && !node_present_pages(node))
-			searchnode = node_to_mem_node(node);
+			node = node_to_mem_node(node);
 
-		if (unlikely(!node_match(page, searchnode))) {
+		if (unlikely(!node_match(page, node))) {
 			stat(s, ALLOC_NODE_MISMATCH);
 			deactivate_slab(s, page, c->freelist, c);
 			goto new_slab;

Re: [PATCH 4/4] powerpc/numa: Set fallback nodes for offline nodes

From: Bharata B Rao <hidden>
Date: 2020-03-17 14:22:46

This patchset can also fix a related problem that I reported earlier at
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-March/206076.html
with an additional change, suggested by Srikar as shown below:

On Tue, Mar 17, 2020 at 06:47:53PM +0530, Srikar Dronamraju wrote:
quoted hunk
Currently fallback nodes for offline nodes aren't set. Hence by default
node 0 ends up being the default node. However node 0 might be offline.

Fix this by explicitly setting fallback node. Ensure first_memory_node
is set before kernel does explicit setting of fallback node.

 arch/powerpc/mm/numa.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 281531340230..6e97ab6575cb 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -827,7 +827,16 @@ void __init dump_numa_cpu_topology(void)
 	if (!numa_enabled)
 		return;
 
-	for_each_online_node(node) {
+	for_each_node(node) {
+		/*
+		 * For all possible but not yet online nodes, ensure their
+		 * node_numa_mem is set correctly so that kmalloc_node works
+		 * for such nodes.
+		 */
+		if (!node_online(node)) {
Change the above line to like below:

+               if (!node_state(node, N_MEMORY)) {

Regards,
Bharata.

Re: [PATCH 4/4] powerpc/numa: Set fallback nodes for offline nodes

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 14:29:39

* Bharata B Rao [off-list ref] [2020-03-17 19:52:32]:

Thanks Bharata.
This patchset can also fix a related problem that I reported earlier at
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-March/206076.html
with an additional change, suggested by Srikar as shown below:
quoted
 
-	for_each_online_node(node) {
+	for_each_node(node) {
+		/*
+		 * For all possible but not yet online nodes, ensure their
+		 * node_numa_mem is set correctly so that kmalloc_node works
+		 * for such nodes.
+		 */
+		if (!node_online(node)) {
Change the above line to like below:

+               if (!node_state(node, N_MEMORY)) {
Just to clarify, this is needed if we don't have
http://lore.kernel.org/lkml/20200311110237.5731-1-srikar@linux.vnet.ibm.com/t/#u


-- 
Thanks and Regards
Srikar Dronamraju

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 14:51:27

* Vlastimil Babka [off-list ref] [2020-03-17 14:53:26]:
quoted
quoted
quoted
Mitigate this by allocating the new slab from the node_numa_mem.
Are you sure this is really needed and the other 3 patches are not enough for
the current SLUB code to work as needed? It seems you are changing the semantics
here...
The other 3 patches are not enough because we don't carry the searchnode
when the actual alloc_pages_node gets called. 

With only the 3 patches, we see the above Panic, its signature is slightly
different from what Sachin first reported and which I have carried in 1st
patch.
Ah, I see. So that's the missing pgdat after your series [1] right?
Yes the pgdat would be missing after my cpuless, memoryless node patchset.
However..
That sounds like an argument for Michal's suggestions that pgdats exist and have
correctly populated zonelists for all possible nodes.
Only the first patch in this series would be affected by pgdat existing or
not.  Even if the pgdat existed, the NODE_DATA[nid]->node_present_pages
would be 0. Right? So it would look at node_to_mem_node(). And since node 0 is
cpuless it would return 0. If we pass this node 0 (which is memoryless/cpuless) to
alloc_pages_node. Please note I am only setting node_numa_mem only
for offline nodes. However we could change this to set for all offline and
memoryless nodes.
node_to_mem_node() could be just a shortcut for the first zone's node in the
zonelist, so that fallback follows the topology.

[1]
https://lore.kernel.org/linuxppc-dev/20200311110237.5731-1-srikar@linux.vnet.ibm.com/t/#m76e5b4c4084380b1d4b193d5aa0359b987f2290e


-- 
Thanks and Regards
Srikar Dronamraju

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Vlastimil Babka <hidden>
Date: 2020-03-17 15:29:30

On 3/17/20 3:51 PM, Srikar Dronamraju wrote:
* Vlastimil Babka [off-list ref] [2020-03-17 14:53:26]:
quoted
quoted
quoted
quoted
Mitigate this by allocating the new slab from the node_numa_mem.
Are you sure this is really needed and the other 3 patches are not enough for
the current SLUB code to work as needed? It seems you are changing the semantics
here...
The other 3 patches are not enough because we don't carry the searchnode
when the actual alloc_pages_node gets called. 

With only the 3 patches, we see the above Panic, its signature is slightly
different from what Sachin first reported and which I have carried in 1st
patch.
Ah, I see. So that's the missing pgdat after your series [1] right?
Yes the pgdat would be missing after my cpuless, memoryless node patchset.
However..
quoted
That sounds like an argument for Michal's suggestions that pgdats exist and have
correctly populated zonelists for all possible nodes.
Only the first patch in this series would be affected by pgdat existing or
not.  Even if the pgdat existed, the NODE_DATA[nid]->node_present_pages
would be 0. Right? So it would look at node_to_mem_node(). And since node 0 is
cpuless it would return 0.
I thought the point was to return 1 for node 0.
If we pass this node 0 (which is memoryless/cpuless) to
alloc_pages_node. Please note I am only setting node_numa_mem only
for offline nodes. However we could change this to set for all offline and
memoryless nodes.
That would indeed make sense.

But I guess that alloc_pages would still crash as the result of
numa_to_mem_node() is not passed down to alloc_pages() without this patch. In
__alloc_pages_node() we currently have "The node must be valid and online" so
offline nodes don't have zonelists. Either they get them, or we indeed need
something like this patch. But in order to not make get_any_partial() dead code,
the final replacement of invalid node with a valid one should be done in
alloc_slab_page() I guess?
quoted
node_to_mem_node() could be just a shortcut for the first zone's node in the
zonelist, so that fallback follows the topology.

[1]
https://lore.kernel.org/linuxppc-dev/20200311110237.5731-1-srikar@linux.vnet.ibm.com/t/#m76e5b4c4084380b1d4b193d5aa0359b987f2290e

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Srikar Dronamraju <hidden>
Date: 2020-03-17 16:41:18

* Vlastimil Babka [off-list ref] [2020-03-17 14:34:25]:
quoted
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1970,14 +1970,8 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
 		struct kmem_cache_cpu *c)
 {
 	void *object;
-	int searchnode = node;
 
-	if (node == NUMA_NO_NODE)
-		searchnode = numa_mem_id();
-	else if (!node_present_pages(node))
-		searchnode = node_to_mem_node(node);
-
-	object = get_partial_node(s, get_node(s, searchnode), c, flags);
+	object = get_partial_node(s, get_node(s, node), c, flags);
 	if (object || node != NUMA_NO_NODE)>  		return object;

      return get_any_partial(s, flags, c);
I.e. here in this if(), now node will never equal NUMA_NO_NODE (thanks to the
hunk below), thus the get_any_partial() call becomes dead code?
Very true. 

Would it be okay if we remove the node != NUMA_NO_NODE
  	if (object || node != NUMA_NO_NODE)
		return object;

will now become
  	if (object)
		return object;

-- 
Thanks and Regards
Srikar Dronamraju

Re: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab

From: Srikar Dronamraju <hidden>
Date: 2020-03-18 07:30:08

* Vlastimil Babka [off-list ref] [2020-03-17 16:29:21]:
quoted
If we pass this node 0 (which is memoryless/cpuless) to
alloc_pages_node. Please note I am only setting node_numa_mem only
for offline nodes. However we could change this to set for all offline and
memoryless nodes.
That would indeed make sense.

But I guess that alloc_pages would still crash as the result of
numa_to_mem_node() is not passed down to alloc_pages() without this patch. In
__alloc_pages_node() we currently have "The node must be valid and online" so
offline nodes don't have zonelists. Either they get them, or we indeed need
something like this patch. But in order to not make get_any_partial() dead code,
the final replacement of invalid node with a valid one should be done in
alloc_slab_page() I guess?
I am posting v2 with this change.
quoted
quoted
node_to_mem_node() could be just a shortcut for the first zone's node in the
zonelist, so that fallback follows the topology.
-- 
Thanks and Regards
Srikar Dronamraju
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help