Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [mm?] WARNING in mas_nomem
@ 2026-07-31  7:30 syzbot
  2026-07-31 15:59 ` Liam R. Howlett
  0 siblings, 1 reply; 7+ messages in thread
From: syzbot @ 2026-07-31  7:30 UTC (permalink / raw)
  To: akpm, jannh, liam, linux-kernel, linux-mm, ljs, pfalcato,
	syzkaller-bugs, vbabka

Hello,

syzbot found the following issue on:

HEAD commit:    cc2b5f627e8c Add linux-next specific files for 20260714
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=15ce5632580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=2290ccbf984c524f
dashboard link: https://syzkaller.appspot.com/bug?extid=78a7af91b68fc6394771
compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=179151b9580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6836f8efb1da/disk-cc2b5f62.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0109d3477cc7/vmlinux-cc2b5f62.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c2e49e350bbf/bzImage-cc2b5f62.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+78a7af91b68fc6394771@syzkaller.appspotmail.com

------------[ cut here ]------------
!mas->sheaf && !mas->alloc
WARNING: lib/maple_tree.c:5751 at mas_nomem+0x1cc/0x210 lib/maple_tree.c:5751, CPU#0: udevd/5627
Modules linked in:
CPU: 0 UID: 0 PID: 5627 Comm: udevd Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
RIP: 0010:mas_nomem+0x1cc/0x210 lib/maple_tree.c:5751
Code: 4c 89 ff e8 d6 85 ea f6 49 c7 07 00 00 00 00 b0 01 e9 95 fe ff ff e8 f3 2d 7e f6 90 0f 0b 90 e9 2b ff ff ff e8 e5 2d 7e f6 90 <0f> 0b 90 e9 77 fe ff ff 89 d1 80 e1 07 80 c1 03 38 c1 0f 8c ce fe
RSP: 0018:ffffc9000562f8f0 EFLAGS: 00010293
RAX: ffffffff8b4775cb RBX: 1ffff92000ac5fbf RCX: ffff8880366e3e80
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000cc0 R08: 00000000ffffffff R09: 1ffffffff1ca1a86
R10: dffffc0000000000 R11: fffffbfff1ca1a87 R12: dffffc0000000000
R13: ffffc9000562fe18 R14: ffffc9000562fde0 R15: ffffc9000562fdf8
FS:  00007f9021203880(0000) GS:ffff8881259f2000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000056467bb0d750 CR3: 0000000046416000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 mas_store_gfp+0x37a/0x820 lib/maple_tree.c:4987
 vma_iter_clear_gfp include/linux/mm.h:1674 [inline]
 do_vmi_align_munmap+0x30c/0x4d0 mm/vma.c:1644
 do_vmi_munmap+0x252/0x2d0 mm/vma.c:1697
 __vm_munmap+0x241/0x3e0 mm/vma.c:3347
 __do_sys_munmap mm/mmap.c:1079 [inline]
 __se_sys_munmap mm/mmap.c:1076 [inline]
 __x64_sys_munmap+0x60/0x70 mm/mmap.c:1076
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x17b/0x530 arch/x86/entry/syscall_64.c:85
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f9021368097
Code: 73 01 c3 48 8b 0d 61 2d 0d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 0b 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 31 2d 0d 00 f7 d8 64 89 01 48
RSP: 002b:00007ffeaf32d0a8 EFLAGS: 00000206 ORIG_RAX: 000000000000000b
RAX: ffffffffffffffda RBX: 000056467bad9bf0 RCX: 00007f9021368097
RDX: 0000000000000000 RSI: 00000000009480e8 RDI: 00007f90208ba000
RBP: 000056467bad9910 R08: 000056467baec140 R09: 0000000000000006
R10: 0000000000000000 R11: 0000000000000206 R12: 00005646569e2588
R13: 00007ffeaf32d130 R14: 0000000000000000 R15: 0000000000000000
 </TASK>


---
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 syzkaller@googlegroups.com.

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] WARNING in mas_nomem
  2026-07-31  7:30 [syzbot] [mm?] WARNING in mas_nomem syzbot
@ 2026-07-31 15:59 ` Liam R. Howlett
  2026-07-31 16:07   ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 7+ messages in thread
