Skip to contentSkip to conversation

WARNING in memory_failure

syzbot syzbot 7 participants 43 messages Sep 23, 2025 – Oct 10, 2025

Subsystems (4)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    b5db4add5e77 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=10edb8e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2ae34a0711ff2f1
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14160f12580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1361627c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6eee2232d5c1/disk-b5db4add.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a8b00f2f1234/vmlinux-b5db4add.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc0d466f156c/Image-b5db4add.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

Injecting memory failure for pfn 0x104000 at process virtual address 0x20000000

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff8620001 x25: 05ffc0000020086d x24: 1fffffbff8620000
x23: fffffdffc3100008 x22: fffffdffc3100000 x21: fffffdffc3100000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: ffff80008f7ee000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff8620000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff8620001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080428910 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Call trace:
 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
 madvise_inject_error mm/madvise.c:1475 [inline]
 madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
 do_madvise+0x190/0x248 mm/madvise.c:1978
 __do_sys_madvise mm/madvise.c:1987 [inline]
 __se_sys_madvise mm/madvise.c:1985 [inline]
 __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
 el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
 el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596
irq event stamp: 1544
hardirqs last  enabled at (1543): [<ffff80008b042cd0>] __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:159 [inline]
hardirqs last  enabled at (1543): [<ffff80008b042cd0>] _raw_spin_unlock_irq+0x30/0x80 kernel/locking/spinlock.c:202
hardirqs last disabled at (1544): [<ffff80008b01a1ac>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:434
softirqs last  enabled at (1528): [<ffff8000803da960>] softirq_handle_end kernel/softirq.c:425 [inline]
softirqs last  enabled at (1528): [<ffff8000803da960>] handle_softirqs+0xaf8/0xc88 kernel/softirq.c:607
softirqs last disabled at (1397): [<ffff800080022028>] __do_softirq+0x14/0x20 kernel/softirq.c:613
---[ end trace 0000000000000000 ]---
Memory failure: 0x104000: recovery action for huge page: Recovered
Injecting memory failure for pfn 0x131e00 at process virtual address 0x20200000
------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Tainted: G        W           syzkaller #0 PREEMPT 
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff878f001 x25: 05ffc0000020086d x24: 1fffffbff878f000
x23: fffffdffc3c78008 x22: fffffdffc3c78000 x21: fffffdffc3c78000
x20: 0000000000000023 x19: dfff800000000000 x18: 00000000ffffffff
x17: ffff80009353a000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff878f000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff878f001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080a549a8 x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Call trace:
 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
 madvise_inject_error mm/madvise.c:1475 [inline]
 madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
 do_madvise+0x190/0x248 mm/madvise.c:1978
 __do_sys_madvise mm/madvise.c:1987 [inline]
 __se_sys_madvise mm/madvise.c:1985 [inline]
 __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
 el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
 el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596
irq event stamp: 2162
hardirqs last  enabled at (2161): [<ffff800080ca8720>] __folio_split+0xf7c/0x1438 mm/huge_memory.c:3856
hardirqs last disabled at (2162): [<ffff80008b01a1ac>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:434
softirqs last  enabled at (1726): [<ffff8000803da960>] softirq_handle_end kernel/softirq.c:425 [inline]
softirqs last  enabled at (1726): [<ffff8000803da960>] handle_softirqs+0xaf8/0xc88 kernel/softirq.c:607
softirqs last disabled at (1547): [<ffff800080022028>] __do_softirq+0x14/0x20 kernel/softirq.c:613
---[ end trace 0000000000000000 ]---
Memory failure: 0x131e00: recovery action for huge page: Recovered
Injecting memory failure for pfn 0x134200 at process virtual address 0x20400000
------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Tainted: G        W           syzkaller #0 PREEMPT 
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff87a1001 x25: 05ffc0000020086d x24: 1fffffbff87a1000
x23: fffffdffc3d08008 x22: fffffdffc3d08000 x21: fffffdffc3d08000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: 646461206c617574 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff87a1000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff87a1001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080a549a8 x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Call trace:
 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
 madvise_inject_error mm/madvise.c:1475 [inline]
 madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
 do_madvise+0x190/0x248 mm/madvise.c:1978
 __do_sys_madvise mm/madvise.c:1987 [inline]
 __se_sys_madvise mm/madvise.c:1985 [inline]
 __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
 el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
 el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596
irq event stamp: 2768
hardirqs last  enabled at (2767): [<ffff800080ca8720>] __folio_split+0xf7c/0x1438 mm/huge_memory.c:3856
hardirqs last disabled at (2768): [<ffff80008b01a1ac>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:434
softirqs last  enabled at (2364): [<ffff8000803da960>] softirq_handle_end kernel/softirq.c:425 [inline]
softirqs last  enabled at (2364): [<ffff8000803da960>] handle_softirqs+0xaf8/0xc88 kernel/softirq.c:607
softirqs last disabled at (2321): [<ffff800080022028>] __do_softirq+0x14/0x20 kernel/softirq.c:613
---[ end trace 0000000000000000 ]---
Memory failure: 0x134200: recovery action for huge page: Recovered
Injecting memory failure for pfn 0x129000 at process virtual address 0x20600000
------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Tainted: G        W           syzkaller #0 PREEMPT 
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff8748001 x25: 05ffc0000020086d x24: 1fffffbff8748000
x23: fffffdffc3a40008 x22: fffffdffc3a40000 x21: fffffdffc3a40000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: 646461206c617574 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff8748000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff8748001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080a549a8 x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Call trace:
 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
 madvise_inject_error mm/madvise.c:1475 [inline]
 madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
 do_madvise+0x190/0x248 mm/madvise.c:1978
 __do_sys_madvise mm/madvise.c:1987 [inline]
 __se_sys_madvise mm/madvise.c:1985 [inline]
 __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
 el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
 el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596
irq event stamp: 3024
hardirqs last  enabled at (3023): [<ffff800080ca8720>] __folio_split+0xf7c/0x1438 mm/huge_memory.c:3856
hardirqs last disabled at (3024): [<ffff80008b01a1ac>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:434
softirqs last  enabled at (2986): [<ffff8000803da960>] softirq_handle_end kernel/softirq.c:425 [inline]
softirqs last  enabled at (2986): [<ffff8000803da960>] handle_softirqs+0xaf8/0xc88 kernel/softirq.c:607
softirqs last disabled at (2771): [<ffff800080022028>] __do_softirq+0x14/0x20 kernel/softirq.c:613
---[ end trace 0000000000000000 ]---
Memory failure: 0x129000: recovery action for huge page: Recovered
Injecting memory failure for pfn 0x134600 at process virtual address 0x20800000
------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Tainted: G        W           syzkaller #0 PREEMPT 
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc0000020086c x27: ffff700014828f20
x26: 1fffffbff87a3001 x25: 05ffc0000020186d x24: 1fffffbff87a3000
x23: fffffdffc3d18008 x22: fffffdffc3d18000 x21: fffffdffc3d18000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: ffff80009353a000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff87a3000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff87a3001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080a549a8 x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Call trace:
 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
 madvise_inject_error mm/madvise.c:1475 [inline]
 madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
 do_madvise+0x190/0x248 mm/madvise.c:1978
 __do_sys_madvise mm/madvise.c:1987 [inline]
 __se_sys_madvise mm/madvise.c:1985 [inline]
 __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
 el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
 el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596
irq event stamp: 3462
hardirqs last  enabled at (3461): [<ffff800080ca8720>] __folio_split+0xf7c/0x1438 mm/huge_memory.c:3856
hardirqs last disabled at (3462): [<ffff80008b01a1ac>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:434
softirqs last  enabled at (3064): [<ffff8000803da960>] softirq_handle_end kernel/softirq.c:425 [inline]
softirqs last  enabled at (3064): [<ffff8000803da960>] handle_softirqs+0xaf8/0xc88 kernel/softirq.c:607
softirqs last disabled at (3027): [<ffff800080022028>] __do_softirq+0x14/0x20 kernel/softirq.c:613
---[ end trace 0000000000000000 ]---
Memory failure: 0x134600: recovery action for huge page: Recovered
Injecting memory failure for pfn 0x134800 at proces
Injecting memory failure for pfn 0x134800 at process virtual address 0x20a00000
------------[ cut here ]------------
WARNING: CPU: 0 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 0 UID: 0 PID: 6700 Comm: syz.0.17 Tainted: G        W           syzkaller #0 PREEMPT 
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc0000020086c x27: ffff700014828f20
x26: 1fffffbff87a4001 x25: 05ffc0000020186d x24: 1fffffbff87a4000
x23: fffffdffc3d20008 x22: fffffdffc3d20000 x21: fffffdffc3d20000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe0003378f088
x17: ffff80008f7ee000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff87a4000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff87a4001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080a549a8 x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Call trace:
 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
 madvise_inject_error mm/madvise.c:1475 [inline]
 madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
 do_madvise+0x190/0x248 mm/madvise.c:1978
 __do_sys_madvise mm/madvise.c:1987 [inline]
 __se_sys_madvise mm/madvise.c:1985 [inline]
 __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
 el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
 el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596
irq event stamp: 3538
hardirqs last  enabled at (3537): [<ffff800080ca8720>] __folio_split+0xf7c/0x1438 mm/huge_memory.c:3856
hardirqs last disabled at (3538): [<ffff80008b01a1ac>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:434
softirqs last  enabled at (3500): [<ffff8000803da960>] softirq_handle_end kernel/softirq.c:425 [inline]
softirqs last  enabled at (3500): [<ffff8000803da960>] handle_softirqs+0xaf8/0xc88 kernel/softirq.c:607
softirqs last disabled at (3465): [<ffff800080022028>] __do_softirq+0x14/0x20 kernel/softirq.c:613
---[ end trace 0000000000000000 ]---

Memory failure: 0x134800: recovery action for huge page: Recovered

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

#1 lore raw
Quoted 42 lines · syzbot

Hello,

syzbot found the following issue on:

HEAD commit:    b5db4add5e77 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=10edb8e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2ae34a0711ff2f1
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14160f12580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1361627c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6eee2232d5c1/disk-b5db4add.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a8b00f2f1234/vmlinux-b5db4add.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc0d466f156c/Image-b5db4add.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

Injecting memory failure for pfn 0x104000 at process virtual address 0x20000000

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff8620001 x25: 05ffc0000020086d x24: 1fffffbff8620000
x23: fffffdffc3100008 x22: fffffdffc3100000 x21: fffffdffc3100000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: ffff80008f7ee000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff8620000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff8620001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080428910 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Quoted 15 lines
Call trace:
  memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
  madvise_inject_error mm/madvise.c:1475 [inline]
  madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
  do_madvise+0x190/0x248 mm/madvise.c:1978
  __do_sys_madvise mm/madvise.c:1987 [inline]
  __se_sys_madvise mm/madvise.c:1985 [inline]
  __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
  __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
  invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
  el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
  do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
  el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
  el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
  el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596

We're running into the

        WARN_ON(folio_test_large(folio));

in memory_failure().

Which is weird because we have the

        if (folio_test_large(folio)) {
                /*
                 * The flag must be set after the refcount is bumped
                 * otherwise it may race with THP split.
                 * And the flag can't be set in get_hwpoison_page() since
                 * it is called by soft offline too and it is just called
                 * for !MF_COUNT_INCREASED.  So here seems to be the best
                 * place.
                 *
                 * Don't need care about the above error handling paths for
                 * get_hwpoison_page() since they handle either free page
                 * or unhandlable page.  The refcount is bumped iff the
                 * page is a valid handlable page.
                 */
                folio_set_has_hwpoisoned(folio);
                if (try_to_split_thp_page(p, false) < 0) {
                        res = -EHWPOISON;
                        kill_procs_now(p, pfn, flags, folio);
                        put_page(p);
                        action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
                        goto unlock_mutex;
                }
                VM_BUG_ON_PAGE(!page_count(p), p);
                folio = page_folio(p);
        }

before it.

But likely that's what I raised to Zi Yan recently: if try_to_split_thp_page()->split_huge_page() silently decided to split to something that is not a small folio (the min_order_for_split() bit), this changed the semantics of the function.

Likely split_huge_page() should have failed if the min_order makes us not split to order-0, or there would have to be some "parameter" that tells split_huge_page() what expectation (order) the callers has.

We can check folio_test_large() after the split, but really, we should just not be splitting at all if it doesn't serve our purpose.

Signature · 3 lines
Cheers

David / dhildenb
reviewer
#2 lore raw
Quoted 99 lines · David Hildenbrand
Quoted 42 lines · syzbot

Hello,

syzbot found the following issue on:

HEAD commit:    b5db4add5e77 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=10edb8e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2ae34a0711ff2f1
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14160f12580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1361627c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6eee2232d5c1/disk-b5db4add.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a8b00f2f1234/vmlinux-b5db4add.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc0d466f156c/Image-b5db4add.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

Injecting memory failure for pfn 0x104000 at process virtual address 0x20000000

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff8620001 x25: 05ffc0000020086d x24: 1fffffbff8620000
x23: fffffdffc3100008 x22: fffffdffc3100000 x21: fffffdffc3100000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: ffff80008f7ee000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff8620000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff8620001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080428910 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Quoted 15 lines
Call trace:
  memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
  madvise_inject_error mm/madvise.c:1475 [inline]
  madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
  do_madvise+0x190/0x248 mm/madvise.c:1978
  __do_sys_madvise mm/madvise.c:1987 [inline]
  __se_sys_madvise mm/madvise.c:1985 [inline]
  __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
  __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
  invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
  el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
  do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
  el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
  el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
  el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596

We're running into the

        WARN_ON(folio_test_large(folio));

in memory_failure().

Which is weird because we have the

        if (folio_test_large(folio)) {
                /*
                 * The flag must be set after the refcount is bumped
                 * otherwise it may race with THP split.
                 * And the flag can't be set in get_hwpoison_page() since
                 * it is called by soft offline too and it is just called
                 * for !MF_COUNT_INCREASED.  So here seems to be the best
                 * place.
                 *
                 * Don't need care about the above error handling paths for
                 * get_hwpoison_page() since they handle either free page
                 * or unhandlable page.  The refcount is bumped iff the
                 * page is a valid handlable page.
                 */
                folio_set_has_hwpoisoned(folio);
                if (try_to_split_thp_page(p, false) < 0) {
                        res = -EHWPOISON;
                        kill_procs_now(p, pfn, flags, folio);
                        put_page(p);
                        action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
                        goto unlock_mutex;
                }
                VM_BUG_ON_PAGE(!page_count(p), p);
                folio = page_folio(p);
        }

before it.

But likely that's what I raised to Zi Yan recently: if try_to_split_thp_page()->split_huge_page() silently decided to split to something that is not a small folio (the min_order_for_split() bit), this changed the semantics of the function.

Quoted 6 lines

Likely split_huge_page() should have failed if the min_order makes us not split to order-0, or there would have to be some "parameter" that tells split_huge_page() what expectation (order) the callers has.

We can check folio_test_large() after the split, but really, we should just not be splitting at all if it doesn't serve our purpose.

But LBS might want to split from a high order to fs min_order.

What I can think of is:
0. split code always does a split to allowed minimal order, namely max(fs_min_order, order_from_caller);
1. if split order cannot reach to order_from_caller, it just return fails, so most of the caller will know about it;
2. for LBS code, when it sees a split failure, it should check the resulting folio order against fs min_order. If the orders match, it regards it as a success.

At least, most of the code does not need to be LBS aware. WDYT?

Best Regards,
Yan, Zi

#3 lore raw
Quoted 101 lines · Zi Yan
Quoted 99 lines · David Hildenbrand
Quoted 42 lines · syzbot

Hello,

syzbot found the following issue on:

HEAD commit:    b5db4add5e77 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=10edb8e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2ae34a0711ff2f1
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14160f12580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1361627c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6eee2232d5c1/disk-b5db4add.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a8b00f2f1234/vmlinux-b5db4add.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc0d466f156c/Image-b5db4add.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

Injecting memory failure for pfn 0x104000 at process virtual address 0x20000000

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff8620001 x25: 05ffc0000020086d x24: 1fffffbff8620000
x23: fffffdffc3100008 x22: fffffdffc3100000 x21: fffffdffc3100000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: ffff80008f7ee000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff8620000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff8620001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080428910 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Quoted 15 lines
Call trace:
   memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
   madvise_inject_error mm/madvise.c:1475 [inline]
   madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
   do_madvise+0x190/0x248 mm/madvise.c:1978
   __do_sys_madvise mm/madvise.c:1987 [inline]
   __se_sys_madvise mm/madvise.c:1985 [inline]
   __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
   __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
   invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
   el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
   do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
   el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
   el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
   el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596

We're running into the

         WARN_ON(folio_test_large(folio));

in memory_failure().

Which is weird because we have the

         if (folio_test_large(folio)) {
                 /*
                  * The flag must be set after the refcount is bumped
                  * otherwise it may race with THP split.
                  * And the flag can't be set in get_hwpoison_page() since
                  * it is called by soft offline too and it is just called
                  * for !MF_COUNT_INCREASED.  So here seems to be the best
                  * place.
                  *
                  * Don't need care about the above error handling paths for
                  * get_hwpoison_page() since they handle either free page
                  * or unhandlable page.  The refcount is bumped iff the
                  * page is a valid handlable page.
                  */
                 folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio);
                         put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
                         goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);
         }

before it.

But likely that's what I raised to Zi Yan recently: if try_to_split_thp_page()->split_huge_page() silently decided to split to something that is not a small folio (the min_order_for_split() bit), this changed the semantics of the function.

Quoted 8 lines
Quoted 6 lines

Likely split_huge_page() should have failed if the min_order makes us not split to order-0, or there would have to be some "parameter" that tells split_huge_page() what expectation (order) the callers has.

We can check folio_test_large() after the split, but really, we should just not be splitting at all if it doesn't serve our purpose.

But LBS might want to split from a high order to fs min_order.

Yes.

Quoted 4 lines

What I can think of is:
0. split code always does a split to allowed minimal order,

    namely max(fs_min_order, order_from_caller);

Wouldn't max mean "allowed maximum order" ?

I guess what you mean is "split to this order or smaller" -- min?

Quoted 2 lines

1. if split order cannot reach to order_from_caller, it just return fails,

    so most of the caller will know about it;

Yes, I think this would be the case here: if we cannot split to order-0, we can just fail right away.

Quoted 5 lines

2. for LBS code, when it sees a split failure, it should check the resulting folio order against fs min_order. If the orders match, it regards it as a success.

At least, most of the code does not need to be LBS aware. WDYT?

Is my understand correct that it's either that the caller wants to

(a) Split to order-0 -- no larger folio afterwards.

(b) Split to smallest order possible, which might be the mapping min order.

If so, we could keep the interface simpler than allowing to specify arbitrary orders as request.

Signature · 3 lines
Cheers

David / dhildenb
reviewer
#4 lore raw
Quoted 114 lines · David Hildenbrand
Quoted 101 lines · Zi Yan
Quoted 99 lines · David Hildenbrand
Quoted 42 lines · syzbot

Hello,

syzbot found the following issue on:

HEAD commit:    b5db4add5e77 Merge branch 'for-next/core' into for-kernelci
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=10edb8e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2ae34a0711ff2f1
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14160f12580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1361627c580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6eee2232d5c1/disk-b5db4add.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a8b00f2f1234/vmlinux-b5db4add.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc0d466f156c/Image-b5db4add.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

Injecting memory failure for pfn 0x104000 at process virtual address 0x20000000

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6700 at mm/memory-failure.c:2391 memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
Modules linked in:
CPU: 1 UID: 0 PID: 6700 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/30/2025
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391
lr : memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391

sp : ffff8000a41478c0
x29: ffff8000a41479a0 x28: 05ffc00000200868 x27: ffff700014828f20
x26: 1fffffbff8620001 x25: 05ffc0000020086d x24: 1fffffbff8620000
x23: fffffdffc3100008 x22: fffffdffc3100000 x21: fffffdffc3100000
x20: 0000000000000023 x19: dfff800000000000 x18: 1fffe00033793888
x17: ffff80008f7ee000 x16: ffff80008052aa64 x15: 0000000000000001
x14: 1fffffbff8620000 x13: 0000000000000000 x12: 0000000000000000
x11: ffff7fbff8620001 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : ffff0000d7eedb80 x7 : ffff800080428910 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000001 x3 : ffff800080cf5438 x2 : 0000000000000001 x1 : 0000000000000040 x0 : 0000000000000000

Quoted 15 lines
Call trace:
   memory_failure+0x18ec/0x1db4 mm/memory-failure.c:2391 (P)
   madvise_inject_error mm/madvise.c:1475 [inline]
   madvise_do_behavior+0x2c8/0x7c4 mm/madvise.c:1875
   do_madvise+0x190/0x248 mm/madvise.c:1978
   __do_sys_madvise mm/madvise.c:1987 [inline]
   __se_sys_madvise mm/madvise.c:1985 [inline]
   __arm64_sys_madvise+0xa4/0xc0 mm/madvise.c:1985
   __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
   invoke_syscall+0x98/0x254 arch/arm64/kernel/syscall.c:49
   el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
   do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
   el0_svc+0x5c/0x254 arch/arm64/kernel/entry-common.c:744
   el0t_64_sync_handler+0x84/0x12c arch/arm64/kernel/entry-common.c:763
   el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:596

We're running into the

         WARN_ON(folio_test_large(folio));

in memory_failure().

Which is weird because we have the

         if (folio_test_large(folio)) {
                 /*
                  * The flag must be set after the refcount is bumped
                  * otherwise it may race with THP split.
                  * And the flag can't be set in get_hwpoison_page() since
                  * it is called by soft offline too and it is just called
                  * for !MF_COUNT_INCREASED.  So here seems to be the best
                  * place.
                  *
                  * Don't need care about the above error handling paths for
                  * get_hwpoison_page() since they handle either free page
                  * or unhandlable page.  The refcount is bumped iff the
                  * page is a valid handlable page.
                  */
                 folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio);
                         put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
                         goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);
         }

before it.

But likely that's what I raised to Zi Yan recently: if try_to_split_thp_page()->split_huge_page() silently decided to split to something that is not a small folio (the min_order_for_split() bit), this changed the semantics of the function.

Quoted 8 lines
Quoted 6 lines

Likely split_huge_page() should have failed if the min_order makes us not split to order-0, or there would have to be some "parameter" that tells split_huge_page() what expectation (order) the callers has.

We can check folio_test_large() after the split, but really, we should just not be splitting at all if it doesn't serve our purpose.

But LBS might want to split from a high order to fs min_order.

Yes.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

What I can think of is:
0. split code always does a split to allowed minimal order,

    namely max(fs_min_order, order_from_caller);

Wouldn't max mean "allowed maximum order" ?

I guess what you mean is "split to this order or smaller" -- min?

But LBS imposes a fs_min_order that is not 0. When a caller asks to split to 0, folio split code needs to use fs_min_order instead of 0. Thus the max.

Quoted 10 lines
Quoted 3 lines

1. if split order cannot reach to order_from_caller, it just return fails,

    so most of the caller will know about it;

Yes, I think this would be the case here: if we cannot split to order-0, we can just fail right away.

Quoted 4 lines

2. for LBS code, when it sees a split failure, it should check the resulting folio order against fs min_order. If the orders match, it regards it as a success.

Quoted 7 lines
Quoted 1 line

At least, most of the code does not need to be LBS aware. WDYT?

Is my understand correct that it's either that the caller wants to

(a) Split to order-0 -- no larger folio afterwards.

(b) Split to smallest order possible, which might be the mapping min order.

Right. IIRC, most of callers are (a), since folio split was originally called by code that cannot handle THPs (now large folios). For (b), I actually wonder if there exists such a caller.

Quoted 1 line

If so, we could keep the interface simpler than allowing to specify arbitrary orders as request.

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

Thanks.

Best Regards,
Yan, Zi

#5 lore raw
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

What I can think of is:
0. split code always does a split to allowed minimal order,

     namely max(fs_min_order, order_from_caller);
Quoted 7 lines
Quoted 3 lines

Wouldn't max mean "allowed maximum order" ?

I guess what you mean is "split to this order or smaller" -- min?

But LBS imposes a fs_min_order that is not 0. When a caller asks to split to 0, folio split code needs to use fs_min_order instead of 0. Thus the max.

I'd say, the point is that if someone wants to split to 0 but that is impossible, then we should fail :)

Quoted 23 lines
Quoted 11 lines
Quoted 4 lines

1. if split order cannot reach to order_from_caller, it just return fails,

     so most of the caller will know about it;

Yes, I think this would be the case here: if we cannot split to order-0, we can just fail right away.

Quoted 4 lines

2. for LBS code, when it sees a split failure, it should check the resulting folio order against fs min_order. If the orders match, it regards it as a success.

Quoted 7 lines
Quoted 1 line

At least, most of the code does not need to be LBS aware. WDYT?

Is my understand correct that it's either that the caller wants to

(a) Split to order-0 -- no larger folio afterwards.

(b) Split to smallest order possible, which might be the mapping min order.

Right. IIRC, most of callers are (a), since folio split was originally called by code that cannot handle THPs (now large folios). For (b), I actually wonder if there exists such a caller.

Quoted 7 lines
Quoted 1 line

If so, we could keep the interface simpler than allowing to specify arbitrary orders as request.

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Quoted 20 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

Thanks.

Best Regards,
Yan, Zi

Signature · 3 lines
Cheers

David / dhildenb
reviewer
#6 lore raw
Quoted 8 lines · David Hildenbrand
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

What I can think of is:
0. split code always does a split to allowed minimal order,

     namely max(fs_min_order, order_from_caller);

Wouldn't max mean "allowed maximum order" ?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I guess what you mean is "split to this order or smaller" -- min?

But LBS imposes a fs_min_order that is not 0. When a caller asks to split to 0, folio split code needs to use fs_min_order instead of 0. Thus the max.

I'd say, the point is that if someone wants to split to 0 but that is impossible, then we should fail :)

I agree.

Quoted 26 lines
Quoted 26 lines
Quoted 12 lines
Quoted 5 lines

1. if split order cannot reach to order_from_caller, it just return fails,

     so most of the caller will know about it;

Yes, I think this would be the case here: if we cannot split to order-0, we can just fail right away.

Quoted 4 lines

2. for LBS code, when it sees a split failure, it should check the resulting folio order against fs min_order. If the orders match, it regards it as a success.

Quoted 7 lines
Quoted 1 line

At least, most of the code does not need to be LBS aware. WDYT?

Is my understand correct that it's either that the caller wants to

(a) Split to order-0 -- no larger folio afterwards.

(b) Split to smallest order possible, which might be the mapping min order.

Right. IIRC, most of callers are (a), since folio split was originally called by code that cannot handle THPs (now large folios). For (b), I actually wonder if there exists such a caller.

Quoted 1 line

If so, we could keep the interface simpler than allowing to specify arbitrary orders as request.

Quoted 7 lines
Quoted 5 lines

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Yep. Let’s hear what Luis and Pankaj will say about this.

Quoted 15 lines
Quoted 15 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

Quoted 12 lines
Quoted 6 lines

Thanks.

Best Regards,
Yan, Zi

Signature · 3 lines
Cheers

David / dhildenb

Best Regards,
Yan, Zi

#7 lore raw
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Quoted 19 lines
Quoted 1 line

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Yep. Let’s hear what Luis and Pankaj will say about this.

Quoted 15 lines
Quoted 15 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

I am not aware of any place in the LBS path where we supply the min_order. truncate_inode_partial_folio() calls try_folio_split(), which takes care of splitting in min_order chunks. So we embedded the min_order in the MM functions that performs the split instead of the caller passing the min_order. Probably, that is why this problem is being exposed now where people are surprised by seeing a large folio even though they asked to split folios to order-0.

As you concluded, we will not be breaking anything wrt LBS as we just refuse to split if it doesn't match the min_order. The only issue I see is we might be exacerbating ENOMEM errors as we are not splitting as many folios with this change. But the solution for that is simple, add more RAM to the system ;)

Just for clarity, are we talking about changing the behaviour just the try_to_split_thp_page() function or all the split functions in huge_mm.h?

Signature · 1 line
Pankaj
reviewer
#8 lore raw
Quoted 35 lines · Pankaj Raghav (Samsung)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Quoted 19 lines
Quoted 1 line

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Yep. Let’s hear what Luis and Pankaj will say about this.

Quoted 15 lines
Quoted 15 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

I am not aware of any place in the LBS path where we supply the min_order. truncate_inode_partial_folio() calls try_folio_split(), which takes care of splitting in min_order chunks. So we embedded the min_order in the MM functions that performs the split instead of the caller passing the min_order. Probably, that is why this problem is being exposed now where people are surprised by seeing a large folio even though they asked to split folios to order-0.

Quoted 8 lines

As you concluded, we will not be breaking anything wrt LBS as we just refuse to split if it doesn't match the min_order. The only issue I see is we might be exacerbating ENOMEM errors as we are not splitting as many folios with this change. But the solution for that is simple, add more RAM to the system ;)

Just for clarity, are we talking about changing the behaviour just the try_to_split_thp_page() function or all the split functions in huge_mm.h?

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

WDYT?

include/linux/huge_mm.h +5 -23
index f327d62fc985..e15c3ca07e33 100644
@@ -387,34 +387,16 @@ int folio_split(struct folio *folio, unsigned int new_order, struct page *page,
  * Return: 0: split is successful, otherwise split failed.
  */
 static inline int try_folio_split(struct folio *folio, struct page *page,
-		struct list_head *list)
+		struct list_head *list, unsigned int order)
 {
-	int ret = min_order_for_split(folio);
-
-	if (ret < 0)
-		return ret;
-
-	if (!non_uniform_split_supported(folio, 0, false))
+	if (!non_uniform_split_supported(folio, order, false))
 		return split_huge_page_to_list_to_order(&folio->page, list,
-				ret);
-	return folio_split(folio, ret, page, list);
+				order);
+	return folio_split(folio, order, page, list);
 }
 static inline int split_huge_page(struct page *page)
 {
-	struct folio *folio = page_folio(page);
-	int ret = min_order_for_split(folio);
-
-	if (ret < 0)
-		return ret;
-
-	/*
-	 * split_huge_page() locks the page before splitting and
-	 * expects the same page that has been split to be locked when
-	 * returned. split_folio(page_folio(page)) cannot be used here
-	 * because it converts the page to folio and passes the head
-	 * page to be split.
-	 */
-	return split_huge_page_to_list_to_order(page, NULL, ret);
+	return split_huge_page_to_list_to_order(page, NULL, 0);
 }
 void deferred_split_folio(struct folio *folio, bool partially_mapped);
 
mm/huge_memory.c +0 -7
index 5acca24bbabb..faf5da459a4c 100644
@@ -3653,8 +3653,6 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
 
 		min_order = mapping_min_folio_order(folio->mapping);
 		if (new_order < min_order) {
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
 			ret = -EINVAL;
 			goto out;
 		}
@@ -3986,11 +3984,6 @@ int min_order_for_split(struct folio *folio)
 
 int split_folio_to_list(struct folio *folio, struct list_head *list)
 {
-	int ret = min_order_for_split(folio);
-
-	if (ret < 0)
-		return ret;
-
 	return split_huge_page_to_list_to_order(&folio->page, list, ret);
 }
 
mm/truncate.c +4 -2
index 91eb92a5ce4f..1c15149ae8e9 100644
@@ -194,6 +194,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
 	size_t size = folio_size(folio);
 	unsigned int offset, length;
 	struct page *split_at, *split_at2;
+	unsigned int min_order;
 
 	if (pos < start)
 		offset = start - pos;
@@ -223,8 +224,9 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
 	if (!folio_test_large(folio))
 		return true;
 
+	min_order = mapping_min_folio_order(folio->mapping);
 	split_at = folio_page(folio, PAGE_ALIGN_DOWN(offset) / PAGE_SIZE);
-	if (!try_folio_split(folio, split_at, NULL)) {
+	if (!try_folio_split(folio, split_at, NULL, min_order)) {
 		/*
 		 * try to split at offset + length to make sure folios within
 		 * the range can be dropped, especially to avoid memory waste
@@ -254,7 +256,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
 		 */
 		if (folio_test_large(folio2) &&
 		    folio2->mapping == folio->mapping)
-			try_folio_split(folio2, split_at2, NULL);
+			try_folio_split(folio2, split_at2, NULL, min_order);
 
 		folio_unlock(folio2);
 out:

Best Regards,
Yan, Zi

#9 lore raw
Quoted 52 lines · Zi Yan
Quoted 35 lines · Pankaj Raghav (Samsung)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Quoted 19 lines
Quoted 1 line

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Yep. Let’s hear what Luis and Pankaj will say about this.

Quoted 15 lines
Quoted 15 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

I am not aware of any place in the LBS path where we supply the min_order. truncate_inode_partial_folio() calls try_folio_split(), which takes care of splitting in min_order chunks. So we embedded the min_order in the MM functions that performs the split instead of the caller passing the min_order. Probably, that is why this problem is being exposed now where people are surprised by seeing a large folio even though they asked to split folios to order-0.

Quoted 8 lines

As you concluded, we will not be breaking anything wrt LBS as we just refuse to split if it doesn't match the min_order. The only issue I see is we might be exacerbating ENOMEM errors as we are not splitting as many folios with this change. But the solution for that is simple, add more RAM to the system ;)

Just for clarity, are we talking about changing the behaviour just the try_to_split_thp_page() function or all the split functions in huge_mm.h?

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Other than making folio split more reliable, it seems like to me this bug report shows memory failure doesn't handle LBS folio properly. For example, if the block size <= order-0 page size (this should be always true before LBS), memory failure should expect the large folio is split to order-0, then the poisoned order-0 page should be discarded if it is not dirty. The later access to the block will trigger a major fault.
But with LBS, the block size may be greater than order-0 page size, so the large folio is actually backed by one single block, so memory failure should discard the whole large folio instead of one order-0 page in the large folio. IOW, memory failure should expect to see large folio.

Thanks,
Yang

Quoted 109 lines

WDYT?

include/linux/huge_mm.h +5 -23
index f327d62fc985..e15c3ca07e33 100644
@@ -387,34 +387,16 @@ int folio_split(struct folio *folio, unsigned int new_order, struct page *page,
  * Return: 0: split is successful, otherwise split failed.
  */
 static inline int try_folio_split(struct folio *folio, struct page *page,
-               struct list_head *list)
+               struct list_head *list, unsigned int order)
 {
-       int ret = min_order_for_split(folio);
-
-       if (ret < 0)
-               return ret;
-
-       if (!non_uniform_split_supported(folio, 0, false))
+       if (!non_uniform_split_supported(folio, order, false))
                return split_huge_page_to_list_to_order(&folio->page, list,
-                               ret);
-       return folio_split(folio, ret, page, list);
+                               order);
+       return folio_split(folio, order, page, list);
 }
 static inline int split_huge_page(struct page *page)
 {
-       struct folio *folio = page_folio(page);
-       int ret = min_order_for_split(folio);
-
-       if (ret < 0)
-               return ret;
-
-       /*
-        * split_huge_page() locks the page before splitting and
-        * expects the same page that has been split to be locked when
-        * returned. split_folio(page_folio(page)) cannot be used here
-        * because it converts the page to folio and passes the head
-        * page to be split.
-        */
-       return split_huge_page_to_list_to_order(page, NULL, ret);
+       return split_huge_page_to_list_to_order(page, NULL, 0);
 }
 void deferred_split_folio(struct folio *folio, bool partially_mapped);
 
mm/huge_memory.c +0 -7
index 5acca24bbabb..faf5da459a4c 100644
@@ -3653,8 +3653,6 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
 
                min_order = mapping_min_folio_order(folio->mapping);
                if (new_order < min_order) {
-                       VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-                                    min_order);
                        ret = -EINVAL;
                        goto out;
                }
@@ -3986,11 +3984,6 @@ int min_order_for_split(struct folio *folio)
 
 int split_folio_to_list(struct folio *folio, struct list_head *list)
 {
-       int ret = min_order_for_split(folio);
-
-       if (ret < 0)
-               return ret;
-
        return split_huge_page_to_list_to_order(&folio->page, list, ret);
 }
 
mm/truncate.c +4 -2
index 91eb92a5ce4f..1c15149ae8e9 100644
@@ -194,6 +194,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
        size_t size = folio_size(folio);
        unsigned int offset, length;
        struct page *split_at, *split_at2;
+       unsigned int min_order;
 
        if (pos < start)
                offset = start - pos;
@@ -223,8 +224,9 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
        if (!folio_test_large(folio))
                return true;
 
+       min_order = mapping_min_folio_order(folio->mapping);
        split_at = folio_page(folio, PAGE_ALIGN_DOWN(offset) / PAGE_SIZE);
-       if (!try_folio_split(folio, split_at, NULL)) {
+       if (!try_folio_split(folio, split_at, NULL, min_order)) {
                /*
                 * try to split at offset + length to make sure folios within
                 * the range can be dropped, especially to avoid memory waste
@@ -254,7 +256,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
                 */
                if (folio_test_large(folio2) &&
                    folio2->mapping == folio->mapping)
-                       try_folio_split(folio2, split_at2, NULL);
+                       try_folio_split(folio2, split_at2, NULL, min_order);
 
                folio_unlock(folio2);
 out:

Best Regards,
Yan, Zi

#10 lore raw
Quoted 61 lines · Yang Shi
Quoted 52 lines · Zi Yan
Quoted 35 lines · Pankaj Raghav (Samsung)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Quoted 19 lines
Quoted 1 line

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Yep. Let’s hear what Luis and Pankaj will say about this.

Quoted 15 lines
Quoted 15 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

I am not aware of any place in the LBS path where we supply the min_order. truncate_inode_partial_folio() calls try_folio_split(), which takes care of splitting in min_order chunks. So we embedded the min_order in the MM functions that performs the split instead of the caller passing the min_order. Probably, that is why this problem is being exposed now where people are surprised by seeing a large folio even though they asked to split folios to order-0.

Quoted 8 lines

As you concluded, we will not be breaking anything wrt LBS as we just refuse to split if it doesn't match the min_order. The only issue I see is we might be exacerbating ENOMEM errors as we are not splitting as many folios with this change. But the solution for that is simple, add more RAM to the system ;)

Just for clarity, are we talking about changing the behaviour just the try_to_split_thp_page() function or all the split functions in huge_mm.h?

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 7 lines

Other than making folio split more reliable, it seems like to me this bug report shows memory failure doesn't handle LBS folio properly. For example, if the block size <= order-0 page size (this should be always true before LBS), memory failure should expect the large folio is split to order-0, then the poisoned order-0 page should be discarded if it is not dirty. The later access to the block will trigger a major fault.

Agreed that larger-folio support would be nice in memory-failure code, but I recall some other areas we recently touched that are rather hairy. (something around unmap_poisoned_folio()).

The BUG at hand is that we changed splitting semantics without taking care of the actual users.

Signature · 3 lines
Cheers

David / dhildenb
#11 lore raw
Quoted 71 lines · David Hildenbrand
Quoted 61 lines · Yang Shi
Quoted 52 lines · Zi Yan
Quoted 35 lines · Pankaj Raghav (Samsung)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

We might just need (a), since there is no caller of (b) in kernel, except split_folio_to_order() is used for testing. There might be future uses when kernel wants to convert from THP to mTHP, but it seems that we are not there yet.

Quoted 19 lines
Quoted 1 line

Even better, then maybe selected interfaces could just fail if the min-order contradicts with the request to split to a non-larger (order-0) folio.

Yep. Let’s hear what Luis and Pankaj will say about this.

Quoted 15 lines
Quoted 15 lines

+Luis and Pankaj for their opinions on how LBS is going to use split folio to any order.

Hi Luis and Pankaj,

It seems that bumping split folio order from 0 to mapping_min_folio_order() instead of simply failing the split folio call gives surprises to some callers and causes issues like the one reported by this email. I cannot think of any situation where failing a folio split does not work. If LBS code wants to split, it should supply mapping_min_folio_order(), right? Does such caller exist?

I am not aware of any place in the LBS path where we supply the min_order. truncate_inode_partial_folio() calls try_folio_split(), which takes care of splitting in min_order chunks. So we embedded the min_order in the MM functions that performs the split instead of the caller passing the min_order. Probably, that is why this problem is being exposed now where people are surprised by seeing a large folio even though they asked to split folios to order-0.

Quoted 8 lines

As you concluded, we will not be breaking anything wrt LBS as we just refuse to split if it doesn't match the min_order. The only issue I see is we might be exacerbating ENOMEM errors as we are not splitting as many folios with this change. But the solution for that is simple, add more RAM to the system ;)

Just for clarity, are we talking about changing the behaviour just the try_to_split_thp_page() function or all the split functions in huge_mm.h?

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 7 lines

Other than making folio split more reliable, it seems like to me this bug report shows memory failure doesn't handle LBS folio properly. For example, if the block size <= order-0 page size (this should be always true before LBS), memory failure should expect the large folio is split to order-0, then the poisoned order-0 page should be discarded if it is not dirty. The later access to the block will trigger a major fault.

Quoted 3 lines

Agreed that larger-folio support would be nice in memory-failure code, but I recall some other areas we recently touched that are rather hairy. (something around unmap_poisoned_folio()).

I had been busy on some arm64 stuff, I didn't follow up the recent development too closely, you meant this one?
https://lore.kernel.org/linux-mm/[email protected]/

It seems like we need more work to support large folio for memory failure.

Thanks,
Yang

Quoted 9 lines

The BUG at hand is that we changed splitting semantics without taking care of the actual users.

--
Cheers

David / dhildenb

#12 lore raw
In reply to Zi Yan
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...

		min_order = mapping_min_folio_order(folio->mapping);
		if (new_order < min_order) {
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
			ret = -EINVAL;
			goto out;
		}

...

Quoted 3 lines

WDYT?

I think it should be fine as along as we return an error if someone is trying to split < min_order for file-backed folios.

Quoted 11 lines
include/linux/huge_mm.h +1 -1
index f327d62fc985..e15c3ca07e33 100644
@@ -387,34 +387,16 @@ int folio_split(struct folio *folio, unsigned int new_order, struct page *page,
  * Return: 0: split is successful, otherwise split failed.
  */
 static inline int try_folio_split(struct folio *folio, struct page *page,
-		struct list_head *list)
+		struct list_head *list, unsigned int order)
 {
Signature · 1 line
Pankaj
reviewer
#13 lore raw
Quoted 31 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...

		min_order = mapping_min_folio_order(folio->mapping);
		if (new_order < min_order) {
mm/huge_memory.c +0 -2
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
			ret = -EINVAL;
			goto out;
		}

...

Quoted 3 lines

WDYT?

I think it should be fine as along as we return an error if someone is trying to split < min_order for file-backed folios.

Quoted 11 lines

include/linux/huge_mm.h int folio_split(struct folio *folio, unsigned int new_order, struct page *page, · line 391

Quoted 11 lines
include/linux/huge_mm.h +1 -1
index f327d62fc985..e15c3ca07e33 100644
@@ -387,34 +387,16 @@ int folio_split(struct folio *folio, unsigned int new_order, struct page *page,
  * Return: 0: split is successful, otherwise split failed.
  */
 static inline int try_folio_split(struct folio *folio, struct page *page,
-		struct list_head *list)
+		struct list_head *list, unsigned int order)
 {

OK, I will send a proper patch to fix this. Thanks.

Best Regards,
Yan, Zi

#14 lore raw
Quoted 33 lines · Zi Yan
Quoted 31 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...

		min_order = mapping_min_folio_order(folio->mapping);
		if (new_order < min_order) {
mm/huge_memory.c +0 -2
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
			ret = -EINVAL;
			goto out;
		}

...

Quoted 3 lines

WDYT?

I think it should be fine as along as we return an error if someone is trying to split < min_order for file-backed folios.

Quoted 13 lines
Quoted 11 lines

include/linux/huge_mm.h int folio_split(struct folio *folio, unsigned int new_order, struct page *page, · line 391

Quoted 11 lines
include/linux/huge_mm.h +1 -1
index f327d62fc985..e15c3ca07e33 100644
@@ -387,34 +387,16 @@ int folio_split(struct folio *folio, unsigned int new_order, struct page *page,
   * Return: 0: split is successful, otherwise split failed.
   */
  static inline int try_folio_split(struct folio *folio, struct page *page,
-		struct list_head *list)
+		struct list_head *list, unsigned int order)
  {

OK, I will send a proper patch to fix this. Thanks.

Thanks!

Signature · 3 lines
Cheers

David / dhildenb
reviewer
#15 lore raw
In reply to Zi Yan
Quoted 33 lines · Zi Yan
Quoted 31 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...

		min_order = mapping_min_folio_order(folio->mapping);
		if (new_order < min_order) {
mm/huge_memory.c +0 -2
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
			ret = -EINVAL;
			goto out;
		}

...

Quoted 3 lines

WDYT?

I think it should be fine as along as we return an error if someone is trying to split < min_order for file-backed folios.

<snip>

Quoted 2 lines

OK, I will send a proper patch to fix this. Thanks.

#syz test: [email protected]:x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci

Best Regards,
Yan, Zi

author syzbot
#16 lore raw
syzbot tried to test the proposed patch but the build/boot failed:

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo [email protected]:x-y-z/linux-dev.git/fix_split_page_min_order-for-kernelci: failed to run ["git" "fetch" "--force" "c604b0b58bbe3045b4698c8a85066936c1abd842" "fix_split_page_min_order-for-kernelci"]: exit status 128 Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Tested on:

commit:         [unknown 
git tree:       [email protected]:x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2ae34a0711ff2f1
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056

compiler:
userspace arch: arm64

Note: no patches were applied.

reviewer
#17 lore raw
In reply to Zi Yan
Quoted 32 lines · Zi Yan
Quoted 30 lines · Zi Yan
Quoted 28 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...

		min_order = mapping_min_folio_order(folio->mapping);
		if (new_order < min_order) {
mm/huge_memory.c +0 -2
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
			ret = -EINVAL;
			goto out;
		}

...

Quoted 3 lines

WDYT?

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

I think it should be fine as along as we return an error if someone is trying to split < min_order for file-backed folios.

<snip>

Quoted 2 lines

OK, I will send a proper patch to fix this. Thanks.

Let me try again:

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci

--
Best Regards,
Yan, Zi

author syzbot
#18 lore raw
syzbot has tested the proposed patch but the reproducer is still triggering an issue: lost connection to test machine

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

#19 lore raw

Hi, Zi Yan,

Quoted 17 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
Quoted 2 lines

Note: no patches were applied.

My hunch is that
https://github.com/x-y-z/linux-dev.git
fix_split_page_min_order-for-kernelci
alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

thanks,
-jane

reviewer
#20 lore raw
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 5 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

Best Regards,
Yan, Zi

reviewer
#21 lore raw
Quoted 43 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

--
Best Regards,
Yan, Zi

author syzbot
#22 lore raw
syzbot has tested the proposed patch but the reproducer is still triggering an issue: lost connection to test machine

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         9cfbc23b mm/memory-failure: improve large block size f..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=118ae05b980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

#23 lore raw
In reply to Zi Yan
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

thanks,
-jane

Quoted 4 lines

--
Best Regards,
Yan, Zi

reviewer
#24 lore raw
Quoted 58 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

Quoted 7 lines

There is a bug here,

		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

BTW, do you mind explaining why soft offline case does not want to split? Like memory failure case, splitting it would make other after-split folios available.

Thanks.

Best Regards,
Yan, Zi

#25 lore raw
Quoted 66 lines · Zi Yan
Quoted 64 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---
Quoted 7 lines
Quoted 1 line

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

BTW, do you mind explaining why soft offline case does not want to split? Like memory failure case, splitting it would make other after-split folios available.

That's exactly what I think. Let's wait for Miaohe, not sure if he has other concern.

thanks,
-jane

Quoted 5 lines

Thanks.

Best Regards,
Yan, Zi

maintainer
#26 lore raw
Quoted 65 lines · On 2025/10/3 1:47, [email protected] wrote:
Quoted 62 lines · Zi Yan
Quoted 60 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8 userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough.  Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:
[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

        if (try_to_split_thp_page(p, new_order, false) || new_order) { res = -EHWPOISON;
            kill_procs_now(p, pfn, flags, folio);  <---

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken:  folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

Sorry for late. I just got back from my vacation. :)

Quoted 5 lines
Quoted 3 lines

BTW, do you mind explaining why soft offline case does not want to split? Like memory failure case, splitting it would make other after-split folios available.

That's exactly what I think.  Let's wait for Miaohe, not sure if he has other concern.

It might be because even if split is skipped, the folio is still accessible (thus available) from user sapce and premature split might lead to potential performance loss. But it's fine to me to split folio first in soft offline case. No strong opinion.

Thanks both.
.

reviewer
#27 lore raw
Quoted 81 lines · Miaohe Lin
Quoted 65 lines · On 2025/10/3 1:47, [email protected] wrote:
Quoted 62 lines · Zi Yan
Quoted 60 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8 userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough.  Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:
[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

        if (try_to_split_thp_page(p, new_order, false) || new_order) { res = -EHWPOISON;
            kill_procs_now(p, pfn, flags, folio);  <---

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken:  folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

Sorry for late. I just got back from my vacation. :)

Quoted 4 lines
Quoted 3 lines

BTW, do you mind explaining why soft offline case does not want to split? Like memory failure case, splitting it would make other after-split folios available.

Quoted 5 lines
Quoted 1 line

That's exactly what I think.  Let's wait for Miaohe, not sure if he has other concern.

It might be because even if split is skipped, the folio is still accessible (thus available) from user sapce and premature split might lead to potential performance loss. But it's fine to me to split folio first in soft offline case. No strong opinion.

Thanks for the explanation. I will add a comment about this. We can always do the split at soft offline when we find it useful. I will send the patches out.

--
Best Regards,
Yan, Zi

#28 lore raw
In reply to Zi Yan
Quoted 62 lines · Zi Yan
Quoted 60 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

Quoted 7 lines
Quoted 5 lines
		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

Forgot to ask, even with your current patch, after splitting at min_order, the old 'folio' should be at min_order as well, just not necessarily the one where the raw hwpoisoned sub-page resides, right? If yes, then 1) I am wondering about the value of the min_order? 2) perhaps the syzbot test need to reduce the number of fork()'ing,
as with each MADV_HWPOISON inject, one page cache page will be lost and stuck in the page cache, the difference is the size of the page cache page and the number of pages.

thanks,
-jane

reviewer
#29 lore raw
Quoted 67 lines · On 2 Oct 2025, at 13:54, [email protected] wrote:
Quoted 66 lines · Zi Yan
Quoted 64 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

Forgot to ask, even with your current patch, after splitting at min_order, the old 'folio' should be at min_order as well, just not necessarily the one where the raw hwpoisoned sub-page resides, right?

Yes.

Quoted 1 line

If yes, then 1) I am wondering about the value of the min_order? 2) perhaps

I think min_order depends on the filesystem config. It can be like 2 (16KB) or 4 (64KB). Based on the reproducer[1], it seems that block size is set to 64KB (see ioctl$BLKBSZSET arg).

[1] https://syzkaller.appspot.com/text?tag=ReproC&x=1361627c580000

Quoted 2 lines

the syzbot test need to reduce the number of fork()'ing,
as with each MADV_HWPOISON inject, one page cache page will be lost and stuck in the page cache, the difference is the size of the page cache page and the number of pages.

Right. the lost page size is amplified by min_order.

BTW, I do not see fork or loop in the above reproducer, I wonder why the test went OOM.

Best Regards,
Yan, Zi

#30 lore raw
Quoted 84 lines · Zi Yan
Quoted 67 lines · On 2 Oct 2025, at 13:54, [email protected] wrote:
Quoted 66 lines · Zi Yan
Quoted 64 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 48 lines · Zi Yan
Quoted 46 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 4 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure-for-kernelci

There is a bug here,

		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

Thank you for pointing it out. Let me fix it and let syzbot test it again.

Forgot to ask, even with your current patch, after splitting at min_order, the old 'folio' should be at min_order as well, just not necessarily the one where the raw hwpoisoned sub-page resides, right?

Yes.

Quoted 1 line

If yes, then 1) I am wondering about the value of the min_order? 2) perhaps

I think min_order depends on the filesystem config. It can be like 2 (16KB) or 4 (64KB). Based on the reproducer[1], it seems that block size is set to 64KB (see ioctl$BLKBSZSET arg).

[1] https://syzkaller.appspot.com/text?tag=ReproC&x=1361627c580000

Quoted 7 lines
Quoted 2 lines

the syzbot test need to reduce the number of fork()'ing,
as with each MADV_HWPOISON inject, one page cache page will be lost and stuck in the page cache, the difference is the size of the page cache page and the number of pages.

Right. the lost page size is amplified by min_order.

BTW, I do not see fork or loop in the above reproducer, I wonder why the test went OOM.

You're right, the test itself doesn't fork. I saw copy_process() in the oom-kill call trace, I spoke too soon.

The tests appear to be running in a tight loop, can't tell the number of iterations or duration. The console has logged "5039 pages hwpoisoned",
likely with each MADV_HWPOISON injection, a 64K folio is lost. So either that means 5039 * 64K, or just 5039 base pages, it's a lot memory lost and become unusable, until zone normal dipped below the min watermark.

I think the test might need to be adjusted.
Option 1, reduce the test runs accordingly, eg, if the blocksize is 4K, maybe allow more test runs, Option 2, add unpoison operation after poison.

Not sure how do we go about that. What do others think?

thanks,
-jane

Quoted 4 lines

Best Regards,
Yan, Zi

reviewer
#31 lore raw
In reply to [email protected]
Quoted 56 lines · On 2 Oct 2025, at 1:23, [email protected] wrote:
Quoted 55 lines · Zi Yan
Quoted 50 lines · Zi Yan
Quoted 23 lines · On 1 Oct 2025, at 19:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 19 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

Thank you for looking into this.

Quoted 3 lines

My hunch is that
https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in

Yes, it only has the first patch, which fails a split if it cannot be split to the intended order (order-0 in this case).

Quoted 4 lines

the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

[  200.378989][T18221] Memory failure: 0x124d30: recovery action for unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

That is my understanding too. Thanks for the confirmation.

Quoted 5 lines

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

So that in the madvise HWPOISON cases, large huge pages are splitted to smaller huge pages, and most of them remain usable in the page cache.

Yep, I am going to incorporate your suggestion as the second patch and make syzbot check it again.

<snip>

Quoted 8 lines

There is a bug here,

		if (try_to_split_thp_page(p, new_order, false) || new_order) {
			res = -EHWPOISON;
			kill_procs_now(p, pfn, flags, folio);  <---

If try_to_split_thp_page() succeeded on min_order, 'folio' should be retaken: folio = page_folio(page) before moving on to kill_procs_now().

#syz test: https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure_v2-for-kernelci

Best Regards,
Yan, Zi

author syzbot
#32 lore raw
syzbot has tested the proposed patch but the reproducer is still triggering an issue: lost connection to test machine

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         3cb04835 mm/memory-failure: improve large block size f..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order_and_opt_memory_failure_v2-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=1428cee2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64

Note: no patches were applied.

#33 lore raw
In reply to [email protected]
Quoted 29 lines · On 02.10.25 01:58, [email protected] wrote:

Hi, Zi Yan,

Quoted 17 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine

Tested on:

commit:         d8795075 mm/huge_memory: do not change split_huge_page..
git tree:       https://github.com/x-y-z/linux-dev.git fix_split_page_min_order-for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce96e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=714d45b6135c308e
dashboard link: https://syzkaller.appspot.com/bug?extid=e6367ea2fdab6ed46056
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
userspace arch: arm64
Quoted 2 lines

Note: no patches were applied.

My hunch is that

     https://github.com/x-y-z/linux-dev.git

fix_split_page_min_order-for-kernelci
alone is not enough. Perhaps on ARM64, the page cache pages of /dev/nullb0 in the test case are probably with min_order > 0, therefore THP split fails, as the console message show:

Quoted 8 lines
[  200.378989][T18221] Memory failure: 0x124d30: recovery action for

unsplit thp: Failed

With lots of poisoned THP pages stuck in the page cache, OOM could trigger too soon.

I think it's worth to try add the additional changes I suggested earlier -
https://lore.kernel.org/lkml/[email protected]/

I think that makes sense in this case. I earlier said that I don't think even splitting makes sense in this case, but as you say we can actually at least allow for reclaiming the remainder of the folio.

Even though we cannot proceed in handling the remaining large folio later on.

Signature · 3 lines
Cheers

David / dhildenb
#34 lore raw
In reply to Pankaj Raghav (Samsung)
Quoted 24 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...

		min_order = mapping_min_folio_order(folio->mapping);
		if (new_order < min_order) {
(quoted diff) +0 -2
-			VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u",
-				     min_order);
			ret = -EINVAL;
			goto out;
		}
Quoted 1 line

...

Then the user process will get a SIGBUS indicting the entire huge page at higher order -

                folio_set_has_hwpoisoned(folio);
                if (try_to_split_thp_page(p, false) < 0) {
                        res = -EHWPOISON;
                        kill_procs_now(p, pfn, flags, folio);
                        put_page(p);
                        action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
                        goto unlock_mutex;
                }
                VM_BUG_ON_PAGE(!page_count(p), p);
                folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M-F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -2
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                 * page is a valid handlable page.
                 */
                folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                        res = -EHWPOISON;
                        kill_procs_now(p, pfn, flags, folio);
                        put_page(p);
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                        goto unlock_mutex;
                }
                VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
        }
 

thanks,
-jane

#35 lore raw
Quoted 61 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 12 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
        min_order = mapping_min_folio_order(folio->mapping);
        if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min-
order: %u",
-                     min_order);
            ret = -EINVAL;
            goto out;
        }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order -
                folio_set_has_hwpoisoned(folio);
                if (try_to_split_thp_page(p, false) < 0) {
                        res = -EHWPOISON;
                        kill_procs_now(p, pfn, flags, folio); put_page(p);
                        action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                }
                VM_BUG_ON_PAGE(!page_count(p), p);
                folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                  * page is a valid handlable page.
                  */
                 folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio);
                         put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                         goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
         }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +8 -4
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
 static int try_to_split_thp_page(struct page *page, bool release)
 {
        int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
        lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
        unlock_page(page);
 
        if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
        folio_unlock(folio);
 
        if (folio_test_large(folio)) {
+               int ret;
                /*
                 * The flag must be set after the refcount is bumped
                 * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                 * page is a valid handlable page.
                 */
                folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                        res = -EHWPOISON;
                        kill_procs_now(p, pfn, flags, folio);
                        put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                        goto unlock_mutex;
                }
                VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
        }
 
        /*
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
        };
 
        if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                        pr_info("%#lx: thp split failed\n", pfn);
                        return -EBUSY;
                }

thanks,
-jane

#36 lore raw
Quoted 128 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 61 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 12 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
        min_order = mapping_min_folio_order(folio->mapping);
        if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min-
order: %u",
-                     min_order);
            ret = -EINVAL;
            goto out;
        }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order - folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio); put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +2 -1
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, 
 struct page *p,
  static int try_to_split_thp_page(struct page *page, bool release)
  {
         int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
         lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
         unlock_page(page);
 

        if (ret && release)

mm/memory-failure.c +6 -3
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
         folio_unlock(folio);
 
         if (folio_test_large(folio)) {
+               int ret;
                 /*
                  * The flag must be set after the refcount is bumped
                  * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                  * page is a valid handlable page.
                  */
                 folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio);
                         put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                         goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
         }
 
         /*
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page 
 *page)
         };
 
         if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                         pr_info("%#lx: thp split failed\n", pfn);
                         return -EBUSY;
Quoted 1 line

                }

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

thanks,
-jane

Quoted 6 lines

thanks,
-jane

reviewer
#37 lore raw
Quoted 120 lines · On 29 Sep 2025, at 14:23, [email protected] wrote:
Quoted 119 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 60 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 11 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
        min_order = mapping_min_folio_order(folio->mapping);
        if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u", -                     min_order);
            ret = -EINVAL;
            goto out;
        }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order - folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio); put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +6 -3
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
  static int try_to_split_thp_page(struct page *page, bool release)
  {
         int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
         lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
         unlock_page(page);
 
         if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
         folio_unlock(folio);
 
         if (folio_test_large(folio)) {
+               int ret;
                 /*
                  * The flag must be set after the refcount is bumped
                  * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                  * page is a valid handlable page.
                  */
                 folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio);
                         put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                         goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
         }
 
         /*
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
         };
 
Quoted 8 lines

mm/memory-failure.c static int soft_offline_in_use_page(struct page *page) · line 2628

Quoted 7 lines
mm/memory-failure.c +2 -1
         if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                         pr_info("%#lx: thp split failed\n", pfn);
                         return -EBUSY;
                 }

What you are proposing here is basically split_huge_page_to_min_order(). I can add that as a second patch.

Quoted 1 line

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

OK. I can do that too.

Thank you for the input.

Best Regards,
Yan, Zi

#38 lore raw
Quoted 131 lines · Zi Yan
Quoted 120 lines · On 29 Sep 2025, at 14:23, [email protected] wrote:
Quoted 119 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 60 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 11 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
        min_order = mapping_min_folio_order(folio->mapping);
        if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u", -                     min_order);
            ret = -EINVAL;
            goto out;
        }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order -
                 folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio); put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +6 -3
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
   static int try_to_split_thp_page(struct page *page, bool release)
   {
          int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
          lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
          unlock_page(page);
 
          if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
          folio_unlock(folio);
 
          if (folio_test_large(folio)) {
+               int ret;
                  /*
                   * The flag must be set after the refcount is bumped
                   * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
          /*
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
          };
 
Quoted 8 lines

mm/memory-failure.c static int soft_offline_in_use_page(struct page *page) · line 2628

Quoted 7 lines
mm/memory-failure.c +2 -1
          if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                          pr_info("%#lx: thp split failed\n", pfn);
                          return -EBUSY;
                  }
Quoted 9 lines

What you are proposing here is basically split_huge_page_to_min_order(). I can add that as a second patch.

Quoted 1 line

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

OK. I can do that too.

Thank you for the input.

That'll be great! Thank you!

-jane

Quoted 3 lines

Best Regards,
Yan, Zi

maintainer
#39 lore raw
In reply to [email protected]
Quoted 122 lines · On 2025/9/30 2:23, [email protected] wrote:
Quoted 119 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 60 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 11 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
        min_order = mapping_min_folio_order(folio->mapping);
        if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u", -                     min_order);
            ret = -EINVAL;
            goto out;
        }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order - folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio); put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +6 -3
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
   static int try_to_split_thp_page(struct page *page, bool release)
   {
          int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
          lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
          unlock_page(page);
 
          if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
          folio_unlock(folio);
 
          if (folio_test_large(folio)) {
+               int ret;
                  /*
                   * The flag must be set after the refcount is bumped
                   * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
          /*
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
          };
 
Quoted 9 lines

mm/memory-failure.c static int soft_offline_in_use_page(struct page *page) · line 2628

Quoted 7 lines
mm/memory-failure.c +2 -1
          if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                          pr_info("%#lx: thp split failed\n", pfn);
                          return -EBUSY;
                  }

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

I might be miss something but why we have to split it? Could we migrate the whole thp or folio with min_order instead?

Thanks.
.

#40 lore raw
Quoted 133 lines · Miaohe Lin
Quoted 122 lines · On 2025/9/30 2:23, [email protected] wrote:
Quoted 119 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 60 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 11 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
        min_order = mapping_min_folio_order(folio->mapping);
        if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u", -                     min_order);
            ret = -EINVAL;
            goto out;
        }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order -
                 folio_set_has_hwpoisoned(folio);
                 if (try_to_split_thp_page(p, false) < 0) {
                         res = -EHWPOISON;
                         kill_procs_now(p, pfn, flags, folio); put_page(p);
                         action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                 }
                 VM_BUG_ON_PAGE(!page_count(p), p);
                 folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +6 -3
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
   static int try_to_split_thp_page(struct page *page, bool release)
   {
          int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
          lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
          unlock_page(page);
 
          if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
          folio_unlock(folio);
 
          if (folio_test_large(folio)) {
+               int ret;
                  /*
                   * The flag must be set after the refcount is bumped
                   * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                   * page is a valid handlable page.
                   */
                  folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio);
                          put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                          goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
          }
 
          /*
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
          };
 
Quoted 9 lines

mm/memory-failure.c static int soft_offline_in_use_page(struct page *page) · line 2628

Quoted 7 lines
mm/memory-failure.c +2 -1
          if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                          pr_info("%#lx: thp split failed\n", pfn);
                          return -EBUSY;
                  }

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

Quoted 1 line

I might be miss something but why we have to split it? Could we migrate the whole thp or folio with min_order instead?

The soft offline code was originally written with the assumption that only 1 base page will be offlined. With the recent introduction of min_order, it might quietly offline multiple pages, is that a desirable thing? Recently we see patch aimed at not soft offlining hugetlb page while okay to offline 4K page though.

What do you think?

thanks,
-jane

Quoted 3 lines

Thanks.
.

maintainer
#41 lore raw
Quoted 136 lines · On 2025/9/30 12:35, [email protected] wrote:
Quoted 133 lines · Miaohe Lin
Quoted 131 lines · On 2025/9/30 2:23, [email protected] wrote:
Quoted 117 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 60 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 11 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
         min_order = mapping_min_folio_order(folio->mapping);
         if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u", -                     min_order);
             ret = -EINVAL;
             goto out;
         }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order - folio_set_has_hwpoisoned(folio);
                  if (try_to_split_thp_page(p, false) < 0) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio); put_page(p);
                          action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
                  folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                    * page is a valid handlable page.
                    */
                   folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                           res = -EHWPOISON;
                           kill_procs_now(p, pfn, flags, folio);
                           put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                           goto unlock_mutex;
                   }
                   VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
           }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +6 -3
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
    static int try_to_split_thp_page(struct page *page, bool release)
    {
           int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
           lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
           unlock_page(page);
 
           if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
           folio_unlock(folio);
 
           if (folio_test_large(folio)) {
+               int ret;
                   /*
                    * The flag must be set after the refcount is bumped
                    * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                    * page is a valid handlable page.
                    */
                   folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                           res = -EHWPOISON;
                           kill_procs_now(p, pfn, flags, folio);
                           put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                           goto unlock_mutex;
                   }
                   VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
           }
 
           /*

mm/memory-failure.c static int soft_offline_in_use_page(struct page *page) · line 2628

Quoted 9 lines
mm/memory-failure.c +2 -1
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
           };
 
           if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                           pr_info("%#lx: thp split failed\n", pfn);
                           return -EBUSY;
                   }

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

Quoted 3 lines
Quoted 1 line

I might be miss something but why we have to split it? Could we migrate the whole thp or folio with min_order instead?

The soft offline code was originally written with the assumption that only 1 base page will be offlined.

Yes, only page corresponding to parameter @pfn of soft_offline_page() will be offlined.

Quoted 2 lines

With the recent introduction of min_order, it might quietly offline multiple pages, is that a desirable thing?

I don't think so. Even if try_to_split_thp_page splits folio into smaller one with min_order, page_handle_poison() will put back the folio into buddy after migrate_pages, set the hwpoisoned flag to raw error page and hold the extra refcnt. So only raw error page will be offlined while other sub-pages will be put back into buddy. Or am I miss something?

Thanks.
.

#42 lore raw
Quoted 144 lines · Miaohe Lin
Quoted 136 lines · On 2025/9/30 12:35, [email protected] wrote:
Quoted 133 lines · Miaohe Lin
Quoted 131 lines · On 2025/9/30 2:23, [email protected] wrote:
Quoted 117 lines · On 9/29/2025 10:49 AM, [email protected] wrote:
Quoted 60 lines · On 9/29/2025 10:29 AM, [email protected] wrote:
Quoted 14 lines · Pankaj Raghav (Samsung)
Quoted 6 lines

I want to change all the split functions in huge_mm.h and provide mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().

Something like below:

Quoted 7 lines

1. no split function will change the given order;
2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order is smaller than mapping_min_folio_order().

In this way, for an LBS folio that cannot be split to order 0, split functions will return -EINVAL to tell caller that the folio cannot be split. The caller is supposed to handle the split failure.

Quoted 11 lines

IIUC, we will remove warn on once but just return -EINVAL in __folio_split() function if new_order < min_order like this:
...
         min_order = mapping_min_folio_order(folio->mapping);
         if (new_order < min_order) {
-            VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u", -                     min_order);
             ret = -EINVAL;
             goto out;
         }
...

Then the user process will get a SIGBUS indicting the entire huge page at higher order -
                  folio_set_has_hwpoisoned(folio);
                  if (try_to_split_thp_page(p, false) < 0) {
                          res = -EHWPOISON;
                          kill_procs_now(p, pfn, flags, folio); put_page(p);
                          action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex;
                  }
                  VM_BUG_ON_PAGE(!page_count(p), p);
                  folio = page_folio(p);

the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.

How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?

mm/memory-failure.c +3 -1
index a24806bb8e82..342c81edcdd9 100644
@@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
                    * page is a valid handlable page.
                    */
                   folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                           res = -EHWPOISON;
                           kill_procs_now(p, pfn, flags, folio);
                           put_page(p);

