* [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning()
@ 2025-03-10 12:40 Alexei Starovoitov
2025-03-10 22:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2025-03-10 12:40 UTC (permalink / raw)
To: bpf; +Cc: daniel, andrii, martin.lau, vbabka, linux-mm, kernel-team
From: Vlastimil Babka <vbabka@suse.cz>
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>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/gfp.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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);
}
#ifdef CONFIG_HIGHMEM
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() 2025-03-10 12:40 [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() Alexei Starovoitov @ 2025-03-10 22:30 ` patchwork-bot+netdevbpf 0 siblings, 0 replies; 4+ messages in thread From: patchwork-bot+netdevbpf @ 2025-03-10 22:30 UTC (permalink / raw) To: Alexei Starovoitov Cc: bpf, daniel, andrii, martin.lau, vbabka, linux-mm, kernel-team Hello: This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <andrii@kernel.org>: On Mon, 10 Mar 2025 13:40:17 +0100 you wrote: > From: Vlastimil Babka <vbabka@suse.cz> > > 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. > > [...] Here is the summary with links: - [bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() https://git.kernel.org/bpf/bpf-next/c/157a50236c30 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <202503101254.cfd454df-lkp@intel.com>]
[parent not found: <7c41d8d7-7d5a-4c3d-97b3-23642e376ff9@suse.cz>]
[parent not found: <CAADnVQ+NKZtNxS+jBW=tMnmca18S2jfuGCR+ap1bPHYyhxy6HQ@mail.gmail.com>]
[parent not found: <a30e2c60-e01b-4eac-8a40-e7a73abebfd3@suse.cz>]
[parent not found: <CAADnVQ+g=VN6cOVzhF2ory0isXEc52W8fKx4KdwpYfOMvk372A@mail.gmail.com>]
[parent not found: <9d8f5f92-5f4b-4732-af48-3ecaa41af81a@suse.cz>]
* Fwd: [linux-next:master] [memcg] 01d37228d3: netperf.Throughput_Mbps 37.9% regression [not found] ` <9d8f5f92-5f4b-4732-af48-3ecaa41af81a@suse.cz> @ 2025-03-10 11:15 ` Alexei Starovoitov 2025-03-10 12:16 ` [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() Alexei Starovoitov 0 siblings, 1 reply; 4+ messages in thread From: Alexei Starovoitov @ 2025-03-10 11:15 UTC (permalink / raw) To: bpf, Vlastimil Babka, Shakeel Butt fwd to bpf list for BPF CI to pick it up. ---------- Forwarded message --------- From: Vlastimil Babka <vbabka@suse.cz> Date: Mon, Mar 10, 2025 at 12:03 PM Subject: Re: [linux-next:master] [memcg] 01d37228d3: netperf.Throughput_Mbps 37.9% regression To: Alexei Starovoitov <alexei.starovoitov@gmail.com> Cc: kernel test robot <oliver.sang@intel.com>, Alexei Starovoitov <ast@kernel.org>, <oe-lkp@lists.linux.dev>, kbuild test robot <lkp@intel.com>, Michal Hocko <mhocko@suse.com>, Shakeel Butt <shakeel.butt@linux.dev>, open list:CONTROL GROUP (CGROUP) <cgroups@vger.kernel.org>, linux-mm <linux-mm@kvack.org> On 3/10/25 11:56, Alexei Starovoitov wrote: > On Mon, Mar 10, 2025 at 11:34 AM Vlastimil Babka <vbabka@suse.cz> wrote: >> >> On 3/10/25 11:18, Alexei Starovoitov wrote: >> >> because this will affect the refill even if consume_stock() fails not due to >> >> a trylock failure (which should not be happening), but also just because the >> >> stock was of a wrong memcg or depleted. So in the nowait context we deny the >> >> refill even if we have the memory. Attached patch could be used to see if it >> >> if fixes things. I'm not sure about the testcases where it doesn't look like >> >> nowait context would be used though, let's see. >> > >> > Not quite. >> > GFP_NOWAIT includes __GFP_KSWAPD_RECLAIM, >> > so gfpflags_allow_spinning() will return true. >> >> Uh right, it's the new gfpflags_allow_spinning(), not the >> gfpflags_allow_blocking() I'm used to and implicitly assumed, sorry. >> >> But then it's very simple because it has a bug: >> gfpflags_allow_spinning() does >> >> return !(gfp_flags & __GFP_RECLAIM); >> >> should be !! > > Ouch. > So I accidentally exposed the whole linux-next to this stress testing > of new trylock facilities :( > But the silver lining is that this is the only thing that blew up :) > Could you send a patch or I will do it later today. OK ----8<---- 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(-) 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); } #ifdef CONFIG_HIGHMEM -- 2.48.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() 2025-03-10 11:15 ` Fwd: [linux-next:master] [memcg] 01d37228d3: netperf.Throughput_Mbps 37.9% regression Alexei Starovoitov @ 2025-03-10 12:16 ` Alexei Starovoitov 2025-03-10 16:03 ` Shakeel Butt 0 siblings, 1 reply; 4+ messages in thread From: Alexei Starovoitov @ 2025-03-10 12:16 UTC (permalink / raw) To: bpf 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(-) 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); } #ifdef CONFIG_HIGHMEM -- 2.48.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() 2025-03-10 12:16 ` [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() Alexei Starovoitov @ 2025-03-10 16:03 ` Shakeel Butt 0 siblings, 0 replies; 4+ messages in thread From: Shakeel Butt @ 2025-03-10 16:03 UTC (permalink / raw) To: Alexei Starovoitov; +Cc: bpf 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> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-10 22:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 12:40 [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() Alexei Starovoitov
2025-03-10 22:30 ` patchwork-bot+netdevbpf
[not found] <202503101254.cfd454df-lkp@intel.com>
[not found] ` <7c41d8d7-7d5a-4c3d-97b3-23642e376ff9@suse.cz>
[not found] ` <CAADnVQ+NKZtNxS+jBW=tMnmca18S2jfuGCR+ap1bPHYyhxy6HQ@mail.gmail.com>
[not found] ` <a30e2c60-e01b-4eac-8a40-e7a73abebfd3@suse.cz>
[not found] ` <CAADnVQ+g=VN6cOVzhF2ory0isXEc52W8fKx4KdwpYfOMvk372A@mail.gmail.com>
[not found] ` <9d8f5f92-5f4b-4732-af48-3ecaa41af81a@suse.cz>
2025-03-10 11:15 ` Fwd: [linux-next:master] [memcg] 01d37228d3: netperf.Throughput_Mbps 37.9% regression Alexei Starovoitov
2025-03-10 12:16 ` [PATCH bpf-next] mm: Fix the flipped condition in gfpflags_allow_spinning() Alexei Starovoitov
2025-03-10 16:03 ` Shakeel Butt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox