On Sat, 2011-01-01 at 21:51 +0100, Arjan Koers wrote:
> Reduce the number of while-loop iterations (from two to one in the most
> common situation)
> 
> Signed-off-by: Arjan Koers <[email protected]>
> 
> 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;
>  }
Hey, good catch.



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to