From: Arjan Koers <0h61vkll2ly8@xutrox.com>
To: kvm@vger.kernel.org
Subject: [PATCH] KVM: pvclock_clocksource_read while-loop optimization
Date: Tue, 19 Oct 2010 22:05:39 +0200 [thread overview]
Message-ID: <4CBDFA13.4080007@xutrox.com> (raw)
Reduce the number of while-loop iterations (from two to one in the most
common situation)
Signed-off-by: Arjan Koers <0h61vkll2ly8@xutrox.com>
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index bab3b9e..995d479 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -126,7 +126,7 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
struct pvclock_shadow_time shadow;
unsigned version;
cycle_t ret, offset;
- u64 last;
+ u64 last, save;
do {
version = pvclock_get_time_values(&shadow, src);
@@ -158,8 +158,9 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
do {
if (ret < last)
return last;
+ save = last;
last = atomic64_cmpxchg(&last_value, last, ret);
- } while (unlikely(last != ret));
+ } while (unlikely(last != save));
return ret;
}
next reply other threads:[~2010-10-19 20:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 20:05 Arjan Koers [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-01-01 20:51 [PATCH] KVM: pvclock_clocksource_read while-loop optimization Arjan Koers
2011-01-03 16:50 ` Glauber Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CBDFA13.4080007@xutrox.com \
--to=0h61vkll2ly8@xutrox.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.