[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 2/4] migration: API to clear bits of guest fr
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH v4 2/4] migration: API to clear bits of guest free pages from the dirty bitmap |
Date: |
Wed, 14 Mar 2018 21:16:50 +0200 |
On Wed, Mar 14, 2018 at 06:11:37PM +0000, Dr. David Alan Gilbert wrote:
> > + used_len = block->used_length - offset;
> > + addr += used_len;
> > + }
> > +
> > + start = offset >> TARGET_PAGE_BITS;
> > + npages = used_len >> TARGET_PAGE_BITS;
> > + ram_state->migration_dirty_pages -=
> > + bitmap_count_one_with_offset(block->bmap, start,
> > npages);
> > + bitmap_clear(block->bmap, start, npages);
>
> If this is happening while the migration is running, this isn't safe -
> the migration code could clear a bit at about the same point this
> happens, so that the count returned by bitmap_count_one_with_offset
> wouldn't match the word that was cleared by bitmap_clear.
>
> The only way I can see to fix it is to run over the range using
> bitmap_test_and_clear_atomic, using the return value to decrement
> the number of dirty pages.
> But you also need to be careful with the update of the
> migration_dirty_pages value itself, because that's also being read
> by the migration thread.
>
> Dave
I see that there's migration_bitmap_sync but it does not seem to be
taken on all paths. E.g. migration_bitmap_clear_dirty and
migration_bitmap_find_dirty are called without that lock sometimes.
Thoughts?
--
MST
[Qemu-devel] [PATCH v4 1/4] bitmap: bitmap_count_one_with_offset, Wei Wang, 2018/03/07
[Qemu-devel] [PATCH v4 4/4] migration: use the free page hint feature from balloon, Wei Wang, 2018/03/07