Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Marcelo Tosatti
On Wed, Mar 25, 2015 at 04:22:03PM -0700, Andy Lutomirski wrote: On Wed, Mar 25, 2015 at 4:13 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 03:48:02PM -0700, Andy Lutomirski wrote: On Wed, Mar 25, 2015 at 3:41 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Radim Krcmar
2015-03-26 11:51-0700, Andy Lutomirski: On Thu, Mar 26, 2015 at 4:29 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 04:22:03PM -0700, Andy Lutomirski wrote: Suppose we start out with all vcpus agreeing on their pvti and perfect invariant TSCs. Now the host updates

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
On Thu, Mar 26, 2015 at 4:29 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 04:22:03PM -0700, Andy Lutomirski wrote: On Wed, Mar 25, 2015 at 4:13 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 03:48:02PM -0700, Andy Lutomirski wrote: On Wed,

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Radim Krčmář
2015-03-26 11:47-0700, Andy Lutomirski: On Wed, Mar 25, 2015 at 4:08 AM, Radim Krčmář rkrc...@redhat.com wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c + /* A guest can read other VCPU's kvmclock; specification says that +* version is odd if data is being modified

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
On Thu, Mar 26, 2015 at 1:31 PM, Radim Krcmar rkrc...@redhat.com wrote: 2015-03-26 11:51-0700, Andy Lutomirski: On Thu, Mar 26, 2015 at 4:29 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 04:22:03PM -0700, Andy Lutomirski wrote: Suppose we start out with all vcpus

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Paolo Bonzini
On 26/03/2015 21:10, Radim Krčmář wrote: 2015-03-26 11:47-0700, Andy Lutomirski: On Wed, Mar 25, 2015 at 4:08 AM, Radim Krčmář rkrc...@redhat.com wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c + /* A guest can read other VCPU's kvmclock; specification says that +*

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Radim Krčmář
2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on cpu migration. Add task migration notification back. Problem

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
On Wed, Mar 25, 2015 at 4:08 AM, Radim Krčmář rkrc...@redhat.com wrote: 2015-03-24 15:33-0700, Andy Lutomirski: On Tue, Mar 24, 2015 at 8:34 AM, Radim Krčmář rkrc...@redhat.com wrote: What is the problem? The kvmclock spec says that the host will increment a version field to an odd number,

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
On Thu, Mar 26, 2015 at 4:22 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 04:09:53PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 3:56 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 01:58:25PM -0700, Andy Lutomirski wrote: On Thu,

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Marcelo Tosatti
On Thu, Mar 26, 2015 at 04:28:37PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 4:22 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 04:09:53PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 3:56 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
On Thu, Mar 26, 2015 at 3:56 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 01:58:25PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 1:31 PM, Radim Krcmar rkrc...@redhat.com wrote: 2015-03-26 11:51-0700, Andy Lutomirski: On Thu, Mar 26, 2015 at 4:29 AM,

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
[much snippage] On Thu, Mar 26, 2015 at 1:58 PM, Andy Lutomirski l...@amacapital.net wrote: If the versioning were fixed, I think we could almost get away with: pvti = pvti for vcpu 0; ver1 = pvti-version; check stable bit; rdtsc_barrier, rdtsc, read scale, shift, etc. if (pvti-version

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Marcelo Tosatti
On Thu, Mar 26, 2015 at 09:59:24PM +0100, Radim Krčmář wrote: 2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Andy Lutomirski
On Thu, Mar 26, 2015 at 3:22 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 09:59:24PM +0100, Radim Krčmář wrote: 2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes.

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Marcelo Tosatti
On Thu, Mar 26, 2015 at 03:24:10PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 3:22 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 09:59:24PM +0100, Radim Krčmář wrote: 2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Marcelo Tosatti
On Thu, Mar 26, 2015 at 01:58:25PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 1:31 PM, Radim Krcmar rkrc...@redhat.com wrote: 2015-03-26 11:51-0700, Andy Lutomirski: On Thu, Mar 26, 2015 at 4:29 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 04:22:03PM

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-26 Thread Marcelo Tosatti
On Thu, Mar 26, 2015 at 04:09:53PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 3:56 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Thu, Mar 26, 2015 at 01:58:25PM -0700, Andy Lutomirski wrote: On Thu, Mar 26, 2015 at 1:31 PM, Radim Krcmar rkrc...@redhat.com wrote: 2015-03-26

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Radim Krčmář
2015-03-25 12:08+0100, Radim Krčmář: Reverting the patch protects us from any migration, but I don't think we need to care about changing VCPUs as long as we read a consistent data from kvmclock. (VCPU can change outside of this loop too, so it doesn't matter if we return a value not fit for

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Radim Krčmář
2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on cpu migration. Add task migration notification back. Problem

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Marcelo Tosatti
On Wed, Mar 25, 2015 at 01:52:15PM +0100, Radim Krčmář wrote: 2015-03-25 12:08+0100, Radim Krčmář: Reverting the patch protects us from any migration, but I don't think we need to care about changing VCPUs as long as we read a consistent data from kvmclock. (VCPU can change outside of this

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Andy Lutomirski
On Wed, Mar 25, 2015 at 3:41 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 03:33:10PM -0700, Andy Lutomirski wrote: On Mar 25, 2015 2:29 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 01:52:15PM +0100, Radim Krčmář wrote: 2015-03-25

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Andy Lutomirski
On Wed, Mar 25, 2015 at 4:13 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 03:48:02PM -0700, Andy Lutomirski wrote: On Wed, Mar 25, 2015 at 3:41 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 03:33:10PM -0700, Andy Lutomirski wrote: On Mar 25,

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Marcelo Tosatti
On Wed, Mar 25, 2015 at 03:33:10PM -0700, Andy Lutomirski wrote: On Mar 25, 2015 2:29 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 01:52:15PM +0100, Radim Krčmář wrote: 2015-03-25 12:08+0100, Radim Krčmář: Reverting the patch protects us from any migration,

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Marcelo Tosatti
On Wed, Mar 25, 2015 at 03:48:02PM -0700, Andy Lutomirski wrote: On Wed, Mar 25, 2015 at 3:41 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 03:33:10PM -0700, Andy Lutomirski wrote: On Mar 25, 2015 2:29 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Andy Lutomirski
On Mar 25, 2015 2:29 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Wed, Mar 25, 2015 at 01:52:15PM +0100, Radim Krčmář wrote: 2015-03-25 12:08+0100, Radim Krčmář: Reverting the patch protects us from any migration, but I don't think we need to care about changing VCPUs as long as we

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Radim Krčmář
2015-03-24 15:33-0700, Andy Lutomirski: On Tue, Mar 24, 2015 at 8:34 AM, Radim Krčmář rkrc...@redhat.com wrote: What is the problem? The kvmclock spec says that the host will increment a version field to an odd number, then update stuff, then increment it to an even number. The host is

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-25 Thread Radim Krčmář
2015-03-24 19:59-0300, Marcelo Tosatti: On Tue, Mar 24, 2015 at 04:34:12PM +0100, Radim Krčmář wrote: 2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM:

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-24 Thread Marcelo Tosatti
On Tue, Mar 24, 2015 at 04:34:12PM +0100, Radim Krčmář wrote: 2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-24 Thread Andy Lutomirski
On Tue, Mar 24, 2015 at 8:34 AM, Radim Krčmář rkrc...@redhat.com wrote: 2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-24 Thread Radim Krčmář
2015-03-23 20:21-0300, Marcelo Tosatti: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on cpu migration. I think that the revert doesn't fix point 2.: KVM: x86:

x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-23 Thread Marcelo Tosatti
The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on cpu migration. Add task migration notification back. Problem noticed by Andy Lutomirski. Signed-off-by: Marcelo

Re: x86: kvm: Revert remove sched notifier for cross-cpu migrations

2015-03-23 Thread Andy Lutomirski
On Mon, Mar 23, 2015 at 4:21 PM, Marcelo Tosatti mtosa...@redhat.com wrote: The following point: 2. per-CPU pvclock time info is updated if the underlying CPU changes. Is not true anymore since KVM: x86: update pvclock area conditionally, on cpu migration. Add task migration