Skip to content

Commit 00e89bd

Browse files
urezkiakpm00
authored andcommitted
vmalloc: use atomic_long_add_return_relaxed()
Switch from the atomic_long_add_return() to its relaxed version. We do not need a full memory barrier or any memory ordering during increasing the "vmap_lazy_nr" variable. What we only need is to do it atomically. This is what atomic_long_add_return_relaxed() guarantees. AARCH64: <snip> Default: 40ec: d34cfe94 lsr x20, x20, torvalds#12 40f0: 1400004 b 4200 <free_vmap_area_noflush+0x19c> 40f4: 94000000 bl 0 <__sanitizer_cov_trace_pc> 40f8: 90000000 adrp x0, 0 <__traceiter_alloc_vmap_area> 40fc: 91000000 add x0, x0, #0x0 4100: f8f40016 ldaddal x20, x22, [x0] 4104: 8b160296 add x22, x20, x22 Relaxed: 40ec: d34cfe94 lsr x20, x20, torvalds#12 40f0: 1400004 b 4200 <free_vmap_area_noflush+0x19c> 40f4: 94000000 bl 0 <__sanitizer_cov_trace_pc> 40f8: 90000000 adrp x0, 0 <__traceiter_alloc_vmap_area> 40fc: 91000000 add x0, x0, #0x0 4100: f8340016 ldadd x20, x22, [x0] 4104: 8b160296 add x22, x20, x22 <snip> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Reviewed-by: Baoquan He <[email protected]> Cc: Christop Hellwig <[email protected]> Cc: Mateusz Guzik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2b0e82f commit 00e89bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/vmalloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ static void free_vmap_area_noflush(struct vmap_area *va)
23702370
if (WARN_ON_ONCE(!list_empty(&va->list)))
23712371
return;
23722372

2373-
nr_lazy = atomic_long_add_return(va_size(va) >> PAGE_SHIFT,
2373+
nr_lazy = atomic_long_add_return_relaxed(va_size(va) >> PAGE_SHIFT,
23742374
&vmap_lazy_nr);
23752375

23762376
/*

0 commit comments

Comments
 (0)