[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 47/51] ram: Change offset field in PageSearchSta
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH 47/51] ram: Change offset field in PageSearchStatus to page |
Date: |
Fri, 31 Mar 2017 13:31:43 +0100 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
* Juan Quintela (address@hidden) wrote:
> We are moving everything to work on pages, not addresses.
>
> Signed-off-by: Juan Quintela <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
> ---
> migration/ram.c | 50 +++++++++++++++++++++++++-------------------------
> 1 file changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 57b776b..ef3b428 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -298,8 +298,8 @@ uint64_t ram_postcopy_requests(void)
> struct PageSearchStatus {
> /* Current block being searched */
> RAMBlock *block;
> - /* Current offset to search from */
> - ram_addr_t offset;
> + /* Current page to search from */
> + unsigned long page;
> /* Set once we wrap around */
> bool complete_round;
> };
> @@ -610,16 +610,16 @@ static int save_xbzrle_page(RAMState *rs, uint8_t
> **current_data,
> *
> * @rs: current RAM state
> * @rb: RAMBlock where to search for dirty pages
> - * @start: starting address (typically so we can continue from previous page)
> + * @start: page where we start the search
> * @page: pointer into where to store the dirty page
> */
> static inline
> -ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
> - ram_addr_t start,
> - unsigned long *page)
> +unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
> + unsigned long start,
> + unsigned long *page)
> {
> unsigned long base = rb->offset >> TARGET_PAGE_BITS;
> - unsigned long nr = base + (start >> TARGET_PAGE_BITS);
> + unsigned long nr = base + start;
> uint64_t rb_size = rb->used_length;
> unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
> unsigned long *bitmap;
> @@ -634,7 +634,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs,
> RAMBlock *rb,
> }
>
> *page = next;
> - return (next - base) << TARGET_PAGE_BITS;
> + return next - base;
> }
>
> static inline bool migration_bitmap_clear_dirty(RAMState *rs,
> @@ -812,7 +812,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus
> *pss, bool last_stage)
> int ret;
> bool send_async = true;
> RAMBlock *block = pss->block;
> - ram_addr_t offset = pss->offset;
> + ram_addr_t offset = pss->page << TARGET_PAGE_BITS;
>
> p = block->host + offset;
>
> @@ -844,7 +844,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus
> *pss, bool last_stage)
> * page would be stale
> */
> xbzrle_cache_zero_page(rs, current_addr);
> - ram_release_pages(block->idstr, pss->offset, pages);
> + ram_release_pages(block->idstr, offset, pages);
> } else if (!rs->ram_bulk_stage &&
> !migration_in_postcopy() && migrate_use_xbzrle()) {
> pages = save_xbzrle_page(rs, &p, current_addr, block,
> @@ -987,7 +987,7 @@ static int ram_save_compressed_page(RAMState *rs,
> PageSearchStatus *pss,
> uint8_t *p;
> int ret, blen;
> RAMBlock *block = pss->block;
> - ram_addr_t offset = pss->offset;
> + ram_addr_t offset = pss->page << TARGET_PAGE_BITS;
>
> p = block->host + offset;
>
> @@ -1031,14 +1031,14 @@ static int ram_save_compressed_page(RAMState *rs,
> PageSearchStatus *pss,
> }
> }
> if (pages > 0) {
> - ram_release_pages(block->idstr, pss->offset, pages);
> + ram_release_pages(block->idstr, offset, pages);
> }
> } else {
> pages = save_zero_page(rs, block, offset, p);
> if (pages == -1) {
> pages = compress_page_with_multi_thread(rs, block, offset);
> } else {
> - ram_release_pages(block->idstr, pss->offset, pages);
> + ram_release_pages(block->idstr, offset, pages);
> }
> }
> }
> @@ -1060,10 +1060,9 @@ static int ram_save_compressed_page(RAMState *rs,
> PageSearchStatus *pss,
> static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,
> bool *again, unsigned long *page)
> {
> - pss->offset = migration_bitmap_find_dirty(rs, pss->block, pss->offset,
> - page);
> + pss->page = migration_bitmap_find_dirty(rs, pss->block, pss->page, page);
> if (pss->complete_round && pss->block == rs->last_seen_block &&
> - pss->offset >= rs->last_page) {
> + pss->page >= rs->last_page) {
> /*
> * We've been once around the RAM and haven't found anything.
> * Give up.
> @@ -1071,9 +1070,9 @@ static bool find_dirty_block(RAMState *rs,
> PageSearchStatus *pss,
> *again = false;
> return false;
> }
> - if (pss->offset >= pss->block->used_length) {
> + if ((pss->page << TARGET_PAGE_BITS) >= pss->block->used_length) {
> /* Didn't find anything in this RAM Block */
> - pss->offset = 0;
> + pss->page = 0;
> pss->block = QLIST_NEXT_RCU(pss->block, next);
> if (!pss->block) {
> /* Hit the end of the list */
> @@ -1196,7 +1195,7 @@ static bool get_queued_page(RAMState *rs,
> PageSearchStatus *pss,
> * it just requested.
> */
> pss->block = block;
> - pss->offset = offset;
> + pss->page = offset >> TARGET_PAGE_BITS;
> }
>
> return !!block;
> @@ -1351,7 +1350,8 @@ static int ram_save_host_page(RAMState *rs,
> PageSearchStatus *pss,
> unsigned long page)
> {
> int tmppages, pages = 0;
> - size_t pagesize = qemu_ram_pagesize(pss->block);
> + size_t pagesize_bits =
> + qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS;
>
> do {
> tmppages = ram_save_target_page(rs, pss, last_stage, page);
> @@ -1360,12 +1360,12 @@ static int ram_save_host_page(RAMState *rs,
> PageSearchStatus *pss,
> }
>
> pages += tmppages;
> - pss->offset += TARGET_PAGE_SIZE;
> + pss->page++;
> page++;
> - } while (pss->offset & (pagesize - 1));
> + } while (pss->page & (pagesize_bits - 1));
>
> /* The offset we leave with is the last one we looked at */
> - pss->offset -= TARGET_PAGE_SIZE;
> + pss->page--;
> return pages;
> }
>
> @@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool
> last_stage)
> }
>
> pss.block = rs->last_seen_block;
> - pss.offset = rs->last_page << TARGET_PAGE_BITS;
> + pss.page = rs->last_page;
> pss.complete_round = false;
>
> if (!pss.block) {
> @@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool
> last_stage)
> } while (!pages && again);
>
> rs->last_seen_block = pss.block;
> - rs->last_page = pss.offset >> TARGET_PAGE_BITS;
> + rs->last_page = pss.page;
>
> return pages;
> }
> --
> 2.9.3
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH 42/51] ram: Pass RAMBlock to bitmap_sync, (continued)
[Qemu-devel] [PATCH 45/51] ram: Use page number instead of an address for the bitmap operations, Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 43/51] ram: ram_discard_range() don't use the mis parameter, Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 46/51] ram: Remember last_page instead of last_offset, Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 47/51] ram: Change offset field in PageSearchStatus to page, Juan Quintela, 2017/03/23
- Re: [Qemu-devel] [PATCH 47/51] ram: Change offset field in PageSearchStatus to page,
Dr. David Alan Gilbert <=
[Qemu-devel] [PATCH 44/51] ram: reorganize last_sent_block, Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 48/51] ram: Use ramblock and page offset instead of absolute offset, Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 49/51] ram: rename last_ram_offset() last_ram_pages(), Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 51/51] migration: Remove MigrationState parameter from migration_is_idle(), Juan Quintela, 2017/03/23
[Qemu-devel] [PATCH 50/51] ram: Use RAMBitmap type for coherence, Juan Quintela, 2017/03/23