[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <165299699122.4207.8125991535807221103.tip-bot2@tip-bot2>
Date: Thu, 19 May 2022 21:49:51 -0000
From: "tip-bot2 for Uros Bizjak" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: locking/core] sched/clock: Use try_cmpxchg64 in
sched_clock_{local,remote}
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 8491d1bdf5de152f27fc941e2dcdc4e66c950542
Gitweb: https://git.kernel.org/tip/8491d1bdf5de152f27fc941e2dcdc4e66c950542
Author: Uros Bizjak <ubizjak@...il.com>
AuthorDate: Wed, 18 May 2022 20:49:53 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Thu, 19 May 2022 23:46:09 +02:00
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@...il.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Link: https://lkml.kernel.org/r/20220518184953.3446778-1-ubizjak@gmail.com
---
kernel/sched/clock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index d9272d9..e374c0c 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;
Powered by blists - more mailing lists