linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC
       [not found] ` <7aa3a1cee63518cb13906d11ea130c9c@208suo.com>
@ 2023-07-18 17:17   ` Andrew Morton
  2023-07-20 23:43     ` Baoquan He
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2023-07-18 17:17 UTC (permalink / raw)
  To: sunran001; +Cc: dennis, tj, cl, linux-mm, linux-kernel

On Tue, 18 Jul 2023 14:35:11 +0800 sunran001@208suo.com wrote:

> ERROR: function pcpu_balance_populated called on line 2238 inside lock
> on line 2234 but uses GFP_KERNEL
> 
> Generated by: scripts/coccinelle/locks/call_kern.cocci
> 
> ...
>
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -2033,7 +2033,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;

I don't believe this warning is correct.  

			spin_unlock_irq(&pcpu_lock);
			ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp);
			cond_resched();
			spin_lock_irq(&pcpu_lock);



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC
  2023-07-18 17:17   ` [PATCH] mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC Andrew Morton
@ 2023-07-20 23:43     ` Baoquan He
  0 siblings, 0 replies; 2+ messages in thread
From: Baoquan He @ 2023-07-20 23:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: sunran001, dennis, tj, cl, linux-mm, linux-kernel

On 07/18/23 at 10:17am, Andrew Morton wrote:
> On Tue, 18 Jul 2023 14:35:11 +0800 sunran001@208suo.com wrote:
> 
> > ERROR: function pcpu_balance_populated called on line 2238 inside lock
> > on line 2234 but uses GFP_KERNEL
> > 
> > Generated by: scripts/coccinelle/locks/call_kern.cocci
> > 
> > ...
> >
> > --- a/mm/percpu.c
> > +++ b/mm/percpu.c
> > @@ -2033,7 +2033,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;
> 
> I don't believe this warning is correct.  

Yeah, the warning is false positive. It releases the lock when
requesting memory allocation, then take the lock again.

> 
> 			spin_unlock_irq(&pcpu_lock);
> 			ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp);
> 			cond_resched();
> 			spin_lock_irq(&pcpu_lock);
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-20 23:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230718063328.16140-1-xujianghui@cdjrlc.com>
     [not found] ` <7aa3a1cee63518cb13906d11ea130c9c@208suo.com>
2023-07-18 17:17   ` [PATCH] mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC Andrew Morton
2023-07-20 23:43     ` Baoquan He

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).