On Tue, Jan 24, 2023 at 01:20:37PM +0000, Dr. David Alan Gilbert wrote: > > @@ -3970,7 +3984,8 @@ int ram_load_postcopy(QEMUFile *f, int channel) > > break; > > } > > tmp_page->target_pages++; > > - matches_target_page_size = block->page_size == > > TARGET_PAGE_SIZE; > > + matches_target_page_size = > > + migration_ram_pagesize(block) == TARGET_PAGE_SIZE; > > /* > > * Postcopy requires that we place whole host pages atomically; > > * these may be huge pages for RAMBlocks that are backed by > > Hmm do you really want this change?
Yes that's intended. I want to reuse the same logic here when receiving small pages from huge pages, just like when we're receiving small pages on non-hugetlb mappings. matches_target_page_size majorly affects two things: 1) For a small zero page, whether we want to pre-set the page_buffer, or simply use postcopy_place_page_zero(): case RAM_SAVE_FLAG_ZERO: ch = qemu_get_byte(f); /* * Can skip to set page_buffer when * this is a zero page and (block->page_size == TARGET_PAGE_SIZE). */ if (ch || !matches_target_page_size) { memset(page_buffer, ch, TARGET_PAGE_SIZE); } 2) For normal page, whether we need to use a page buffer or we can directly reuse the page buffer in QEMUFile: if (!matches_target_page_size) { /* For huge pages, we always use temporary buffer */ qemu_get_buffer(f, page_buffer, TARGET_PAGE_SIZE); } else { /* * For small pages that matches target page size, we * avoid the qemu_file copy. Instead we directly use * the buffer of QEMUFile to place the page. Note: we * cannot do any QEMUFile operation before using that * buffer to make sure the buffer is valid when * placing the page. */ qemu_get_buffer_in_place(f, (uint8_t **)&place_source, TARGET_PAGE_SIZE); } Here: I want 1) to reuse postcopy_place_page_zero(). For the doublemap case, it'll reuse postcopy_tmp_zero_page() (because qemu_ram_is_uf_zeroable() will return false for such a ramblock). I want 2) to reuse qemu_get_buffer_in_place(), so we avoid a copy process for the small page which is faster (even if it's hugetlb backed, now we can reuse the qemufile buffer safely). Thanks, -- Peter Xu