mm/memory-failure.c int memory_failure(unsigned long pfn, int flags)

Quoted 8 lines
mm/memory-failure.c +0 -2
@@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
                           goto unlock_mutex;
                   }
                   VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
           }
 
 thanks,
-jane

Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.

mm/memory-failure.c +6 -3
index a24806bb8e82..2bfa05acae65 100644
@@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
    static int try_to_split_thp_page(struct page *page, bool release)
    {
           int ret;
+       int new_order = min_order_for_split(page_folio(page));
 
           lock_page(page);
-       ret = split_huge_page(page);
+       ret = split_huge_page_to_list_to_order(page, NULL, new_order);
           unlock_page(page);
 
           if (ret && release)
@@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
           folio_unlock(folio);
 
           if (folio_test_large(folio)) {
+               int ret;
                   /*
                    * The flag must be set after the refcount is bumped
                    * otherwise it may race with THP split.
@@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
                    * page is a valid handlable page.
                    */
                   folio_set_has_hwpoisoned(folio);
-               if (try_to_split_thp_page(p, false) < 0) {
+               ret = try_to_split_thp_page(p, false);
+               folio = page_folio(p);
+               if (ret < 0 || folio_test_large(folio)) {
                           res = -EHWPOISON;
                           kill_procs_now(p, pfn, flags, folio);
                           put_page(p);
@@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
                           goto unlock_mutex;
                   }
                   VM_BUG_ON_PAGE(!page_count(p), p);
-               folio = page_folio(p);
           }
 
           /*

mm/memory-failure.c static int soft_offline_in_use_page(struct page *page) · line 2628

Quoted 9 lines
mm/memory-failure.c +2 -1
@@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
           };
 
           if (!huge && folio_test_large(folio)) {
-               if (try_to_split_thp_page(page, true)) {
+               if ((try_to_split_thp_page(page, true)) ||
+                       folio_test_large(page_folio(page))) {
                           pr_info("%#lx: thp split failed\n", pfn);
                           return -EBUSY;
                   }

In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...

Quoted 3 lines
Quoted 1 line

I might be miss something but why we have to split it? Could we migrate the whole thp or folio with min_order instead?

The soft offline code was originally written with the assumption that only 1 base page will be offlined.

Yes, only page corresponding to parameter @pfn of soft_offline_page() will be offlined.

Quoted 1 line
Quoted 6 lines
Quoted 1 line

With the recent introduction of min_order, it might quietly offline multiple pages, is that a desirable thing?

I don't think so. Even if try_to_split_thp_page splits folio into smaller one with min_order, page_handle_poison() will put back the folio into buddy after migrate_pages, set the hwpoisoned flag to raw error page and hold the extra refcnt. So only raw error page will be offlined while other sub-pages will be put back into buddy. Or am I miss something?

The thing is that the non-poisoned subpages are also migrated away, they're no longer available for the user process.

thanks,
-jane

Quoted 3 lines

Thanks.
.