* Juan Quintela ([email protected]) wrote:
> "Dr. David Alan Gilbert (git)" <[email protected]> wrote:
> > From: "Dr. David Alan Gilbert" <[email protected]>
> >
> > postcopy_place_page (etc) provide a way for postcopy to place a page
> > into guests memory atomically (using the copy ioctl on the ufd).
> >
> > Signed-off-by: Dr. David Alan Gilbert <[email protected]>
> > Reviewed-by: Amit Shah <[email protected]>
> 
> 
> Reviewed-by: Juan Quintela <[email protected]>
> 
> > +int postcopy_place_page_zero(MigrationIncomingState *mis, void *host)
> > +{
> > +    struct uffdio_zeropage zero_struct;
> > +
> > +    zero_struct.range.start = (uint64_t)(uintptr_t)host;
> > +    zero_struct.range.len = getpagesize();
> > +    zero_struct.mode = 0;
> > +
> > +    if (ioctl(mis->userfault_fd, UFFDIO_ZEROPAGE, &zero_struct)) {
> > +        int e = errno;
> > +        error_report("%s: %s zero host: %p",
> > +                     __func__, strerror(e), host);
> > +
> > +        return -e;
> > +    }
> > +
> > +    trace_postcopy_place_page_zero(host);
> > +    return 0;
> > +}
> 
> Would this be faster than normal precopy way of just copying a zero page?

For postcopy we have to do an ioctl anyway (to release any paused tasks
waiting on the page), and we can't just write to the page because it's not
mapped yet.  We could do a UFFDIO_COPY of a zero page but that would
take a copy; here the kernel maps the zero page and releases the paused task
without needing a zero page to copy from.

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Reply via email to