All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arjan Koers <0h61vkll2ly8@xutrox.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, Glauber Costa <glommer@redhat.com>
Subject: [PATCH] KVM: pvclock_clocksource_read while-loop optimization
Date: Sat, 01 Jan 2011 21:51:03 +0100	[thread overview]
Message-ID: <4D1F93B7.4080707@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 42eb330..8f52acb 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -93,7 +93,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);
@@ -125,8 +125,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;
 }



             reply	other threads:[~2011-01-01 20:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-01 20:51 Arjan Koers [this message]
2011-01-03 16:50 ` [PATCH] KVM: pvclock_clocksource_read while-loop optimization Glauber Costa
  -- strict thread matches above, loose matches on Subject: below --
2010-10-19 20:05 Arjan Koers

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=4D1F93B7.4080707@xutrox.com \
    --to=0h61vkll2ly8@xutrox.com \
    --cc=avi@redhat.com \
    --cc=glommer@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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.