[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54ACC64F.6030304@redhat.com>
Date: Wed, 07 Jan 2015 06:38:23 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Andy Lutomirski <luto@...capital.net>
CC: "xen-devel@...ts.xenproject.org" <xen-devel@...ts.xenproject.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
kvm list <kvm@...r.kernel.org>, Gleb Natapov <gleb@...nel.org>,
Marcelo Tosatti <mtosatti@...hat.com>
Subject: Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso
pvclock reader
On 06/01/2015 17:56, Andy Lutomirski wrote:
> Still no good. We can migrate a bunch of times so we see the same CPU
> all three times
There are no three times. The CPU you see here:
>>
>>
>> // ... compute nanoseconds from pvti and tsc ...
>> rmb();
>> } while(v != pvti->version);
is the same you read here:
>> cpu = get_cpu();
The algorithm is:
1) get a consistent (cpu, version, tsc)
1.a) get cpu
1.b) get pvti[cpu]->version, ignoring low bit
1.c) get (tsc, cpu)
1.d) if cpu from 1.a and 1.c do not match, loop
1.e) if pvti[cpu] was being updated, we'll loop later
2) compute nanoseconds from pvti[cpu] and tsc
3) if pvti[cpu] changed under our feet during (2), i.e. version doesn't
match, retry.
As long as the CPU is consistent between get_cpu() and rdtscp(), there
is no problem with migration, because pvti is always accessed for that
one CPU. If there were any problem, it would be caught by the version
check. Writing it down with two nested do...whiles makes it clearer IMHO.
> and *still* don't get a consistent read, unless we
> play nasty games with lots of version checks (I have a patch for that,
> but I don't like it very much). The patch is here:
>
> https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/commit/?h=x86/vdso_paranoia&id=a69754dc5ff33f5187162b5338854ad23dd7be8d
>
> but I don't like it.
>
> Thus far, I've been told unambiguously that a guest can't observe pvti
> while it's being written, and I think you're now telling me that this
> isn't true and that a guest *can* observe pvti while it's being
> written while the low bit of the version field is not set. If so,
> this is rather strongly incompatible with the spec in the KVM docs.
Where am I saying that?
Paolo
--
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