summaryrefslogtreecommitdiff
path: root/kernel/sched
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2022-05-18 21:49:53 +0300
committerPeter Zijlstra <peterz@infradead.org>2022-05-20 00:46:09 +0300
commit8491d1bdf5de152f27fc941e2dcdc4e66c950542 (patch)
treec971126e067abf917f5204a5cd2ce87305240cae /kernel/sched
parentc2df0a6af177b6c06a859806a876f92b072dc624 (diff)
downloadlinux-8491d1bdf5de152f27fc941e2dcdc4e66c950542.tar.xz
sched/clock: Use try_cmpxchg64 in sched_clock_{local,remote}
Use try_cmpxchg64 instead of cmpxchg64 (*ptr, old, new) != old in sched_clock_{local,remote}. x86 cmpxchg returns success in ZF flag, so this change saves a compare after cmpxchg (and related move instruction in front of cmpxchg). Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220518184953.3446778-1-ubizjak@gmail.com
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/clock.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index d9272d9061a3..e374c0c923da 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -287,7 +287,7 @@ again:
clock = wrap_max(clock, min_clock);
clock = wrap_min(clock, max_clock);
- if (cmpxchg64(&scd->clock, old_clock, clock) != old_clock)
+ if (!try_cmpxchg64(&scd->clock, &old_clock, clock))
goto again;
return clock;
@@ -349,7 +349,7 @@ again:
val = remote_clock;
}
- if (cmpxchg64(ptr, old_val, val) != old_val)
+ if (!try_cmpxchg64(ptr, &old_val, val))
goto again;
return val;