From: Liam R. Howlett @ 2026-07-31 15:59 UTC (permalink / raw)
  To: syzbot
  Cc: akpm, jannh, linux-kernel, linux-mm, ljs, pfalcato,
	syzkaller-bugs, vbabka, Jason Gunthorpe

On 26/07/31 12:30AM, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    cc2b5f627e8c Add linux-next specific files for 20260714
> git tree:       linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=15ce5632580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=2290ccbf984c524f
> dashboard link: https://syzkaller.appspot.com/bug?extid=78a7af91b68fc6394771
> compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=179151b9580000
> 
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/6836f8efb1da/disk-cc2b5f62.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/0109d3477cc7/vmlinux-cc2b5f62.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/c2e49e350bbf/bzImage-cc2b5f62.xz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+78a7af91b68fc6394771@syzkaller.appspotmail.com
> 
> ------------[ cut here ]------------
> !mas->sheaf && !mas->alloc
> WARNING: lib/maple_tree.c:5751 at mas_nomem+0x1cc/0x210 lib/maple_tree.c:5751, CPU#0: udevd/5627
> Modules linked in:
> CPU: 0 UID: 0 PID: 5627 Comm: udevd Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
> RIP: 0010:mas_nomem+0x1cc/0x210 lib/maple_tree.c:5751
> Code: 4c 89 ff e8 d6 85 ea f6 49 c7 07 00 00 00 00 b0 01 e9 95 fe ff ff e8 f3 2d 7e f6 90 0f 0b 90 e9 2b ff ff ff e8 e5 2d 7e f6 90 <0f> 0b 90 e9 77 fe ff ff 89 d1 80 e1 07 80 c1 03 38 c1 0f 8c ce fe
> RSP: 0018:ffffc9000562f8f0 EFLAGS: 00010293
> RAX: ffffffff8b4775cb RBX: 1ffff92000ac5fbf RCX: ffff8880366e3e80
> RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
> RBP: 0000000000000cc0 R08: 00000000ffffffff R09: 1ffffffff1ca1a86
> R10: dffffc0000000000 R11: fffffbfff1ca1a87 R12: dffffc0000000000
> R13: ffffc9000562fe18 R14: ffffc9000562fde0 R15: ffffc9000562fdf8
> FS:  00007f9021203880(0000) GS:ffff8881259f2000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000056467bb0d750 CR3: 0000000046416000 CR4: 00000000003526f0
> Call Trace:
>  <TASK>
>  mas_store_gfp+0x37a/0x820 lib/maple_tree.c:4987
>  vma_iter_clear_gfp include/linux/mm.h:1674 [inline]
>  do_vmi_align_munmap+0x30c/0x4d0 mm/vma.c:1644
>  do_vmi_munmap+0x252/0x2d0 mm/vma.c:1697
>  __vm_munmap+0x241/0x3e0 mm/vma.c:3347
>  __do_sys_munmap mm/mmap.c:1079 [inline]
>  __se_sys_munmap mm/mmap.c:1076 [inline]
>  __x64_sys_munmap+0x60/0x70 mm/mmap.c:1076
>  do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
>  do_syscall_64+0x17b/0x530 arch/x86/entry/syscall_64.c:85
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7f9021368097
> Code: 73 01 c3 48 8b 0d 61 2d 0d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 0b 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 31 2d 0d 00 f7 d8 64 89 01 48
> RSP: 002b:00007ffeaf32d0a8 EFLAGS: 00000206 ORIG_RAX: 000000000000000b
> RAX: ffffffffffffffda RBX: 000056467bad9bf0 RCX: 00007f9021368097
> RDX: 0000000000000000 RSI: 00000000009480e8 RDI: 00007f90208ba000
> RBP: 000056467bad9910 R08: 000056467baec140 R09: 0000000000000006
> R10: 0000000000000000 R11: 0000000000000206 R12: 00005646569e2588
> R13: 00007ffeaf32d130 R14: 0000000000000000 R15: 0000000000000000
>  </TASK>


