diff mbox series

[v2,07/11] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local

Message ID 20230209153204.818774692@redhat.com (mailing list archive)
State New
Headers show
Series fold per-CPU vmstats remotely | expand

Commit Message

Marcelo Tosatti Feb. 9, 2023, 3:01 p.m. UTC
this_cpu_cmpxchg was modified to atomic version, which 
can be more costly than non-atomic version.

Switch users of this_cpu_cmpxchg to this_cpu_cmpxchg_local
(which preserves pre-non-atomic this_cpu_cmpxchg behaviour).

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Comments

Peter Xu March 2, 2023, 8:54 p.m. UTC | #1
On Thu, Feb 09, 2023 at 12:01:57PM -0300, Marcelo Tosatti wrote:
> this_cpu_cmpxchg was modified to atomic version, which 
> can be more costly than non-atomic version.
> 
> Switch users of this_cpu_cmpxchg to this_cpu_cmpxchg_local
> (which preserves pre-non-atomic this_cpu_cmpxchg behaviour).
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Yes afaict these are the only pieces that uses the helper besides vmstat
udpates.

Acked-by: Peter Xu <peterx@redhat.com>
diff mbox series

Patch

Index: linux-vmstat-remote/kernel/fork.c
===================================================================
--- linux-vmstat-remote.orig/kernel/fork.c
+++ linux-vmstat-remote/kernel/fork.c
@@ -203,7 +203,7 @@  static bool try_release_thread_stack_to_
 	unsigned int i;
 
 	for (i = 0; i < NR_CACHED_STACKS; i++) {
-		if (this_cpu_cmpxchg(cached_stacks[i], NULL, vm) != NULL)
+		if (this_cpu_cmpxchg_local(cached_stacks[i], NULL, vm) != NULL)
 			continue;
 		return true;
 	}
Index: linux-vmstat-remote/kernel/scs.c
===================================================================
--- linux-vmstat-remote.orig/kernel/scs.c
+++ linux-vmstat-remote/kernel/scs.c
@@ -79,7 +79,7 @@  void scs_free(void *s)
 	 */
 
 	for (i = 0; i < NR_CACHED_SCS; i++)
-		if (this_cpu_cmpxchg(scs_cache[i], 0, s) == NULL)
+		if (this_cpu_cmpxchg_local(scs_cache[i], 0, s) == NULL)
 			return;
 
 	kasan_unpoison_vmalloc(s, SCS_SIZE, KASAN_VMALLOC_PROT_NORMAL);