[PATCH] KVM: pvclock_clocksource_read while-loop optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reduce the number of while-loop iterations (from two to one in the most
common situation)

Signed-off-by: Arjan Koers <0h61vkll2ly8@xxxxxxxxxx>

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;
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux