Re: [PATCH bpf-next v2 1/7] mm/percpu.c: don't acquire pcpu_lock for pcpu_chunk_addr_search()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 18, 2023 at 07:33:37PM +0800, Hou Tao wrote:
> From: Hou Tao <houtao1@xxxxxxxxxx>
> 
> There is no need to acquire pcpu_lock for pcpu_chunk_addr_search():
> 1) both pcpu_first_chunk & pcpu_reserved_chunk must have been
>    initialized before the invocation of free_percpu().
> 2) The dynamically-created chunk must be valid before the per-cpu
>    pointers allocated from it are freed.
> 
> So acquire pcpu_lock() after the invocation of pcpu_chunk_addr_search().
> 
> Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
> ---
>  mm/percpu.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 7b40b3963f10..76b9c5e63c56 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -2267,12 +2267,10 @@ void free_percpu(void __percpu *ptr)
>  	kmemleak_free_percpu(ptr);
>  
>  	addr = __pcpu_ptr_to_addr(ptr);
> -
> -	spin_lock_irqsave(&pcpu_lock, flags);
> -
>  	chunk = pcpu_chunk_addr_search(addr);
>  	off = addr - chunk->base_addr;
>  
> +	spin_lock_irqsave(&pcpu_lock, flags);
>  	size = pcpu_free_area(chunk, off);
>  
>  	pcpu_memcg_free_hook(chunk, off, size);
> -- 
> 2.29.2
> 

Acked-by: Dennis Zhou <dennis@xxxxxxxxxx>

Thanks,
Dennis




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux