[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v9 35/56] Postcopy: Calculate discard
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v9 35/56] Postcopy: Calculate discard |
Date: |
Mon, 9 Nov 2015 18:27:40 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
* Juan Quintela (address@hidden) wrote:
> "Dr. David Alan Gilbert (git)" <address@hidden> wrote:
> > From: "Dr. David Alan Gilbert" <address@hidden>
> >
> > Where postcopy is preceeded by a period of precopy, the destination will
> > have received pages that may have been dirtied on the source after the
> > page was sent. The destination must throw these pages away before
> > starting it's CPUs.
> >
> > Calculate list of sent & dirty pages
> > Provide helpers on the destination side to discard these.
> >
> > Signed-off-by: Dr. David Alan Gilbert <address@hidden>
>
> Reviewed-by: Juan Quintela <address@hidden>
>
> But please, send a fix for:
>
> > return ret;
> > }
> >
> > +/**
> > + * postcopy_ram_discard_range: Discard a range of memory.
> > + * We can assume that if we've been called postcopy_ram_hosttest returned
> > true.
> > + *
> > + * @mis: Current incoming migration state.
> > + * @start, @length: range of memory to discard.
> > + *
> > + * returns: 0 on success.
> > + */
> > +int postcopy_ram_discard_range(MigrationIncomingState *mis, uint8_t *start,
> > + size_t length)
> > +{
> > + trace_postcopy_ram_discard_range(start, length);
> > + if (madvise(start, length, MADV_DONTNEED)) {
>
> qemu_madvise(start, length, QEMU_MADV_DONTNEED)
I thought I'd better check before making a patch for that,
and it turns out you have to be really careful.
qemu_madvise may call posix_madvise instead of madvise (depending
what config decides); you might think that a
madvise(..,..,MADV_DONTNEED) is the same as a
posix_madvise(..,..,POSIX_MADV_DONTNEED)
but actually on Linux a posix_madvise does precisely nothing;
from the glibc source:
{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}
posix_madvise (void *addr, size_t len, int advice)
{
/* We have one problem: the kernel's MADV_DONTNEED does not
correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
discards changes made to the memory without writing it back to
disk, if this would be necessary. The POSIX behavior does not
allow this. There is no functionality mapping the POSIX behavior
so far so we ignore that advice for now. */
if (advice == POSIX_MADV_DONTNEED)
return 0;
{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}{<>}
oh and notice how it returns with a 'return 0' so we can't tell if we
fall down that trap.
So, it's best to stick to an actual, solid, good old fashioned madvise
which does what it was asked.
Dave
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH v9 30/56] migration_completion: Take current state, (continued)
- [Qemu-devel] [PATCH v9 28/56] postcopy: OS support test, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 29/56] migrate_start_postcopy: Command to trigger transition to postcopy, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 31/56] MIGRATION_STATUS_POSTCOPY_ACTIVE: Add new migration state, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 32/56] Avoid sending vmdescription during postcopy, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 33/56] Add qemu_savevm_state_complete_postcopy, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 34/56] Postcopy: Maintain unsentmap, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 35/56] Postcopy: Calculate discard, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 37/56] postcopy: ram_enable_notify to switch on userfault, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 36/56] postcopy: Incoming initialisation, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 38/56] Postcopy: Postcopy startup in migration thread, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 40/56] Page request: Add MIG_RP_MSG_REQ_PAGES reverse command, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 39/56] Postcopy: End of iteration, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 41/56] Page request: Process incoming page request, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 42/56] Page request: Consume pages off the post-copy queue, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 44/56] Postcopy: Use helpers to map pages during migration, Dr. David Alan Gilbert (git), 2015/11/05