Okay, so I'm going to change this warn_on again.

The plan is to:
1. Make mas_erase() and mtree_erase() use __NO_FAIL on retry.
2. Remove the warning so that any failures won't cause the warning.
3. Make mas_store() use __NO_FAIL on retry, like mas_erase().
4. Add the check for locks that cannot sleep to mas_store().

Basically any caller that cannot correctly return the failure will avoid
failing by allocating with __NO_FAIL.  This means the warning is not
necessary.

Thanks to Vlastimil and Pedro for the help on the plan.

Summary of previous conversation is here:
https://lore.kernel.org/all/20260618152451.GE231643@ziepe.ca/


Cheers,
Liam


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] WARNING in mas_nomem
  2026-07-31 15:59 ` Liam R. Howlett
@ 2026-07-31 16:07   ` Vlastimil Babka (SUSE)
  2026-08-05  0:46     ` Jason Gunthorpe
  0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-31 16:07 UTC (permalink / raw)
  To: Liam R. Howlett, syzbot
  Cc: akpm, jannh, linux-kernel, linux-mm, ljs, pfalcato,
	syzkaller-bugs, Jason Gunthorpe

On 7/31/26 17:59, Liam R. Howlett wrote:
> On 26/07/31 12:30AM, syzbot wrote:
>> Hello,
>> 
>> syzbot found the following issue on:
>> 
>> HEAD commit:    cc2b5f627e8c Add linux-next specific files for 20260714
>> git tree:       linux-next
>> console output: https://syzkaller.appspot.com/x/log.txt?x=15ce5632580000
>> kernel config:  https://syzkaller.appspot.com/x/.config?x=2290ccbf984c524f
>> dashboard link: https://syzkaller.appspot.com/bug?extid=78a7af91b68fc6394771
>> compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
>> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=179151b9580000
>> 
>> Downloadable assets:
>> disk image: https://storage.googleapis.com/syzbot-assets/6836f8efb1da/disk-cc2b5f62.raw.xz
>> vmlinux: https://storage.googleapis.com/syzbot-assets/0109d3477cc7/vmlinux-cc2b5f62.xz
>> kernel image: https://storage.googleapis.com/syzbot-assets/c2e49e350bbf/bzImage-cc2b5f62.xz
>> 
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: syzbot+78a7af91b68fc6394771@syzkaller.appspotmail.com
>> 
>> ------------[ cut here ]------------
>> !mas->sheaf && !mas->alloc
>> WARNING: lib/maple_tree.c:5751 at mas_nomem+0x1cc/0x210 lib/maple_tree.c:5751, CPU#0: udevd/5627
>> Modules linked in:
>> CPU: 0 UID: 0 PID: 5627 Comm: udevd Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
>> RIP: 0010:mas_nomem+0x1cc/0x210 lib/maple_tree.c:5751
>> Code: 4c 89 ff e8 d6 85 ea f6 49 c7 07 00 00 00 00 b0 01 e9 95 fe ff ff e8 f3 2d 7e f6 90 0f 0b 90 e9 2b ff ff ff e8 e5 2d 7e f6 90 <0f> 0b 90 e9 77 fe ff ff 89 d1 80 e1 07 80 c1 03 38 c1 0f 8c ce fe
>> RSP: 0018:ffffc9000562f8f0 EFLAGS: 00010293
>> RAX: ffffffff8b4775cb RBX: 1ffff92000ac5fbf RCX: ffff8880366e3e80
>> RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
>> RBP: 0000000000000cc0 R08: 00000000ffffffff R09: 1ffffffff1ca1a86
>> R10: dffffc0000000000 R11: fffffbfff1ca1a87 R12: dffffc0000000000
>> R13: ffffc9000562fe18 R14: ffffc9000562fde0 R15: ffffc9000562fdf8
>> FS:  00007f9021203880(0000) GS:ffff8881259f2000(0000) knlGS:0000000000000000
>> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: 000056467bb0d750 CR3: 0000000046416000 CR4: 00000000003526f0
>> Call Trace:
>>  <TASK>
>>  mas_store_gfp+0x37a/0x820 lib/maple_tree.c:4987
>>  vma_iter_clear_gfp include/linux/mm.h:1674 [inline]
>>  do_vmi_align_munmap+0x30c/0x4d0 mm/vma.c:1644
>>  do_vmi_munmap+0x252/0x2d0 mm/vma.c:1697
>>  __vm_munmap+0x241/0x3e0 mm/vma.c:3347
>>  __do_sys_munmap mm/mmap.c:1079 [inline]
>>  __se_sys_munmap mm/mmap.c:1076 [inline]
>>  __x64_sys_munmap+0x60/0x70 mm/mmap.c:1076
>>  do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
>>  do_syscall_64+0x17b/0x530 arch/x86/entry/syscall_64.c:85
>>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
>> RIP: 0033:0x7f9021368097
>> Code: 73 01 c3 48 8b 0d 61 2d 0d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 0b 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 31 2d 0d 00 f7 d8 64 89 01 48
>> RSP: 002b:00007ffeaf32d0a8 EFLAGS: 00000206 ORIG_RAX: 000000000000000b
>> RAX: ffffffffffffffda RBX: 000056467bad9bf0 RCX: 00007f9021368097
>> RDX: 0000000000000000 RSI: 00000000009480e8 RDI: 00007f90208ba000
>> RBP: 000056467bad9910 R08: 000056467baec140 R09: 0000000000000006
>> R10: 0000000000000000 R11: 0000000000000206 R12: 00005646569e2588
>> R13: 00007ffeaf32d130 R14: 0000000000000000 R15: 0000000000000000
>>  </TASK>
> 
> 
> Okay, so I'm going to change this warn_on again.
> 
> The plan is to:
> 1. Make mas_erase() and mtree_erase() use __NO_FAIL on retry.

__GFP_NOFAIL to be precise.

> 2. Remove the warning so that any failures won't cause the warning.
> 3. Make mas_store() use __NO_FAIL on retry, like mas_erase().
> 4. Add the check for locks that cannot sleep to mas_store().
> 
> Basically any caller that cannot correctly return the failure will avoid
> failing by allocating with __NO_FAIL.  This means the warning is not
> necessary.

Sounds good.

> Thanks to Vlastimil and Pedro for the help on the plan.
> 
> Summary of previous conversation is here:
> https://lore.kernel.org/all/20260618152451.GE231643@ziepe.ca/

Yeah, unfortunately, "too small to fail" is a lie, because in some cases it
can fail (such as the task itself becoming oom killer victim) or any of the
other conditions that can cause __alloc_pages_may_oom() return with
*did_some_progress == 0.

And syzbot knows how to remind us of this, using fault injection.

> 
> Cheers,
> Liam



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] WARNING in mas_nomem
  2026-07-31 16:07   ` Vlastimil Babka (SUSE)
