mm/migrate: fix softlockup in do_pages_move() with huge page arrays
Subsystems (3)
PATCH v2 1/1 mm/migrate: fix softlockup in do_pages_move() with huge page arrays
From: Shao Mingyin <[email protected]>
mm/migrate: fix softlockup in do_pages_move() with huge page arrays
do_pages_move() walks the array one page at a time. An entry naming the node its page is already on is never queued, so the loop runs without a voluntary preemption point on a non-preemptible kernel; the existing cond_resched() calls in the migration code are only reached after a folio has been queued. nr_pages comes straight from the syscall.
A 6.6.60 x86_64 kernel with CONFIG_PREEMPT_NONE=y and CONFIG_NUMA=y reproduces this under QEMU TCG: 50 million entries pointing at a page already on the target node keep the CPU in do_pages_move() for 42.9 s and trip the softlockup watchdog; with this patch the same call completes in 44.3 s without a softlockup.
Add cond_resched() so that long calls yield periodically. do_pages_stat() had the same problem; it was fixed by 8e934ab44389. In current mainline only alpha, hexagon and classic m68k can select PREEMPT_NONE and they cannot enable CONFIG_NUMA, so this mainly targets pre-v7.0 stable kernels.
---
Changes in v2:
- describe the reproduction and the code path, as requested by David Hildenbrand; no code change
- correct the do_pages_stat() reference (fixed by 8e934ab44389)
mm/migrate.c | 2 ++ 1 file changed, 2 insertions(+)
mm/migrate.c +2 -0
@@ -2372,6 +2372,8 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,const void __user *p;int node; +cond_resched (); + err = -EFAULT ;if (in_compat_syscall ()) {compat_uptr_t cp;
David Hildenbrand (Arm)
maintainerQuoted 16 lines · On 11/8/26 07:28, [email protected] wrote:
From: Shao Mingyin <[email protected]>
mm/migrate: fix softlockup in
do_pages_move()with huge page arrays
do_pages_move()walks the array one page at a time. An entry naming the node its page is already on is never queued, so the loop runs without a voluntary preemption point on a non-preemptible kernel; the existingcond_resched()calls in the migration code are only reached after a folio has been queued.nr_pagescomes straight from the syscall.A 6.6.60
x86_64kernel withCONFIG_PREEMPT_NONE=yandCONFIG_NUMA=yreproduces this under QEMU TCG: 50 million entries pointing at a page already on the target node keep the CPU indo_pages_move()for 42.9 s and trip the softlockup watchdog; with this patch the same call completes in 44.3 s without a softlockup.
Quoted 5 lines
Add
cond_resched()so that long calls yield periodically.do_pages_stat()had the same problem; it was fixed by8e934ab44389. In current mainline only alpha, hexagon and classic m68k can selectPREEMPT_NONEand they cannot enableCONFIG_NUMA, so this mainly targets pre-v7.0 stable kernels.
I hat that we have to care about this, and I'll probably increasingly hard push back against such effective stable-only fixes in the future.
In particular if it wasn't even encountered in practice but required a QEMU TCG instance to even trigger it ...
Signature · 3 lines
Cheers, David
Hi David,
fair enough -- and your reading is correct: preempt=none is unselectable under PREEMPT_DYNAMIC, and the arches that can still pick PREEMPT_NONE have no NUMA, so mainline cannot reach this path.
I was aiming at the 6.6 LTS configs that shipped PREEMPT_NONE + NUMA: two lines of cond_resched(), no behaviour change, same as do_pages_stat() got in 8e934ab44389. If you and Andrew would rather not carry a stable-only fix, just say so and I will withdraw it.
Thanks,
Shao
David Hildenbrand (Arm)
maintainerQuoted 10 lines · On 11/9/26 13:33, [email protected] wrote:
Hi David,
fair enough -- and your reading is correct: preempt=none is unselectable under
PREEMPT_DYNAMIC, and the arches that can still pickPREEMPT_NONEhave no NUMA, so mainline cannot reach this path.I was aiming at the 6.6 LTS configs that shipped
PREEMPT_NONE+ NUMA: two lines ofcond_resched(), no behaviour change, same asdo_pages_stat()got in8e934ab44389. If you and Andrew would rather not carry a stable-only fix, just say so and I will withdraw it.
I think this one will be the last ones where we do that and don't really have a real workload run into it.
It's not a good use of our time and it doesn't make upstream any better :)
Signature · 3 lines
Cheers, David
Quoted 9 lines · On Sun, 08 Nov 2026 14:28:31 +0800, [email protected] wrote:
mm/migrate: fix softlockup in
do_pages_move()with huge page arrays
do_pages_move()walks the array one page at a time. An entry naming the node its page is already on is never queued, so the loop runs without a voluntary preemption point on a non-preemptible kernel; the existingcond_resched()calls in the migration code are only reached after a folio has been queued.nr_pagescomes straight from the syscall.[...]
Applied, thanks!
tree: mm/core.git
branch: migrate-7.5.misc
Applied patches will appear soon in mm-next, followed by linux-next.
Please report any outstanding bugs that were missed during review, so we can either drop the patch series or decide how to fix it up.
It is encouraged to provide Acked-bys, Reviewed-bys, and Tested-bys even though the patches have already been applied. If possible, patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. Further, this is not a guarantee that the patches will go upstream. If in doubt, please check the listed branch.
[1/1] mm/migrate: fix softlockup in do_pages_move() with huge page arrays
https://git.kernel.org/mm/core/c/e200153a
Signature · 3 lines
Cheers, David
Quoted 30 lines · EST,
From: Shao Mingyin <[email protected]>
mm/migrate: fix softlockup in
do_pages_move()with huge page arrays
do_pages_move()walks the array one page at a time. An entry naming the node its page is already on is never queued, so the loop runs without a voluntary preemption point on a non-preemptible kernel; the existingcond_resched()calls in the migration code are only reached after a folio has been queued.nr_pagescomes straight from the syscall.A 6.6.60
x86_64kernel withCONFIG_PREEMPT_NONE=yandCONFIG_NUMA=yreproduces this under QEMU TCG: 50 million entries pointing at a page already on the target node keep the CPU indo_pages_move()for 42.9 s and trip the softlockup watchdog; with this patch the same call completes in 44.3 s without a softlockup.Add
cond_resched()so that long calls yield periodically.do_pages_stat()had the same problem; it was fixed by8e934ab44389. In current mainline only alpha, hexagon and classic m68k can selectPREEMPT_NONEand they cannot enableCONFIG_NUMA, so this mainly targets pre-v7.0 stable kernels.Fixes a49bd4d71637 ("mm, numa: rework do_pages_move")Signed-off-by Shao Mingyin <[email protected]>---
Changes in v2:
- describe the reproduction and the code path, as requested by David Hildenbrand; no code change
- correct thedo_pages_stat()reference (fixed by8e934ab44389)
Quoted 5 lines
mm/migrate.c | 2 ++ 1 file changed, 2 insertions(+)
Signature · 2 lines
Best Regards, Yan, Zi
Quoted 22 lines · On Sun, Nov 08, 2026 at 02:28:31PM +0800, [email protected] wrote:
From: Shao Mingyin <[email protected]>
mm/migrate: fix softlockup in
do_pages_move()with huge page arrays
do_pages_move()walks the array one page at a time. An entry naming the node its page is already on is never queued, so the loop runs without a voluntary preemption point on a non-preemptible kernel; the existingcond_resched()calls in the migration code are only reached after a folio has been queued.nr_pagescomes straight from the syscall.A 6.6.60
x86_64kernel withCONFIG_PREEMPT_NONE=yandCONFIG_NUMA=yreproduces this under QEMU TCG: 50 million entries pointing at a page already on the target node keep the CPU indo_pages_move()for 42.9 s and trip the softlockup watchdog; with this patch the same call completes in 44.3 s without a softlockup.Add
cond_resched()so that long calls yield periodically.do_pages_stat()had the same problem; it was fixed by8e934ab44389. In current mainline only alpha, hexagon and classic m68k can selectPREEMPT_NONEand they cannot enableCONFIG_NUMA, so this mainly targets pre-v7.0 stable kernels.
Quoted 3 lines
Fixes a49bd4d71637 ("mm, numa: rework do_pages_move")Signed-off-by Shao Mingyin <[email protected]>
NAK.
This person('s script) sent 300 mails in under four weeks spanning: ata, scsi, target, ufs, nvme/nvmet, ubifs, ublk, zloop, dm, md, mmc, virtio-blk, mfd, gpio, pwm, spi, PCI, ASoC, ACPI, net, vfs mount, block partitions, and now mm.
Those patches that I've looked at have actually both been wrong and both useless.
And absolutely not to this person/script doing backports, thanks.
Quoted 16 lines
---
Changes in v2:
- describe the reproduction and the code path, as requested by David Hildenbrand; no code change
- correct thedo_pages_stat()reference (fixed by8e934ab44389)mm/migrate.c | 2 ++ 1 file changed, 2 insertions(+)mm/migrate.c +0
-0
mm/migrate.c static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, · line 2379
Quoted 8 lines
mm/migrate.c +2
-0@@ -2372,6 +2372,8 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,const void __user *p;int node; +cond_resched (); + err = -EFAULT ;if (in_compat_syscall ()) {compat_uptr_t cp;
--
Cheers, Lorenzo
Gregory Price (Meta)
reviewerQuoted 13 lines · Lorenzo Stoakes (ARM)
Quoted 10 lines · On Sun, Nov 08, 2026 at 02:28:31PM +0800, [email protected] wrote:
From: Shao Mingyin <[email protected]>
do_pages_stat()had the same problem; it was fixed by8e934ab44389. In current mainline only alpha, hexagon and classic m68k can selectPREEMPT_NONEand they cannot enableCONFIG_NUMA, so this mainly targets pre-v7.0 stable kernels.Fixes a49bd4d71637 ("mm, numa: rework do_pages_move")Signed-off-by Shao Mingyin <[email protected]>NAK.
...
Quoted 1 line
And absolutely not to this person/script doing backports, thanks.
Have to agree here. This is just creating backport busywork.
This might matter if we intended to do automated cross-arch testing on QEMU TCG on these platforms... on those LTS kernels... but also mehhhhhh
Yeah we shouldn't encourage this kind of patch spew.
Signature · 1 line
~Gregory
David Hildenbrand (Arm)
maintainerQuoted 17 lines · Gregory Price (Meta)
Quoted 13 lines · Lorenzo Stoakes (ARM)
Quoted 10 lines · On Sun, Nov 08, 2026 at 02:28:31PM +0800, [email protected] wrote:
From: Shao Mingyin <[email protected]>
do_pages_stat()had the same problem; it was fixed by8e934ab44389. In current mainline only alpha, hexagon and classic m68k can selectPREEMPT_NONEand they cannot enableCONFIG_NUMA, so this mainly targets pre-v7.0 stable kernels.Fixes a49bd4d71637 ("mm, numa: rework do_pages_move")Signed-off-by Shao Mingyin <[email protected]>NAK.
...
Quoted 1 line
And absolutely not to this person/script doing backports, thanks.
Quoted 8 lines
Have to agree here. This is just creating backport busywork.
This might matter if we intended to do automated cross-arch testing on QEMU TCG on these platforms... on those LTS kernels... but also mehhhhhh
Yeah we shouldn't encourage this kind of patch spew.
More than happy to drop this and wait for an actual user report -- and likely find a different way to fix this stuff in stable without involving upstream that doesn't need these changes.
Signature · 3 lines
Cheers, David