From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: x86: kvm: Revert "remove sched notifier for cross-cpu migrations" Date: Thu, 26 Mar 2015 21:59:24 +0100 Message-ID: <20150326205924.GD13271@potion.brq.redhat.com> References: <20150323232151.GA12772@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm-devel , stable@vger.kernel.org, Paolo Bonzini , Andy Lutomirski To: Marcelo Tosatti Return-path: Content-Disposition: inline In-Reply-To: <20150323232151.GA12772@amt.cnet> Sender: stable-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 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 noticed by Andy Lutomirski. > > Signed-off-by: Marcelo Tosatti > CC: stable@kernel.org # 3.11+ Revert contains a bug that got pointed out in the discussion: > diff --git a/arch/x86/vdso/vclock_gettime.c b/arch/x86/vdso/vclock_gettime.c > do { > cpu = __getcpu() & VGETCPU_CPU_MASK; > > pvti = get_pvti(cpu); We can migrate to 'other cpu' here. > + migrate_count = pvti->migrate_count; > + > version = __pvclock_read_cycles(&pvti->pvti, &ret, &flags); And migrate back to 'cpu' here. rdtsc was executed on different cpu, so pvti and tsc might not be in sync, but migrate_count hasn't changed. > cpu1 = __getcpu() & VGETCPU_CPU_MASK; (Reading cpuid here is useless.) > } while (unlikely(cpu != cpu1 || > (pvti->pvti.version & 1) || > - pvti->pvti.version != version)); > + pvti->pvti.version != version || > + pvti->migrate_count != migrate_count)); We can workaround the bug with, cpu = __getcpu() & VGETCPU_CPU_MASK; pvti = get_pvti(cpu); migrate_count = pvti->migrate_count; if (cpu != (__getcpu() & VGETCPU_CPU_MASK)) continue;