[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4C430F80.9020100@redhat.com>
Date: Sun, 18 Jul 2010 17:28:16 +0300
From: Avi Kivity <avi@...hat.com>
To: Zachary Amsden <zamsden@...hat.com>
CC: KVM <kvm@...r.kernel.org>, Marcelo Tosatti <mtosatti@...hat.com>,
Glauber Costa <glommer@...hat.com>,
Linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 01/18] Make TSC offset writes non-preemptible
On 07/13/2010 05:25 AM, Zachary Amsden wrote:
> Ensure that the storing of the offset and the reading of the TSC
> are never preempted by taking a spinlock. While the lock is overkill
> now, it is useful later in this patch series.
>
>
>
This patch has both code movement and semantic changes. Please split
into two so it's easier to understand which are which.
> /*
> - * writes 'guest_tsc' into guest's timestamp counter "register"
> - * guest_tsc = host_tsc + tsc_offset ==> tsc_offset = guest_tsc - host_tsc
> + * writes 'offset' into guest's timestamp counter offset register
> */
> -static void guest_write_tsc(u64 guest_tsc, u64 host_tsc)
> +static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
>
Shouldn't offset be an s64? Doesn't matter in practice, of course, but
offset would usually be negative, not some huge number that happens to
roll the guest tsc around.
> {
> - vmcs_write64(TSC_OFFSET, guest_tsc - host_tsc);
> + vmcs_write64(TSC_OFFSET, offset);
> }
>
>
>
>
> +void guest_write_tsc(struct kvm_vcpu *vcpu, u64 data)
> +{
> + struct kvm *kvm = vcpu->kvm;
> + u64 offset;
> +
> + spin_lock(&kvm->arch.tsc_write_lock);
> + offset = data - native_read_tsc();
> + kvm_x86_ops->write_tsc_offset(vcpu, offset);
> + spin_unlock(&kvm->arch.tsc_write_lock);
> +
> + /* Reset of TSC must disable overshoot protection below */
> + vcpu->arch.hv_clock.tsc_timestamp = 0;
> +}
> +EXPORT_SYMBOL_GPL(guest_write_tsc);
> +
>
Exported symbols should start with kvm_.
--
error compiling committee.c: too many arguments to function
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists