Skip to contentSkip to conversation

WARNING in mas_nomem

syzbot syzbot 4 participants 11 messages Jul 31 – Aug 7

Subsystems (3)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

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 [email protected]
------------[ 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 [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

maintainer
#1 lore raw
Quoted 51 lines · syzbot

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 [email protected]
------------[ 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
Quoted 8 lines
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/[email protected]/

Cheers,
Liam

#2 lore raw
Quoted 62 lines · Liam R. Howlett
Quoted 51 lines · syzbot

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 [email protected]
------------[ 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
Quoted 8 lines
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>
Quoted 4 lines

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.

Quoted 7 lines

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.

Quoted 4 lines

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

Summary of previous conversation is here:
https://lore.kernel.org/all/[email protected]/

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.

Quoted 3 lines

Cheers,
Liam

#3 lore raw
Quoted 9 lines · Vlastimil Babka (SUSE)
Quoted 4 lines

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

Summary of previous conversation is here:
https://lore.kernel.org/all/[email protected]/

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

#4 lore raw
Quoted 7 lines · Jason Gunthorpe
Quoted 5 lines · Vlastimil Babka (SUSE)
Quoted 4 lines

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

Summary of previous conversation is here:
https://lore.kernel.org/all/[email protected]/

Quoted 7 lines
Quoted 4 lines

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.

Quoted 1 line

Jason

maintainer
#5 lore raw
Quoted 13 lines · Vlastimil Babka (SUSE)
Quoted 12 lines · Jason Gunthorpe
Quoted 9 lines · Vlastimil Babka (SUSE)
Quoted 4 lines

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

Summary of previous conversation is here:
https://lore.kernel.org/all/[email protected]/

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.

Quoted 6 lines
Quoted 2 lines

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.

From 7943966dfd4eb8470d79da1fef2d81cf4cf59983 Mon Sep 17 00:00:00 2001
From: "Liam R. Howlett (Oracle)" <[email protected]>
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.

---
 lib/maple_tree.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
lib/maple_tree.c +6 -4
index 0954d431bf981..4fb7a209dcb2d 100644
@@ -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);
Signature · 1 line
2.47.3
#6 lore raw

lib/maple_tree.c void *mas_store(struct ma_state *mas, void *entry) · line 5615

Quoted 7 lines · Liam R. Howlett
lib/maple_tree.c +1 -2
@@ -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

maintainer
#7 lore raw
Quoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Liam R. Howlett
lib/maple_tree.c +0 -0
@@ -5609,8 +5612,7 @@ void *mas_store(struct ma_state *mas, void *entry)
 		goto store;
 
Quoted 8 lines

lib/maple_tree.c void *mas_store(struct ma_state *mas, void *entry) · line 5615

Quoted 4 lines
lib/maple_tree.c +1 -2
 	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()

Sure, that's fair.

Quoted 2 lines

? and maybe it can have a WARN_ON

The warning would never trigger. If the allocation fails with nofail, then you'd never reach the warning.

Thanks,
Liam

maintainer
#8 lore raw
Quoted 15 lines · Liam R. Howlett
Quoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Liam R. Howlett
lib/maple_tree.c +0 -0
@@ -5609,8 +5612,7 @@ void *mas_store(struct ma_state *mas, void *entry)
 		goto store;
 
Quoted 8 lines

lib/maple_tree.c void *mas_store(struct ma_state *mas, void *entry) · line 5615

Quoted 4 lines
lib/maple_tree.c +1 -2
 	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()

Quoted 8 lines

Sure, that's fair.

Quoted 2 lines

? and maybe it can have a WARN_ON

The warning would never trigger. If the allocation fails with nofail, then you'd never reach the warning.

Upon rereading my reply, I don't think it was clear what's going to happen here.

If there's really no memory and no reserves, then we're going to panic on trying to allocate. So, even if I rewrite this to have a void function to print a warning, it will never trigger, at that point why have another function? Are you looking to document what's happening in the code with this? If so, maybe a comment would be better.

Thanks,
Liam

#9 lore raw
Quoted 25 lines · Liam R. Howlett
Quoted 15 lines · Liam R. Howlett
Quoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Liam R. Howlett
lib/maple_tree.c +0 -0
@@ -5609,8 +5612,7 @@ void *mas_store(struct ma_state *mas, void *entry)
 		goto store;
 
Quoted 8 lines

lib/maple_tree.c void *mas_store(struct ma_state *mas, void *entry) · line 5615

Quoted 4 lines
lib/maple_tree.c +1 -2
 	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()

Quoted 8 lines

Sure, that's fair.

Quoted 2 lines

? and maybe it can have a WARN_ON

The warning would never trigger. If the allocation fails with nofail, then you'd never reach the warning.

Quoted 8 lines

Upon rereading my reply, I don't think it was clear what's going to happen here.

If there's really no memory and no reserves, then we're going to panic on trying to allocate. So, even if I rewrite this to have a void function to print a warning, it will never trigger, at that point why have another function? Are you looking to document what's happening in the code with this? If so, maybe a comment would be better.

Yeah, it is clearer to document it with a function that can't be called wrong, IMHO

Jason

maintainer
#10 lore raw
Quoted 29 lines · Jason Gunthorpe
Quoted 28 lines · Liam R. Howlett
Quoted 15 lines · Liam R. Howlett
Quoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Liam R. Howlett
lib/maple_tree.c +0 -0
@@ -5609,8 +5612,7 @@ void *mas_store(struct ma_state *mas, void *entry)
 		goto store;
 
Quoted 8 lines

lib/maple_tree.c void *mas_store(struct ma_state *mas, void *entry) · line 5615

Quoted 4 lines
lib/maple_tree.c +1 -2
 	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()

Quoted 8 lines

Sure, that's fair.

Quoted 2 lines

? and maybe it can have a WARN_ON

The warning would never trigger. If the allocation fails with nofail, then you'd never reach the warning.

Upon rereading my reply, I don't think it was clear what's going to happen here.

Quoted 8 lines
Quoted 5 lines

If there's really no memory and no reserves, then we're going to panic on trying to allocate. So, even if I rewrite this to have a void function to print a warning, it will never trigger, at that point why have another function? Are you looking to document what's happening in the code with this? If so, maybe a comment would be better.

Yeah, it is clearer to document it with a function that can't be called wrong, IMHO

Okay, I'll figure out how to do that later. I'd like to get this in for the next weeks -next testing as we're getting late in the cycle.

Cheers,
Liam