On 05.02.20 10:00, Wang, Wei W wrote:> On Wednesday, February 5, 2020 4:57 PM, David Hildenbrand wrote: >>>> Yes, I agree with you. Yet, I am thinking about one >>>> (unlikely?impossible?) scenario. Can you refresh my brain why that >>>> cannot happen (IOW, why we don't have to wait for the host to process >>>> the request)? >>>> >>>> 1. Guest allocates a page and sends it to the host. >>>> 2. Shrinker gets active and releases that page again. >>>> 3. Some user in the guest allocates and modifies that page. After >>>> that, it is done using that page for the next hour. >>>> 4. The host processes the request and clears the bit in the dirty bitmap. >>>> 5. The guest is being migrated by the host. The modified page is not >>>> being migrated. >>> >>> Whenever the guest modifies a page during migration, it will be >>> captured by the dirty logging and the hypervisor will send the dirtied the >> page in the following round. >> >> Please explain why the steps I outlined don't apply esp. in the last round. >> Your general statement does not explain why this race can't happen. >> > > The guest is stopped in the last round, thus no page will be modified at that time.No, that does not answer my question. Because then, obviously the guest can't do any hinting in the last round. I think I am missing something important :) 1. Guest allocates a page and sends it to the host. 2. Shrinker gets active and releases that page again. 3. Some user in the guest allocates and modifies that page. The dirty bit is set in the hypervisor. 4. The host processes the request and clears the bit in the dirty bitmap. 5. The guest is stopped and the last set of dirty pages is migrated. The modified page is not being migrated (because not marked dirty). Something between 3. and 4. has to guarantee that the page will still be migrated, what guarantees that? -- Thanks, David / dhildenb
On Wednesday, February 5, 2020 5:06 PM, David Hildenbrand wrote:> > No, that does not answer my question. Because then, obviously the guest > can't do any hinting in the last round. I think I am missing something > important :)No problem, probably need more details here: QEMU has a dirty bitmap which indicates all the dirty pages from the previous round. KVM has a dirty bitmap which records what pages are modified in this round. When a new round starts, QEMU syncs the bitmap from KVM (this round always sends the pages dirtied from the previous round).> 1. Guest allocates a page and sends it to the host. > 2. Shrinker gets active and releases that page again. > 3. Some user in the guest allocates and modifies that page. The dirty bit is > set in the hypervisor.The bit will be set in KVM's bitmap, and will be synced to QEMU's bitmap when the next round starts.> 4. The host processes the request and clears the bit in the dirty bitmap.This clears the bit from the QEMU bitmap, and this page will not be sent in this round.> 5. The guest is stopped and the last set of dirty pages is migrated. The > modified page is not being migrated (because not marked dirty).When QEMU start the last round, it first syncs the bitmap from KVM, which includes the one set in step 3. Then the modified page gets sent. Best, Wei
>> 1. Guest allocates a page and sends it to the host. >> 2. Shrinker gets active and releases that page again. >> 3. Some user in the guest allocates and modifies that page. The dirty bit is >> set in the hypervisor. > > The bit will be set in KVM's bitmap, and will be synced to QEMU's bitmap when the next round starts. > >> 4. The host processes the request and clears the bit in the dirty bitmap. > > This clears the bit from the QEMU bitmap, and this page will not be sent in this round. > >> 5. The guest is stopped and the last set of dirty pages is migrated. The >> modified page is not being migrated (because not marked dirty). > > When QEMU start the last round, it first syncs the bitmap from KVM, which includes the one set in step 3. > Then the modified page gets sent.So, if you run a TCG guest and use it with free page reporting, the race is possible? So the correctness depends on two dirty bitmaps in the hypervisor and how they interact. wow this is fragile. Thanks for the info :) -- Thanks, David / dhildenb