From d568d3ce199a95b9679f12ac8f14d6ca0f10cb2f Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Mon, 20 Mar 2023 15:03:39 -0300 Subject: [PATCH] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local 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). Link: https://lkml.kernel.org/r/20230320180745.709381791@redhat.com Signed-off-by: Marcelo Tosatti Acked-by: Peter Xu Cc: Aaron Tomlin Cc: Christoph Lameter Cc: Frederic Weisbecker Cc: Heiko Carstens Cc: Huacai Chen Cc: Michal Hocko Cc: "Russell King (Oracle)" Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- kernel/fork.c | 2 +- kernel/scs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 639228be0115..2066a57786a8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -203,7 +203,7 @@ static bool try_release_thread_stack_to_cache(struct vm_struct *vm) 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; } diff --git a/kernel/scs.c b/kernel/scs.c index d7809affe740..08b4af1a3f4d 100644 --- a/kernel/scs.c +++ b/kernel/scs.c @@ -83,7 +83,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); -- 2.50.1