Thread (22 messages) flat view 22 messages, 6 authors, 2014-09-20

Re: [PATCH] x86/vdso: Add prctl to set per-process VDSO load

From: Andy Lutomirski <luto@amacapital.net>
Date: 2014-09-19 19:28:08
Also in: lkml

On Wed, Sep 17, 2014 at 7:28 AM, Andy Lutomirski [off-list ref] wrote:
On Sep 17, 2014 1:46 AM, "H. Peter Anvin" [off-list ref] wrote:
quoted
On 09/16/2014 11:21 PM, Filipe Brandenburger wrote:
quoted
Hi Andy,

On Tue, Sep 16, 2014 at 10:00 PM, Andy Lutomirski [off-list ref] wrote:
quoted
I think that the patch should instead tweak the vvar mapping to tell
the vdso not to use rdtsc.  It should be based on this:
I've been working on this approach which extends the vvar from 2 to 3
pages. The third page would initially be mapped to a zero page but
then through a prctl a task could replace it with a real page that
could then be inherited through fork and exec.

That would make it possible to have per-task vvar contents.

We could use some of those values as flags to indicate whether vdso
routines may use RDTSC or not.

In the future, we're planning to also use that to store clock offsets
so that we can ensure CLOCK_MONOTONIC works after CRIU migration
without having to turn off the VDSO or have to always fallback to full
syscalls on every case.

Do you think that would be a reasonable way to accomplish that?
Why would we need/want per process vvar contents?  It seems better to
have the code swapped out.
That seems messier from a build perspective.  Also, if we ever want to
switch this dynamically, swapping out data is much easier than
swapping out code.  I think we should be able to replace the vvar page
with the zero page, though.

One tricky bit: currently we can only easily do this on exec, but we
should be able to do it immediately if we start tracking mremap of the
vdso.  Should we make that a prerequisite?  I don't really want this
to end up being permanently weird.
I have this (special mapping tracking) 3/4 implemented.  I'm planning
on making it fully functional for 64-bit programs and almost correct
for 32-bit.  (You'll still crash if you have multiple threads, you use
sysenter, and you remap the vdso, but I think that this is essentially
unavoidable until someone lets mremap work on multiple vmas at once.)
As for an actual post-migration offset, I'd rather add support for
per-mm forced syscall fallback and then get something into the code
timing code before even thinking about an x86 vdso fast path.  I don't
think that a feature like per-mm timing offsets should happen as an
arch-specific thing first.

--Andy
quoted
        -hpa


-- 
Andy Lutomirski
AMA Capital Management, LLC
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help