@ 2026-08-05  0:46     ` Jason Gunthorpe
  2026-08-05  8:01       ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2026-08-05  0:46 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Liam R. Howlett, syzbot, akpm, jannh, linux-kernel, linux-mm, ljs,
	pfalcato, syzkaller-bugs

On Fri, Jul 31, 2026 at 06:07:24PM +0200, Vlastimil Babka (SUSE) wrote:

> > Thanks to Vlastimil and Pedro for the help on the plan.
> > 
> > Summary of previous conversation is here:
> > https://lore.kernel.org/all/20260618152451.GE231643@ziepe.ca/
> 
> Yeah, unfortunately, "too small to fail" is a lie, because in some cases it
> can fail (such as the task itself becoming oom killer victim) or any of the
> other conditions that can cause __alloc_pages_may_oom() return with
> *did_some_progress == 0.

But then we are back to the original problem, an erase API that can
fail is fundamentally broken.

Jason


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] WARNING in mas_nomem
  2026-08-05  0:46     ` Jason Gunthorpe
@ 2026-08-05  8:01       ` Vlastimil Babka (SUSE)
  2026-08-06 14:29         ` Liam R. Howlett
  0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-08-05  8:01 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Liam R. Howlett, syzbot, akpm, jannh, linux-kernel, linux-mm, ljs,
	pfalcato, syzkaller-bugs

