diff options
author | Hou Tao <houtao1@huawei.com> | 2023-10-20 21:31:56 +0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-10-20 10:12:54 -0700 |
commit | 394e6869f0185e89cb815db29bf819474df858ae (patch) | |
tree | b01d8ee6e2f3b518a0db7e12644a3fd7490c1e87 /mm/percpu.c | |
parent | da1055b673f3baac2249571c9882ce767a0aa746 (diff) |
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: Dennis Zhou <dennis@kernel.org>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20231020133202.4043247-2-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'mm/percpu.c')
-rw-r--r-- | mm/percpu.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/mm/percpu.c b/mm/percpu.c index a7665de8485f..ea607078368d 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); |