[PATCH] mm: mempool: remove __GFP_NOFAIL gfp_mask when first allocation
From: Vernon Yang
Date: Mon Feb 02 2026 - 21:51:45 EST
page allocator triggers a warning when __GFP_NOFAIL is set but
__GFP_DIRECT_RECLAIM is not set.
The user of the mempool (f2fs_encrypt_one_page) passed
__GFP_DIRECT_RECLAIM, but mempool temporarily cleared it when
first allocate memory.
gfp_temp = gfp_mask & ~(__GFP_DIRECT_RECLAIM|__GFP_IO)
Make mempool also clear __GFP_NOFAIL as well when clearing
__GFP_DIRECT_RECLAIM.
Closes: https://lore.kernel.org/linux-mm/CAHPqNmwK9TY5THsXWkJuYCdt7x+mZHPq65AUOLZJeMp-FdAMvA@xxxxxxxxxxxxxx
Suggested-by: Harry Yoo <harry.yoo@xxxxxxxxxx>
Signed-off-by: Vernon Yang <yanglincheng@xxxxxxxxxx>
---
mm/mempool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/mempool.c b/mm/mempool.c
index c290e5261b47..679ab4a2cc5f 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -472,7 +472,7 @@ static unsigned int mempool_alloc_from_pool(struct mempool *pool, void **elems,
static inline gfp_t mempool_adjust_gfp(gfp_t *gfp_mask)
{
*gfp_mask |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN;
- return *gfp_mask & ~(__GFP_DIRECT_RECLAIM | __GFP_IO);
+ return *gfp_mask & ~(__GFP_NOFAIL | __GFP_DIRECT_RECLAIM | __GFP_IO);
}
/**
--
2.51.0
>
> > fscrypt_alloc_bounce_page+0x28/0x60 fs/crypto/crypto.c:59
> > fscrypt_encrypt_pagecache_blocks.cold+0x567/0x6da fs/crypto/crypto.c:202
> > f2fs_encrypt_one_page+0x187/0x630 fs/f2fs/data.c:2516
> > f2fs_do_write_data_page+0x7b4/0x1900 fs/f2fs/data.c:2706
> > f2fs_write_single_data_page+0x1454/0x1c30 fs/f2fs/data.c:2872
> > f2fs_write_cache_pages+0xd6e/0x24e0 fs/f2fs/data.c:3166
> > __f2fs_write_data_pages fs/f2fs/data.c:3321 [inline]
> > f2fs_write_data_pages+0x4af/0xdd0 fs/f2fs/data.c:3348
> > do_writepages+0x1a3/0x7f0 mm/page-writeback.c:2683
> > filemap_fdatawrite_wbc mm/filemap.c:398 [inline]
> > filemap_fdatawrite_wbc+0x148/0x1c0 mm/filemap.c:388
> > __filemap_fdatawrite_range+0xb3/0xf0 mm/filemap.c:431
> > file_write_and_wait_range+0xca/0x140 mm/filemap.c:788
> > f2fs_do_sync_file+0x2dc/0x1ed0 fs/f2fs/file.c:278
> > f2fs_sync_file+0x13a/0x1a0 fs/f2fs/file.c:395
> > vfs_fsync_range+0x136/0x220 fs/sync.c:188
> > generic_write_sync include/linux/fs.h:2871 [inline]
> > f2fs_file_write_iter+0x12ba/0x2370 fs/f2fs/file.c:5057
> > new_sync_write fs/read_write.c:590 [inline]
> > vfs_write+0x5ae/0x1150 fs/read_write.c:683
> > ksys_write+0x12f/0x260 fs/read_write.c:736
> > do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> > do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
> > entry_SYSCALL_64_after_hwframe+0x77/0x7f
> > RIP: 0033:0x471ecd
> > Code: c3 e8 17 28 00 00 0f 1f 80 00 00 00 00 f3 0f 1e fa 48 89 f8 48
> > 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
> > 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
> > RSP: 002b:00007f1784eff058 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> > RAX: ffffffffffffffda RBX: 000000000059bf80 RCX: 0000000000471ecd
> > RDX: 0000000000000002 RSI: 00000000200003c0 RDI: 0000000000000004
> > RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
> > R10: 0000000000000000 R11: 0000000000000246 R12: 000000000059bf8c
> > R13: 000000000000000b R14: 000000000059bf80 R15: 00007f1784edf000
> > </TASK>
> >
> > https://drive.google.com/file/d/17HbDTI_iPjA72SkV5MnO-_w7IQZ9HIHW/view?usp=drive_link
> >
> > https://drive.google.com/file/d/19pMiWedcVz8nFrj9jiJXuCjyPbNjYQqq/view?usp=drive_link
>
--
Thanks,
Vernon