On 8/5/26 02:46, Jason Gunthorpe wrote:
> On Fri, Jul 31, 2026 at 06:07:24PM +0200, Vlastimil Babka (SUSE) wrote:
> 
>> > Thanks to Vlastimil and Pedro for the help on the plan.
>> > 
>> > Summary of previous conversation is here:
>> > https://lore.kernel.org/all/20260618152451.GE231643@ziepe.ca/
>> 
>> Yeah, unfortunately, "too small to fail" is a lie, because in some cases it
>> can fail (such as the task itself becoming oom killer victim) or any of the
>> other conditions that can cause __alloc_pages_may_oom() return with
>> *did_some_progress == 0.
> 
> But then we are back to the original problem, an erase API that can
> fail is fundamentally broken.

That's why the plan is to add __GFP_NOFAIL, which overrides the
possibilities to fail listed above.

> Jason



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] WARNING in mas_nomem
  2026-08-05  8:01       ` Vlastimil Babka (SUSE)
@ 2026-08-06 14:29         ` Liam R. Howlett
  2026-08-06 15:48           ` Jason Gunthorpe
  0 siblings, 1 reply; 7+ messages in thread
From: Liam R. Howlett @ 2026-08-06 14:29 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Jason Gunthorpe, syzbot, akpm, jannh, linux-kernel, linux-mm, ljs,
	pfalcato, syzkaller-bugs

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

On 26/08/05 10:01AM, Vlastimil Babka (SUSE) wrote:
> On 8/5/26 02:46, Jason Gunthorpe wrote:
> > On Fri, Jul 31, 2026 at 06:07:24PM +0200, Vlastimil Babka (SUSE) wrote:
> > 
> >> > Thanks to Vlastimil and Pedro for the help on the plan.
> >> > 
> >> > Summary of previous conversation is here:
> >> > https://lore.kernel.org/all/20260618152451.GE231643@ziepe.ca/
> >> 
> >> Yeah, unfortunately, "too small to fail" is a lie, because in some cases it
> >> can fail (such as the task itself becoming oom killer victim) or any of the
> >> other conditions that can cause __alloc_pages_may_oom() return with
> >> *did_some_progress == 0.
> > 
> > But then we are back to the original problem, an erase API that can
> > fail is fundamentally broken.
> 
> That's why the plan is to add __GFP_NOFAIL, which overrides the
> possibilities to fail listed above.
> 

Something like the attached.

[-- Attachment #2: 0001-maple_tree-Remove-warning-from-mas_nomem.patch --]
[-- Type: text/x-diff, Size: 2311 bytes --]

From 7943966dfd4eb8470d79da1fef2d81cf4cf59983 Mon Sep 17 00:00:00 2001
From: "Liam R. Howlett (Oracle)" <liam@infradead.org>
Date: Thu, 6 Aug 2026 10:23:00 -0400
Subject: [PATCH] maple_tree: Remove warning from mas_nomem()

It is possible to trigger the warning in mas_nomem in certain call paths
using valid gfp flags.  Drop the warning and handle the failures
differently.

Instead, have mtree_erase() and mas_erase() use __GFP_NOFAIL.

During the discussion, mas_store() was also flagged as a potential path
that may fail due to implied gfp flags.  Changing those flags to retry
with __GFP_NOFAIL is a viable solution there.  At the same time, adding
a might_sleep() check to catch incorrect uses is prudent.

Signed-off-by: Liam R. Howlett (Oracle) <liam@infradead.org>
---
 lib/maple_tree.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 0954d431bf981..4fb7a209dcb2d 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5577,6 +5577,9 @@ void *mas_store(struct ma_state *mas, void *entry)
 	MA_WR_STATE(wr_mas, mas, entry);
 
 	mas_may_init_lock_check(mas);
+	if (mt_external_lock(mas->tree))
+		might_alloc(GFP_KERNEL);
+
 	trace_ma_write(TP_FCT, mas, 0, entry);
 #ifdef CONFIG_DEBUG_MAPLE_TREE
 	if (MAS_WARN_ON(mas, mas->index > mas->last))
@@ -5609,8 +5612,7 @@ void *mas_store(struct ma_state *mas, void *entry)
 		goto store;
 
 	mas_alloc_nodes(mas, GFP_NOWAIT);
-	if (mas_is_err(mas))
-		return NULL;
+	mas_nomem(mas, GFP_KERNEL | __GFP_NOFAIL);
 
 store:
 	mas_wr_store_entry(&wr_mas);
@@ -6351,7 +6353,7 @@ void *mas_erase(struct ma_state *mas)
 	/* Must reset to ensure spanning writes of last slot are detected */
 	mas_reset(mas);
 	mas_wr_preallocate(&wr_mas, NULL);
-	if (mas_nomem(mas, GFP_KERNEL)) {
+	if (mas_nomem(mas, GFP_KERNEL | __GFP_NOFAIL)) {
 		/* in case the range of entry changed when unlocked */
 		mas->index = mas->last = index;
 		goto write_retry;
@@ -6402,7 +6404,7 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp)
 	 * external lock with a non-blocking gfp in a low memory situation -
 	 * which would have triggered the first warning in this function.
 	 */
-	if (WARN_ON_ONCE(!mas->sheaf && !mas->alloc))
+	if (!mas->sheaf && !mas->alloc)
 		return false;
 
 	mas_reset(mas);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] WARNING in mas_nomem
  2026-08-06 14:29         ` Liam R. Howlett
