* [PATCH 0/2] Fix spurious warnings about memory allocation @ 2026-12-03 14:23 Wang Wensheng 2026-12-03 14:23 ` [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed Wang Wensheng 2026-12-03 14:23 ` [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath Wang Wensheng 0 siblings, 2 replies; 10+ messages in thread From: Wang Wensheng @ 2026-12-03 14:23 UTC (permalink / raw) To: vbabka, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm Cc: wsw9603 After upgrading our product to kernel 6.18, we observed several memory allocation warnings. They do not affect real workloads and are false positives, so address them. Wang Wensheng (2): mm/swap: Don't warn if swap_cluster_alloc_table() failed mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath mm/page_alloc.c | 25 ++++++++++++------------- mm/swapfile.c | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed 2026-12-03 14:23 [PATCH 0/2] Fix spurious warnings about memory allocation Wang Wensheng @ 2026-12-03 14:23 ` Wang Wensheng 2026-12-04 2:32 ` Youngjun Park 2026-12-04 8:21 ` Dev Jain 2026-12-03 14:23 ` [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath Wang Wensheng 1 sibling, 2 replies; 10+ messages in thread From: Wang Wensheng @ 2026-12-03 14:23 UTC (permalink / raw) To: vbabka, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm Cc: wsw9603 swap_cluster_alloc_table() is mostly used in the memory reclaim path and should not warn when memory allocation fails. The actual user may reclaim pagecache or slab to free up memory. Even if the user ultimately cannot obtain memory, it is more useful to issue the warning at the last possible point. Signed-off-by: Wang Wensheng <wsw9603@163.com> --- mm/swapfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 226230dda0aa..b8fc4e25f1f3 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -602,7 +602,7 @@ swap_cluster_populate(struct swap_info_struct *si, local_unlock(&percpu_swap_cluster.lock); ret = swap_cluster_alloc_table(si, ci, __GFP_HIGH | __GFP_NOMEMALLOC | - GFP_KERNEL, false); + __GFP_NOWARN | GFP_KERNEL, false); /* * Back to atomic context. We might have migrated to a new CPU with a -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed 2026-12-03 14:23 ` [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed Wang Wensheng @ 2026-12-04 2:32 ` Youngjun Park 2026-12-04 5:06 ` wangwensheng 2026-12-04 8:21 ` Dev Jain 1 sibling, 1 reply; 10+ messages in thread From: Youngjun Park @ 2026-12-04 2:32 UTC (permalink / raw) To: Wang Wensheng Cc: vbabka, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, david, linux-mm On Thu, Dec 03, 2026 at 10:23:05PM +0800, Wang Wensheng wrote: > swap_cluster_alloc_table() is mostly used in the memory reclaim path > and should not warn when memory allocation fails. The actual user may > reclaim pagecache or slab to free up memory. Even if the user ultimately > cannot obtain memory, it is more useful to issue the warning at the last > possible point. > > Signed-off-by: Wang Wensheng <wsw9603@163.com> > --- > mm/swapfile.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 226230dda0aa..b8fc4e25f1f3 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -602,7 +602,7 @@ swap_cluster_populate(struct swap_info_struct *si, > local_unlock(&percpu_swap_cluster.lock); > > ret = swap_cluster_alloc_table(si, ci, __GFP_HIGH | __GFP_NOMEMALLOC | > - GFP_KERNEL, false); > + __GFP_NOWARN | GFP_KERNEL, false); Hi Wensheng, it may point to a real problem in dynamic cluster allocation, so the warning could be useful. If it is rare, __GFP_NOWARN isn't really needed(not bothering). If it is frequent, it suggests a real problem in dynamic cluster allocation, and then the warning is useful. IMHO So either way, it seems worth keeping. What do you think? Thanks, Youngjun ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed 2026-12-04 2:32 ` Youngjun Park @ 2026-12-04 5:06 ` wangwensheng 0 siblings, 0 replies; 10+ messages in thread From: wangwensheng @ 2026-12-04 5:06 UTC (permalink / raw) To: Youngjun Park Cc: vbabka, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, david, linux-mm On 12/4/26 10:32, Youngjun Park wrote: > On Thu, Dec 03, 2026 at 10:23:05PM +0800, Wang Wensheng wrote: >> swap_cluster_alloc_table() is mostly used in the memory reclaim path >> and should not warn when memory allocation fails. The actual user may >> reclaim pagecache or slab to free up memory. Even if the user ultimately >> cannot obtain memory, it is more useful to issue the warning at the last >> possible point. >> >> Signed-off-by: Wang Wensheng <wsw9603@163.com> >> --- >> mm/swapfile.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/swapfile.c b/mm/swapfile.c >> index 226230dda0aa..b8fc4e25f1f3 100644 >> --- a/mm/swapfile.c >> +++ b/mm/swapfile.c >> @@ -602,7 +602,7 @@ swap_cluster_populate(struct swap_info_struct *si, >> local_unlock(&percpu_swap_cluster.lock); >> >> ret = swap_cluster_alloc_table(si, ci, __GFP_HIGH | __GFP_NOMEMALLOC | >> - GFP_KERNEL, false); >> + __GFP_NOWARN | GFP_KERNEL, false); > > Hi Wensheng, > > it may point to a real problem in dynamic cluster allocation, > so the warning could be useful. What else could be wrong here besides low memory? If there is an issue with swap clusters, we should emit a separate warning instead of relying on warn_alloc. If it is simply a memory shortage, the warning should be shown when the actual workload allocation fails. Since warn_alloc has rate limiting, a hit during the swap path may suppress subsequent warn_alloc logs for later allocation failures from the workload. > > If it is rare, __GFP_NOWARN isn't really needed(not bothering). > If it is frequent, it suggests a real problem in dynamic cluster allocation, and then > the warning is useful. As for the frequency: it reproduces several times across 100 test runs. Only warn_alloc messages are seen, no OOM occurs, and the workload remains unaffected. > > IMHO So either way, it seems worth keeping. > What do you think? > > Thanks, > Youngjun ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed 2026-12-03 14:23 ` [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed Wang Wensheng 2026-12-04 2:32 ` Youngjun Park @ 2026-12-04 8:21 ` Dev Jain 1 sibling, 0 replies; 10+ messages in thread From: Dev Jain @ 2026-12-04 8:21 UTC (permalink / raw) To: Wang Wensheng, vbabka, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm On 03/12/26 7:53 pm, Wang Wensheng wrote: > swap_cluster_alloc_table() is mostly used in the memory reclaim path > and should not warn when memory allocation fails. The actual user may > reclaim pagecache or slab to free up memory. Even if the user ultimately What if a process is doing madvise(MADV_PAGEOUT)? Then you may not be able to obtain memory by freeing pagecache/slab etc I think? > cannot obtain memory, it is more useful to issue the warning at the last > possible point. > > Signed-off-by: Wang Wensheng <wsw9603@163.com> > --- > mm/swapfile.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 226230dda0aa..b8fc4e25f1f3 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -602,7 +602,7 @@ swap_cluster_populate(struct swap_info_struct *si, > local_unlock(&percpu_swap_cluster.lock); > > ret = swap_cluster_alloc_table(si, ci, __GFP_HIGH | __GFP_NOMEMALLOC | > - GFP_KERNEL, false); > + __GFP_NOWARN | GFP_KERNEL, false); > > /* > * Back to atomic context. We might have migrated to a new CPU with a ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath 2026-12-03 14:23 [PATCH 0/2] Fix spurious warnings about memory allocation Wang Wensheng 2026-12-03 14:23 ` [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed Wang Wensheng @ 2026-12-03 14:23 ` Wang Wensheng 2026-12-03 17:24 ` Michal Hocko 2026-12-04 9:06 ` Vlastimil Babka (SUSE) 1 sibling, 2 replies; 10+ messages in thread From: Wang Wensheng @ 2026-12-03 14:23 UTC (permalink / raw) To: vbabka, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm Cc: wsw9603 It is not uncommon to enter __alloc_pages_slowpath() with both PF_MEMALLOC and __GFP_NOFAIL set during memory reclaim. The original warning was placed where an allocation attempt had failed, intended to alert about a potential silent stall: with PF_MEMALLOC, direct reclaim cannot be performed, while __GFP_NOFAIL forces the allocation to keep retrying. Commit 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in a more appropriate location and manner") moved this warning to the very start of __alloc_pages_slowpath(), before any allocation attempt. This causes frequent false positives: PF_MEMALLOC allows allocations to ignore watermarks, and the fastpath only checks the low watermark, so the first allocation attempt inside the slowpath is likely to succeed. Move the warning to the nopage label to suppress these false warnings. The following calltrace triggers the spurious warning: __alloc_pages_slowpath __alloc_frozen_pages_noprof __folio_alloc_noprof __filemap_get_folio ext4_mb_load_buddy_gfp ext4_free_blocks ext4_ext_remove_space ext4_ext_truncate ext4_truncate ext4_evict_inode evict iput dentry_unlink_inode __dentry_kill shrink_dentry_list prune_dcache_sb super_cache_scan do_shrink_slab shrink_slab shrink_node do_try_to_free_pages try_to_free_pages __alloc_pages_direct_reclaim __alloc_pages_slowpath __alloc_frozen_pages_noprof __folio_alloc_noprof vma_alloc_zeroed_movable_folio Fixes: 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in a more appropriate location and manner") Signed-off-by: Wang Wensheng <wsw9603@163.com> --- mm/page_alloc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2fef4092c913..abdf4ba3f757 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4823,19 +4823,11 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, can_compact = can_direct_reclaim && gfp_compaction_allowed(gfp_mask); nofail = gfp_mask & __GFP_NOFAIL; - if (unlikely(nofail)) { - /* - * We don't support __GFP_NOFAIL without __GFP_DIRECT_RECLAIM, - * otherwise, we may result in lockup. - */ - WARN_ON_ONCE(!can_direct_reclaim); - /* - * PF_MEMALLOC request from this context is rather bizarre - * because we cannot reclaim anything and only can loop waiting - * for somebody to do a work for us. - */ - WARN_ON_ONCE(current->flags & PF_MEMALLOC); - } + /* + * We don't support __GFP_NOFAIL without __GFP_DIRECT_RECLAIM, + * otherwise, we may result in lockup. + */ + WARN_ON_ONCE(unlikely(nofail) && !can_direct_reclaim); restart: compaction_retries = 0; @@ -5124,6 +5116,13 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, if (page) goto got_pg; + /* + * PF_MEMALLOC request from this context is rather bizarre + * because we cannot reclaim anything and only can loop waiting + * for somebody to do a work for us. + */ + WARN_ON_ONCE(current->flags & PF_MEMALLOC); + cond_resched(); goto retry; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath 2026-12-03 14:23 ` [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath Wang Wensheng @ 2026-12-03 17:24 ` Michal Hocko 2026-12-04 1:42 ` wangwensheng 2026-12-04 9:06 ` Vlastimil Babka (SUSE) 1 sibling, 1 reply; 10+ messages in thread From: Michal Hocko @ 2026-12-03 17:24 UTC (permalink / raw) To: Wang Wensheng Cc: vbabka, hannes, surenb, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm On Thu 03-12-26 22:23:06, Wang Wensheng wrote: > It is not uncommon to enter __alloc_pages_slowpath() with both > PF_MEMALLOC and __GFP_NOFAIL set during memory reclaim. The original > warning was placed where an allocation attempt had failed, intended to > alert about a potential silent stall: with PF_MEMALLOC, direct reclaim > cannot be performed, while __GFP_NOFAIL forces the allocation to keep > retrying. > > Commit 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in > a more appropriate location and manner") moved this warning to the > very start of __alloc_pages_slowpath(), before any allocation attempt. > This causes frequent false positives: PF_MEMALLOC allows allocations > to ignore watermarks, and the fastpath only checks the low watermark, > so the first allocation attempt inside the slowpath is likely to > succeed. So essentially you are telling that we shouldn't warn if the allocation just manages to succeeds because there are memory reserves available. While the intention of the code is to catch the unsupported GFP_NOFAIL use from the allocation context. See the difference? -- Michal Hocko SUSE Labs ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath 2026-12-03 17:24 ` Michal Hocko @ 2026-12-04 1:42 ` wangwensheng 2026-12-04 9:29 ` Michal Hocko 0 siblings, 1 reply; 10+ messages in thread From: wangwensheng @ 2026-12-04 1:42 UTC (permalink / raw) To: Michal Hocko Cc: vbabka, hannes, surenb, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm On 12/4/26 01:24, Michal Hocko wrote: > On Thu 03-12-26 22:23:06, Wang Wensheng wrote: >> It is not uncommon to enter __alloc_pages_slowpath() with both >> PF_MEMALLOC and __GFP_NOFAIL set during memory reclaim. The original >> warning was placed where an allocation attempt had failed, intended to >> alert about a potential silent stall: with PF_MEMALLOC, direct reclaim >> cannot be performed, while __GFP_NOFAIL forces the allocation to keep >> retrying. >> >> Commit 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in >> a more appropriate location and manner") moved this warning to the >> very start of __alloc_pages_slowpath(), before any allocation attempt. >> This causes frequent false positives: PF_MEMALLOC allows allocations >> to ignore watermarks, and the fastpath only checks the low watermark, >> so the first allocation attempt inside the slowpath is likely to >> succeed. > > So essentially you are telling that we shouldn't warn if the allocation > just manages to succeeds because there are memory reserves available. > While the intention of the code is to catch the unsupported GFP_NOFAIL > use from the allocation context. See the difference? > Am I right to understand that __GFP_NOFAIL must not be used together with PF_MEMALLOC? In ext4, however, many memory allocation failures are hard to handle gracefully. Meanwhile, PF_MEMALLOC is set within the reclaim path and has no direct connection to ext4. This rule would therefore couple these two subsystems, which seems difficult to adhere to. Besides, it does not make sense to emit warnings when user workloads remain unaffected — I believe this should be a common understanding. Hence this warning needs to be addressed. Do you have any alternative suggestions for this scenario? For additional context: this issue occurs on an embedded system. We have very little free memory, the workload is stable with low memory usage fluctuation. The same workload ran for a long time without trouble on older kernels. On the new kernel, we only hit this warning rather than an OOM. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath 2026-12-04 1:42 ` wangwensheng @ 2026-12-04 9:29 ` Michal Hocko 0 siblings, 0 replies; 10+ messages in thread From: Michal Hocko @ 2026-12-04 9:29 UTC (permalink / raw) To: wangwensheng Cc: vbabka, hannes, surenb, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm On Fri 04-12-26 09:42:55, wangwensheng wrote: > > > On 12/4/26 01:24, Michal Hocko wrote: > > On Thu 03-12-26 22:23:06, Wang Wensheng wrote: > > > It is not uncommon to enter __alloc_pages_slowpath() with both > > > PF_MEMALLOC and __GFP_NOFAIL set during memory reclaim. The original > > > warning was placed where an allocation attempt had failed, intended to > > > alert about a potential silent stall: with PF_MEMALLOC, direct reclaim > > > cannot be performed, while __GFP_NOFAIL forces the allocation to keep > > > retrying. > > > > > > Commit 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in > > > a more appropriate location and manner") moved this warning to the > > > very start of __alloc_pages_slowpath(), before any allocation attempt. > > > This causes frequent false positives: PF_MEMALLOC allows allocations > > > to ignore watermarks, and the fastpath only checks the low watermark, > > > so the first allocation attempt inside the slowpath is likely to > > > succeed. > > > > So essentially you are telling that we shouldn't warn if the allocation > > just manages to succeeds because there are memory reserves available. > > While the intention of the code is to catch the unsupported GFP_NOFAIL > > use from the allocation context. See the difference? > > > > Am I right to understand that __GFP_NOFAIL must not be used together with > PF_MEMALLOC? In ext4, however, many memory allocation failures are hard to > handle gracefully. Meanwhile, PF_MEMALLOC is set within the reclaim path and > has no direct connection to ext4. This rule would therefore couple these two > subsystems, which seems difficult to adhere to. GFP_NOFAIL allocations from the memory reclaim context are simply broken! There is no way to guanratee any forward progress while being stuck in the page allocator which is blocking the reclaim. This is a dead lock scenario. See? > Besides, it does not make sense to emit warnings when user workloads remain > unaffected — I believe this should be a common understanding. Hence this > warning needs to be addressed. Do you have any alternative suggestions for > this scenario? Yes, do not require NOFAIL allocation from the memory reclaim path. Exactly what the warning tells you. > For additional context: this issue occurs on an embedded system. We have > very little free memory, the workload is stable with low memory usage > fluctuation. The same workload ran for a long time without trouble on older > kernels. On the new kernel, we only hit this warning rather than an OOM. THis is not about how much memory there really is. This is about a wrong memory allocation use. If the caller can handle allocation failure gracefully it shouldn't use NOFAIL in the first place. -- Michal Hocko SUSE Labs ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath 2026-12-03 14:23 ` [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath Wang Wensheng 2026-12-03 17:24 ` Michal Hocko @ 2026-12-04 9:06 ` Vlastimil Babka (SUSE) 1 sibling, 0 replies; 10+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-12-04 9:06 UTC (permalink / raw) To: Wang Wensheng, hannes, surenb, mhocko, brendan.jackman, ziy, akpm, chrisl, kasong, shikemeng, nphamcs, baoquan.he, baohua, youngjun.park, david, linux-mm, Jan Kara On 12/3/26 15:23, Wang Wensheng wrote: > It is not uncommon to enter __alloc_pages_slowpath() with both > PF_MEMALLOC and __GFP_NOFAIL set during memory reclaim. The original > warning was placed where an allocation attempt had failed, intended to > alert about a potential silent stall: with PF_MEMALLOC, direct reclaim > cannot be performed, while __GFP_NOFAIL forces the allocation to keep > retrying. > > Commit 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in > a more appropriate location and manner") moved this warning to the > very start of __alloc_pages_slowpath(), before any allocation attempt. > This causes frequent false positives: PF_MEMALLOC allows allocations > to ignore watermarks, and the fastpath only checks the low watermark, > so the first allocation attempt inside the slowpath is likely to > succeed. > > Move the warning to the nopage label to suppress these false warnings. > The following calltrace triggers the spurious warning: > __alloc_pages_slowpath > __alloc_frozen_pages_noprof > __folio_alloc_noprof > __filemap_get_folio > ext4_mb_load_buddy_gfp > ext4_free_blocks > ext4_ext_remove_space > ext4_ext_truncate > ext4_truncate > ext4_evict_inode > evict > iput > dentry_unlink_inode > __dentry_kill > shrink_dentry_list > prune_dcache_sb > super_cache_scan > do_shrink_slab > shrink_slab > shrink_node > do_try_to_free_pages > try_to_free_pages > __alloc_pages_direct_reclaim > __alloc_pages_slowpath > __alloc_frozen_pages_noprof > __folio_alloc_noprof > vma_alloc_zeroed_movable_folio > > Fixes: 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in a more appropriate location and manner") > Signed-off-by: Wang Wensheng <wsw9603@163.com> This is just shooting the messenger. The real fix to this issue is here: https://lore.kernel.org/all/20261201105733.18997-1-jack@suse.cz/ > --- > mm/page_alloc.c | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 2fef4092c913..abdf4ba3f757 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -4823,19 +4823,11 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > can_compact = can_direct_reclaim && gfp_compaction_allowed(gfp_mask); > nofail = gfp_mask & __GFP_NOFAIL; > > - if (unlikely(nofail)) { > - /* > - * We don't support __GFP_NOFAIL without __GFP_DIRECT_RECLAIM, > - * otherwise, we may result in lockup. > - */ > - WARN_ON_ONCE(!can_direct_reclaim); > - /* > - * PF_MEMALLOC request from this context is rather bizarre > - * because we cannot reclaim anything and only can loop waiting > - * for somebody to do a work for us. > - */ > - WARN_ON_ONCE(current->flags & PF_MEMALLOC); > - } > + /* > + * We don't support __GFP_NOFAIL without __GFP_DIRECT_RECLAIM, > + * otherwise, we may result in lockup. > + */ > + WARN_ON_ONCE(unlikely(nofail) && !can_direct_reclaim); > > restart: > compaction_retries = 0; > @@ -5124,6 +5116,13 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > if (page) > goto got_pg; > > + /* > + * PF_MEMALLOC request from this context is rather bizarre > + * because we cannot reclaim anything and only can loop waiting > + * for somebody to do a work for us. > + */ > + WARN_ON_ONCE(current->flags & PF_MEMALLOC); > + > cond_resched(); > goto retry; > } ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-04 9:30 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-03 14:23 [PATCH 0/2] Fix spurious warnings about memory allocation Wang Wensheng 2026-12-03 14:23 ` [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed Wang Wensheng 2026-12-04 2:32 ` Youngjun Park 2026-12-04 5:06 ` wangwensheng 2026-12-04 8:21 ` Dev Jain 2026-12-03 14:23 ` [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath Wang Wensheng 2026-12-03 17:24 ` Michal Hocko 2026-12-04 1:42 ` wangwensheng 2026-12-04 9:29 ` Michal Hocko 2026-12-04 9:06 ` Vlastimil Babka (SUSE)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox