* [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated
@ 2021-06-18 15:14 Wan Jiabing
2021-06-18 18:20 ` Dennis Zhou
0 siblings, 1 reply; 2+ messages in thread
From: Wan Jiabing @ 2021-06-18 15:14 UTC (permalink / raw)
To: Dennis Zhou, Tejun Heo, Christoph Lameter, Andrew Morton,
linux-mm, linux-kernel
Cc: kael_w, Wan Jiabing
Fix coccicheck warning:
./mm/percpu.c:2045:19-29: ERROR: function pcpu_balance_populated
called on line 2232 inside lock on line 2228 but uses GFP_KERNEL
When pcpu_balance_populated() is called in pcpu_balance_workfn(),
it helds spin_lock but use GFP_KERNEL to alloc mem, which is unsafe.
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
mm/percpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index b4cebeca4c0c..4031f32e6975 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -2042,7 +2042,7 @@ static void pcpu_balance_free(bool empty_only)
static void pcpu_balance_populated(void)
{
/* gfp flags passed to underlying allocators */
- const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
+ const gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
struct pcpu_chunk *chunk;
int slot, nr_to_pop, ret;
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated
2021-06-18 15:14 [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated Wan Jiabing
@ 2021-06-18 18:20 ` Dennis Zhou
0 siblings, 0 replies; 2+ messages in thread
From: Dennis Zhou @ 2021-06-18 18:20 UTC (permalink / raw)
To: Wan Jiabing
Cc: Tejun Heo, Christoph Lameter, Andrew Morton, linux-mm,
linux-kernel, kael_w
Hello,
On Fri, Jun 18, 2021 at 11:14:36PM +0800, Wan Jiabing wrote:
> Fix coccicheck warning:
>
> ./mm/percpu.c:2045:19-29: ERROR: function pcpu_balance_populated
> called on line 2232 inside lock on line 2228 but uses GFP_KERNEL
>
> When pcpu_balance_populated() is called in pcpu_balance_workfn(),
> it helds spin_lock but use GFP_KERNEL to alloc mem, which is unsafe.
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
> mm/percpu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/percpu.c b/mm/percpu.c
> index b4cebeca4c0c..4031f32e6975 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -2042,7 +2042,7 @@ static void pcpu_balance_free(bool empty_only)
> static void pcpu_balance_populated(void)
> {
> /* gfp flags passed to underlying allocators */
> - const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
> + const gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
> struct pcpu_chunk *chunk;
> int slot, nr_to_pop, ret;
>
> --
> 2.30.2
>
In both places gfp flags are passed, the pcpu_lock is dropped. So I
think this is an issue with coccicheck. Regardless, the fix wouldn't be
to switch to GFP_ATOMIC but to make the locking correct.
Thanks,
Dennis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-18 18:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 15:14 [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated Wan Jiabing
2021-06-18 18:20 ` Dennis Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).