From: Marcelo Tosatti <mtosatti@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
kvm-devel <kvm@vger.kernel.org>, stable <stable@vger.kernel.org>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: x86: kvm: Revert "remove sched notifier for cross-cpu migrations"
Date: Thu, 26 Mar 2015 19:40:00 -0300 [thread overview]
Message-ID: <20150326224000.GA29116@amt.cnet> (raw)
In-Reply-To: <CALCETrV-Ri0hcHK8Vkw0zt-cZmEV1UPy+myzb9A1Y6v8sGGCtA@mail.gmail.com>
On Thu, Mar 26, 2015 at 03:24:10PM -0700, Andy Lutomirski wrote:
> On Thu, Mar 26, 2015 at 3:22 PM, Marcelo Tosatti <mtosatti@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.
> >> >
> >> > 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 <mtosatti@redhat.com>
> >> > 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.
> >
> > Migrating back will increase pvti->migrate_count, right ?
>
> I thought it only increased the count when we migrated away.
Right.
> --Andy
>
> >
> >> 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;
Looks good, please submit a fix.
prev parent reply other threads:[~2015-03-26 22:40 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 23:21 x86: kvm: Revert "remove sched notifier for cross-cpu migrations" Marcelo Tosatti
2015-03-23 23:30 ` Andy Lutomirski
2015-03-24 15:34 ` Radim Krčmář
2015-03-24 22:33 ` Andy Lutomirski
2015-03-25 11:08 ` Radim Krčmář
2015-03-25 12:52 ` Radim Krčmář
2015-03-25 21:28 ` Marcelo Tosatti
2015-03-25 22:33 ` Andy Lutomirski
2015-03-25 22:41 ` Marcelo Tosatti
2015-03-25 22:48 ` Andy Lutomirski
2015-03-25 23:13 ` Marcelo Tosatti
2015-03-25 23:22 ` Andy Lutomirski
2015-03-26 11:29 ` Marcelo Tosatti
2015-03-26 18:51 ` Andy Lutomirski
2015-03-26 20:31 ` Radim Krcmar
2015-03-26 20:58 ` Andy Lutomirski
2015-03-26 22:22 ` Andy Lutomirski
2015-03-26 22:56 ` Marcelo Tosatti
2015-03-26 23:09 ` Andy Lutomirski
2015-03-26 23:22 ` Marcelo Tosatti
2015-03-26 23:28 ` Andy Lutomirski
2015-03-26 23:38 ` Marcelo Tosatti
2015-03-26 18:47 ` Andy Lutomirski
2015-03-26 20:10 ` Radim Krčmář
2015-03-26 20:52 ` Paolo Bonzini
2015-03-24 22:59 ` Marcelo Tosatti
2015-03-25 11:09 ` Radim Krčmář
2015-03-25 13:06 ` Radim Krčmář
2015-03-26 20:59 ` Radim Krčmář
2015-03-26 22:22 ` Marcelo Tosatti
2015-03-26 22:24 ` Andy Lutomirski
2015-03-26 22:40 ` Marcelo Tosatti [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150326224000.GA29116@amt.cnet \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox