fork: Use this_cpu_try_cmpxchg() in try_release_thread_stack_to_cache()
Subsystems (3)
PATCH 1/1 fork: Use this_cpu_try_cmpxchg() in try_release_thread_stack_to_cache()
Use this_cpu_try_cmpxchg() instead ofthis_cpu_cmpxchg (*ptr, old, new) == old in try_release_thread_stack_to_cache. x86 CMPXCHG instruction returns success in ZF flag, so this change saves a compare after cmpxchg (and related move instruction in front of cmpxchg).
No functional change intended.
Signed-off-by Uros Bizjak <[email protected]>
Cc Andrew Morton <[email protected]>
--- kernel/fork.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/fork.c +3 -1
@@ -205,7 +205,9 @@ 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 ) +struct vm_struct *tmp =NULL ; + +if (!this_cpu_try_cmpxchg (cached_stacks[i], &tmp, vm))continue ;return true; }
Signature · 1 line
2.45.1