diff mbox series

[bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning()

Message ID CAADnVQ+XGfYX0EzLJMVYDa05zY3DS4Ahvpq0XkKuzifwTJdY9w@mail.gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/apply fail Patch does not apply to bpf-next-0
bpf/vmtest-bpf-net-PR fail merge-conflict

Commit Message

Alexei Starovoitov March 10, 2025, 12:16 p.m. UTC
From 69b3d1631645c82d9d88f17fb01184d24034df2b Mon Sep 17 00:00:00 2001
From: Vlastimil Babka <vbabka@suse.cz>
Date: Mon, 10 Mar 2025 11:57:52 +0100
Subject: [PATCH] mm: Fix the flipped condition in gfpflags_allow_spinning()

The function gfpflags_allow_spinning() has a bug that makes it return
the opposite result than intended. This could contribute to deadlocks as
usage profilerates, for now it was noticed as a performance regression
due to try_charge_memcg() not refilling memcg stock when it could. Fix
the flipped condition.

Fixes: 97769a53f117 ("mm, bpf: Introduce try_alloc_pages() for
opportunistic page allocation")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202503101254.cfd454df-lkp@intel.com

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 include/linux/gfp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

 #ifdef CONFIG_HIGHMEM
--
2.48.1

Comments

Shakeel Butt March 10, 2025, 4:03 p.m. UTC | #1
On Mon, Mar 10, 2025 at 01:16:45PM +0100, Alexei Starovoitov wrote:
> From 69b3d1631645c82d9d88f17fb01184d24034df2b Mon Sep 17 00:00:00 2001
> From: Vlastimil Babka <vbabka@suse.cz>
> Date: Mon, 10 Mar 2025 11:57:52 +0100
> Subject: [PATCH] mm: Fix the flipped condition in gfpflags_allow_spinning()
> 
> The function gfpflags_allow_spinning() has a bug that makes it return
> the opposite result than intended. This could contribute to deadlocks as
> usage profilerates, for now it was noticed as a performance regression
> due to try_charge_memcg() not refilling memcg stock when it could. Fix
> the flipped condition.
> 
> Fixes: 97769a53f117 ("mm, bpf: Introduce try_alloc_pages() for
> opportunistic page allocation")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202503101254.cfd454df-lkp@intel.com
> 
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
diff mbox series

Patch

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index ceb226c2e25c..c9fa6309c903 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -55,7 +55,7 @@  static inline bool gfpflags_allow_spinning(const
gfp_t gfp_flags)
         * regular page allocator doesn't fully support this
         * allocation mode.
         */
-       return !(gfp_flags & __GFP_RECLAIM);
+       return !!(gfp_flags & __GFP_RECLAIM);
 }