Commit 394e6869 authored by Hou Tao's avatar Hou Tao Committed by Alexei Starovoitov

mm/percpu.c: don't acquire pcpu_lock for pcpu_chunk_addr_search()

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().
Acked-by: default avatarDennis Zhou <dennis@kernel.org>
Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20231020133202.4043247-2-houtao@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent da1055b6
...@@ -2267,12 +2267,10 @@ void free_percpu(void __percpu *ptr) ...@@ -2267,12 +2267,10 @@ void free_percpu(void __percpu *ptr)
kmemleak_free_percpu(ptr); kmemleak_free_percpu(ptr);
addr = __pcpu_ptr_to_addr(ptr); addr = __pcpu_ptr_to_addr(ptr);
spin_lock_irqsave(&pcpu_lock, flags);
chunk = pcpu_chunk_addr_search(addr); chunk = pcpu_chunk_addr_search(addr);
off = addr - chunk->base_addr; off = addr - chunk->base_addr;
spin_lock_irqsave(&pcpu_lock, flags);
size = pcpu_free_area(chunk, off); size = pcpu_free_area(chunk, off);
pcpu_memcg_free_hook(chunk, off, size); pcpu_memcg_free_hook(chunk, off, size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment