From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: Yong Huang <yong.huang@smartx.com>,
qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>,
Wei Wang <wei.w.wang@intel.com>,
"Michael S . Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v1 2/2] migration: Do not perform RAMBlock dirty sync during the first iteration
Date: Thu, 14 Nov 2024 22:16:41 +0100 [thread overview]
Message-ID: <5f04a1dc-ca0a-488b-812e-7cebf393f59f@redhat.com> (raw)
In-Reply-To: <ZzZPd7Ye09bjUjyR@x1n>
On 14.11.24 20:28, Peter Xu wrote:
> On Thu, Nov 14, 2024 at 10:02:37AM +0100, David Hildenbrand wrote:
>> On 13.11.24 21:12, Peter Xu wrote:
>>> On Wed, Nov 13, 2024 at 07:49:44PM +0100, David Hildenbrand wrote:
>>>> I think I had precisely that, and I recall you suggested to have it only
>>>> after the initial sync. Would work for me, but I'd still like to understand
>>>> why essentially none of the "discard" was effective -- all of guest RAM got
>>>> touched.
>>>
>>> Yes it'll be interesting to know..
>>>
>>> One thing I'm wildly guessing is dirty_memory_extend(), so maybe after the
>>> ramblock is created nobody yet to clear the "1"s there for each of the
>>> client, including DIRTY_MEMORY_MIGRATION. Then it'll be synced to ramblock
>>> bmap only in the initial sync, once for each qemu lifecycle.
>>
>>
>> In ram_block_add() we do the
>>
>> cpu_physical_memory_set_dirty_range(new_block->offset,
>> new_block->used_length,
>> DIRTY_CLIENTS_ALL);
>>
>> ramblock_dirty_bitmap_clear_discarded_pages()->...->migration_clear_memory_region_dirty_bitmap_range()->migration_clear_memory_region_dirty_bitmap()
>> won't end up clearing the bits in the dirty bitmap.
>>
>> First I thought because of:
>>
>> if (!rb->clear_bmap || !clear_bmap_test_and_clear(rb, page)) {
>> return;
>> }
>>
>> But then I realized that even memory_region_clear_dirty_bitmap() will not
>> clear the ramblock_dirty_bitmap_ bits! It's only concerned about
>> listener->log_clear() calls.
>>
>> Looking for DIRTY_MEMORY_BLOCK_SIZE users, only
>> cpu_physical_memory_sync_dirty_bitmap() and
>> cpu_physical_memory_clear_dirty_range() clear them, whereby the latter is
>> only used when resizing RAMblocks.
>>
>> At first I wondered whether ramblock_dirty_bitmap_clear_discarded_pages()
>> should also call cpu_physical_memory_clear_dirty_range(), but then I am not
>> so sure if that is really the right approach.
>
> That sounds actually reasonable to me so far.. What's the concern in your
> mind?
I think what I had in mind was that for the initial bitmap sync, when we
set the bmap to all-1s already, we could just clear the whole
ramblock_dirty_bitmap_ + KVM ... bitmaps.
So, instead of an "initial sync" we might just want to do an "initial
clearing" of all bitmaps.
>
>>
>>
>> virtio-balloon() calls qemu_guest_free_page_hint() which calls
>>
>> migration_clear_memory_region_dirty_bitmap_range()
>> bitmap_clear()
>>
>> So it would maybe have the same issue.
>
> Should virtio-balloon do the same?
virtio-balloon is more interesting, because I assume here we could run
after the "initial clearing" and would want to mark it clean everywhere.
>
> So I suppose the idea here is some module may want to say "we should ignore
> these pages in the dirty bitmap", and so far that's only about migration.
>
> Then cpu_physical_memory_clear_dirty_range() does look like the right thing
> to do, in which case the bmap in ram_list used to be overlooked.. it seems.
>
> But of course, cpu_physical_memory_clear_dirty_range() still doesn't cover
> the migration bitmap itself, which is ramblock->bmap. So we'll need to
> switch from migration_clear_memory_region_dirty_bitmap() to use things like
> cpu_physical_memory_clear_dirty_range(), just to cover ram_list bitmaps.
> Then keeping the rb->bmap operations like before..
For virtio-balloon likely yes. Regarding virtio-mem, maybe "initial
clearing" + only modifying the rb->bmap when processing discards could
work and would even be more efficient.
(but I'm confused because we have way too many bitmaps, and maybe the
KVM one could be problematic without an initial sync ... we'd want an
initial clearing for that as well ...)
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-11-14 21:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 4:59 [PATCH v1 0/2] migration: Skip the first dirty sync Hyman Huang
2024-11-09 4:59 ` [PATCH v1 1/2] virtio-balloon: Enable free page hinting during PRECOPY_NOTIFY_SETUP Hyman Huang
2024-11-12 10:10 ` David Hildenbrand
2024-11-09 4:59 ` [PATCH v1 2/2] migration: Do not perform RAMBlock dirty sync during the first iteration Hyman Huang
2024-11-11 9:07 ` Wang, Wei W
2024-11-11 10:20 ` Yong Huang
2024-11-11 9:27 ` David Hildenbrand
2024-11-11 10:08 ` Yong Huang
2024-11-11 10:42 ` David Hildenbrand
2024-11-11 11:14 ` Yong Huang
2024-11-11 11:37 ` Yong Huang
2024-11-12 10:08 ` David Hildenbrand
2024-11-13 17:40 ` Peter Xu
2024-11-13 18:49 ` David Hildenbrand
2024-11-13 20:12 ` Peter Xu
2024-11-14 9:02 ` David Hildenbrand
2024-11-14 19:28 ` Peter Xu
2024-11-14 21:16 ` David Hildenbrand [this message]
2024-11-14 22:40 ` Peter Xu
2024-11-15 9:11 ` David Hildenbrand
2024-11-15 15:41 ` Peter Xu
2024-11-15 15:49 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f04a1dc-ca0a-488b-812e-7cebf393f59f@redhat.com \
--to=david@redhat.com \
--cc=farosas@suse.de \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wei.w.wang@intel.com \
--cc=yong.huang@smartx.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).