Lines Matching refs:pss
360 PageSearchStatus pss[RAM_CHANNEL_MAX]; member
471 int (*ram_save_target_page)(RAMState *rs, PageSearchStatus *pss);
477 static int ram_save_host_page_urgent(PageSearchStatus *pss);
480 static void pss_init(PageSearchStatus *pss, RAMBlock *rb, ram_addr_t page) in pss_init() argument
482 pss->block = rb; in pss_init()
483 pss->page = page; in pss_init()
484 pss->complete_round = false; in pss_init()
509 static size_t save_page_header(PageSearchStatus *pss, QEMUFile *f, in save_page_header() argument
513 bool same_block = (block == pss->last_sent_block); in save_page_header()
526 pss->last_sent_block = block; in save_page_header()
614 static int save_xbzrle_page(RAMState *rs, PageSearchStatus *pss, in save_xbzrle_page() argument
620 QEMUFile *file = pss->pss_channel; in save_xbzrle_page()
685 bytes_xbzrle = save_page_header(pss, pss->pss_channel, block, in save_xbzrle_page()
712 static void pss_find_next_dirty(PageSearchStatus *pss) in pss_find_next_dirty() argument
714 RAMBlock *rb = pss->block; in pss_find_next_dirty()
720 pss->page = size; in pss_find_next_dirty()
728 if (pss->host_page_sending) { in pss_find_next_dirty()
729 assert(pss->host_page_end); in pss_find_next_dirty()
730 size = MIN(size, pss->host_page_end); in pss_find_next_dirty()
733 pss->page = find_next_bit(bitmap, size, pss->page); in pss_find_next_dirty()
1130 static int save_zero_page(RAMState *rs, PageSearchStatus *pss, in save_zero_page() argument
1133 uint8_t *p = pss->block->host + offset; in save_zero_page()
1134 QEMUFile *file = pss->pss_channel; in save_zero_page()
1149 clear_bit_atomic(offset >> TARGET_PAGE_BITS, pss->block->file_bmap); in save_zero_page()
1153 len += save_page_header(pss, file, pss->block, offset | RAM_SAVE_FLAG_ZERO); in save_zero_page()
1156 ram_release_page(pss->block->idstr, offset); in save_zero_page()
1165 xbzrle_cache_zero_page(pss->block->offset + offset); in save_zero_page()
1179 static bool control_save_page(PageSearchStatus *pss, in control_save_page() argument
1184 ret = rdma_control_save_page(pss->pss_channel, pss->block->offset, offset, in control_save_page()
1209 static int save_normal_page(PageSearchStatus *pss, RAMBlock *block, in save_normal_page() argument
1212 QEMUFile *file = pss->pss_channel; in save_normal_page()
1219 ram_transferred_add(save_page_header(pss, pss->pss_channel, block, in save_normal_page()
1246 static int ram_save_page(RAMState *rs, PageSearchStatus *pss) in ram_save_page() argument
1251 RAMBlock *block = pss->block; in ram_save_page()
1252 ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; in ram_save_page()
1260 pages = save_xbzrle_page(rs, pss, &p, current_addr, in ram_save_page()
1272 pages = save_normal_page(pss, block, offset, p, send_async); in ram_save_page()
1307 static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) in find_dirty_block() argument
1310 pss_find_next_dirty(pss); in find_dirty_block()
1312 if (pss->complete_round && pss->block == rs->last_seen_block && in find_dirty_block()
1313 pss->page >= rs->last_page) { in find_dirty_block()
1320 if (!offset_in_ramblock(pss->block, in find_dirty_block()
1321 ((ram_addr_t)pss->page) << TARGET_PAGE_BITS)) { in find_dirty_block()
1323 pss->page = 0; in find_dirty_block()
1324 pss->block = QLIST_NEXT_RCU(pss->block, next); in find_dirty_block()
1325 if (!pss->block) { in find_dirty_block()
1329 QEMUFile *f = rs->pss[RAM_CHANNEL_PRECOPY].pss_channel; in find_dirty_block()
1342 pss->block = QLIST_FIRST_RCU(&ram_list.blocks); in find_dirty_block()
1344 pss->complete_round = true; in find_dirty_block()
1445 static int ram_save_release_protection(RAMState *rs, PageSearchStatus *pss, in ram_save_release_protection() argument
1451 if (pss->block->flags & RAM_UF_WRITEPROTECT) { in ram_save_release_protection()
1452 void *page_address = pss->block->host + (start_page << TARGET_PAGE_BITS); in ram_save_release_protection()
1453 uint64_t run_length = (pss->page - start_page) << TARGET_PAGE_BITS; in ram_save_release_protection()
1456 qemu_fflush(pss->pss_channel); in ram_save_release_protection()
1752 static int ram_save_release_protection(RAMState *rs, PageSearchStatus *pss, in ram_save_release_protection() argument
1756 (void) pss; in ram_save_release_protection()
1793 static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) in get_queued_page() argument
1836 pss->block = block; in get_queued_page()
1837 pss->page = offset >> TARGET_PAGE_BITS; in get_queued_page()
1843 pss->complete_round = false; in get_queued_page()
1930 PageSearchStatus *pss = &ram_state->pss[RAM_CHANNEL_POSTCOPY]; in ram_save_queue_pages() local
1935 pss_init(pss, ramblock, page_start); in ram_save_queue_pages()
1941 pss->pss_channel = migrate_get_current()->postcopy_qemufile_src; in ram_save_queue_pages()
1942 assert(pss->pss_channel); in ram_save_queue_pages()
1950 if (ram_save_host_page_urgent(pss)) { in ram_save_queue_pages()
1996 static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss) in ram_save_target_page_legacy() argument
1998 ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; in ram_save_target_page_legacy()
2001 if (control_save_page(pss, offset, &res)) { in ram_save_target_page_legacy()
2005 if (save_zero_page(rs, pss, offset)) { in ram_save_target_page_legacy()
2009 return ram_save_page(rs, pss); in ram_save_target_page_legacy()
2020 static int ram_save_target_page_multifd(RAMState *rs, PageSearchStatus *pss) in ram_save_target_page_multifd() argument
2022 RAMBlock *block = pss->block; in ram_save_target_page_multifd()
2023 ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; in ram_save_target_page_multifd()
2030 if (save_zero_page(rs, pss, offset)) { in ram_save_target_page_multifd()
2039 static void pss_host_page_prepare(PageSearchStatus *pss) in pss_host_page_prepare() argument
2042 size_t guest_pfns = qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; in pss_host_page_prepare()
2044 pss->host_page_sending = true; in pss_host_page_prepare()
2054 pss->host_page_start = pss->page; in pss_host_page_prepare()
2055 pss->host_page_end = pss->page + 1; in pss_host_page_prepare()
2061 pss->host_page_start = ROUND_DOWN(pss->page, guest_pfns); in pss_host_page_prepare()
2062 pss->host_page_end = ROUND_UP(pss->page + 1, guest_pfns); in pss_host_page_prepare()
2070 static bool pss_within_range(PageSearchStatus *pss) in pss_within_range() argument
2074 assert(pss->host_page_sending); in pss_within_range()
2077 if (pss->page >= pss->host_page_end) { in pss_within_range()
2081 ram_addr = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; in pss_within_range()
2083 return offset_in_ramblock(pss->block, ram_addr); in pss_within_range()
2086 static void pss_host_page_finish(PageSearchStatus *pss) in pss_host_page_finish() argument
2088 pss->host_page_sending = false; in pss_host_page_finish()
2090 pss->host_page_start = pss->host_page_end = 0; in pss_host_page_finish()
2099 static int ram_save_host_page_urgent(PageSearchStatus *pss) in ram_save_host_page_urgent() argument
2105 trace_postcopy_preempt_send_host_page(pss->block->idstr, pss->page); in ram_save_host_page_urgent()
2106 pss_host_page_prepare(pss); in ram_save_host_page_urgent()
2113 if (pss_overlap(pss, &ram_state->pss[RAM_CHANNEL_PRECOPY])) { in ram_save_host_page_urgent()
2114 trace_postcopy_preempt_hit(pss->block->idstr, in ram_save_host_page_urgent()
2115 pss->page << TARGET_PAGE_BITS); in ram_save_host_page_urgent()
2120 page_dirty = migration_bitmap_clear_dirty(rs, pss->block, pss->page); in ram_save_host_page_urgent()
2124 if (migration_ops->ram_save_target_page(rs, pss) != 1) { in ram_save_host_page_urgent()
2131 pss_find_next_dirty(pss); in ram_save_host_page_urgent()
2132 } while (pss_within_range(pss)); in ram_save_host_page_urgent()
2134 pss_host_page_finish(pss); in ram_save_host_page_urgent()
2137 qemu_fflush(pss->pss_channel); in ram_save_host_page_urgent()
2163 static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss) in ram_save_host_page() argument
2168 qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; in ram_save_host_page()
2169 unsigned long start_page = pss->page; in ram_save_host_page()
2172 if (migrate_ram_is_ignored(pss->block)) { in ram_save_host_page()
2173 error_report("block %s should not be migrated !", pss->block->idstr); in ram_save_host_page()
2178 pss_host_page_prepare(pss); in ram_save_host_page()
2181 page_dirty = migration_bitmap_clear_dirty(rs, pss->block, pss->page); in ram_save_host_page()
2193 tmppages = migration_ops->ram_save_target_page(rs, pss); in ram_save_host_page()
2212 pss_host_page_finish(pss); in ram_save_host_page()
2216 pss_find_next_dirty(pss); in ram_save_host_page()
2217 } while (pss_within_range(pss)); in ram_save_host_page()
2219 pss_host_page_finish(pss); in ram_save_host_page()
2221 res = ram_save_release_protection(rs, pss, start_page); in ram_save_host_page()
2240 PageSearchStatus *pss = &rs->pss[RAM_CHANNEL_PRECOPY]; in ram_find_and_save_block() local
2260 pss_init(pss, rs->last_seen_block, rs->last_page); in ram_find_and_save_block()
2263 if (!get_queued_page(rs, pss)) { in ram_find_and_save_block()
2265 int res = find_dirty_block(rs, pss); in ram_find_and_save_block()
2277 pages = ram_save_host_page(rs, pss); in ram_find_and_save_block()
2283 rs->last_seen_block = pss->block; in ram_find_and_save_block()
2284 rs->last_page = pss->page; in ram_find_and_save_block()
2400 rs->pss[i].last_sent_block = NULL; in ram_state_reset()
2595 rs->pss[RAM_CHANNEL_PRECOPY].last_sent_block = NULL; in ram_postcopy_send_discard_bitmap()
2845 rs->pss[RAM_CHANNEL_PRECOPY].pss_channel = out; in ram_state_resume_prepare()
3014 (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f; in ram_save_setup()