@ 2026-08-06 15:48           ` Jason Gunthorpe
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2026-08-06 15:48 UTC (permalink / raw)
  To: Liam R. Howlett
  Cc: Vlastimil Babka (SUSE), syzbot, akpm, jannh, linux-kernel,
	linux-mm, ljs, pfalcato, syzkaller-bugs

On Thu, Aug 06, 2026 at 10:29:27AM -0400, Liam R. Howlett wrote:

> @@ -5609,8 +5612,7 @@ void *mas_store(struct ma_state *mas, void *entry)
>  		goto store;
>  
>  	mas_alloc_nodes(mas, GFP_NOWAIT);
> -	if (mas_is_err(mas))
> -		return NULL;
> +	mas_nomem(mas, GFP_KERNEL | __GFP_NOFAIL);

It still feels really weird to ignore the return code from mas_nomem..

 void mas_nomem_nofail() 

? and maybe it can have a WARN_ON

Jason


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-06 15:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31  7:30 [syzbot] [mm?] WARNING in mas_nomem syzbot
2026-07-31 15:59 ` Liam R. Howlett
2026-07-31 16:07   ` Vlastimil Babka (SUSE)
2026-08-05  0:46     ` Jason Gunthorpe
2026-08-05  8:01       ` Vlastimil Babka (SUSE)
2026-08-06 14:29         ` Liam R. Howlett
2026-08-06 15:48           ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox