From nobody Sat Feb 7 06:55:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492777093542995.5825917655003; Fri, 21 Apr 2017 05:18:13 -0700 (PDT) Received: from localhost ([::1]:58891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XVr-0002X0-2h for importer@patchew.org; Fri, 21 Apr 2017 08:18:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCt-0003KQ-Hg for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCs-0007pQ-7j for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCr-0007pI-Ul for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF5AFDDB3A for ; Fri, 21 Apr 2017 11:58:32 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F41489F52; Fri, 21 Apr 2017 11:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF5AFDDB3A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CF5AFDDB3A From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:31 +0200 Message-Id: <20170421115646.15544-51-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 21 Apr 2017 11:58:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 50/65] ram: Change offset field in PageSearchStatus to page X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We are moving everything to work on pages, not addresses. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index d501040..eec398f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -296,8 +296,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; }; @@ -608,16 +608,16 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **c= urrent_data, * * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages - * @start: starting address (typically so we can continue from previous pa= ge) + * @start: page where we start the search * @page_abs: 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_abs) +unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, + unsigned long start, + unsigned long *page_abs) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; - unsigned long nr =3D base + (start >> TARGET_PAGE_BITS); + unsigned long nr =3D base + start; uint64_t rb_size =3D rb->used_length; unsigned long size =3D base + (rb_size >> TARGET_PAGE_BITS); unsigned long *bitmap; @@ -632,7 +632,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RA= MBlock *rb, } =20 *page_abs =3D next; - return (next - base) << TARGET_PAGE_BITS; + return next - base; } =20 static inline bool migration_bitmap_clear_dirty(RAMState *rs, @@ -810,7 +810,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus= *pss, bool last_stage) int ret; bool send_async =3D true; RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->offset; + ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 p =3D block->host + offset; =20 @@ -842,7 +842,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 =3D save_xbzrle_page(rs, &p, current_addr, block, @@ -985,7 +985,7 @@ static int ram_save_compressed_page(RAMState *rs, PageS= earchStatus *pss, uint8_t *p; int ret, blen; RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->offset; + ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 p =3D block->host + offset; =20 @@ -1029,14 +1029,14 @@ static int ram_save_compressed_page(RAMState *rs, P= ageSearchStatus *pss, } } if (pages > 0) { - ram_release_pages(block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, offset, pages); } } else { pages =3D save_zero_page(rs, block, offset, p); if (pages =3D=3D -1) { pages =3D compress_page_with_multi_thread(rs, block, offse= t); } else { - ram_release_pages(block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, offset, pages); } } } @@ -1058,10 +1058,10 @@ static int ram_save_compressed_page(RAMState *rs, P= ageSearchStatus *pss, static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again, unsigned long *page_abs) { - pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, - page_abs); + pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page, + page_abs); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && - (pss->offset >> TARGET_PAGE_BITS) >=3D rs->last_page) { + pss->page >=3D rs->last_page) { /* * We've been once around the RAM and haven't found anything. * Give up. @@ -1069,9 +1069,9 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, *again =3D false; return false; } - if (pss->offset >=3D pss->block->used_length) { + if ((pss->page << TARGET_PAGE_BITS) >=3D pss->block->used_length) { /* Didn't find anything in this RAM Block */ - pss->offset =3D 0; + pss->page =3D 0; pss->block =3D QLIST_NEXT_RCU(pss->block, next); if (!pss->block) { /* Hit the end of the list */ @@ -1193,7 +1193,7 @@ static bool get_queued_page(RAMState *rs, PageSearchS= tatus *pss, * it just requested. */ pss->block =3D block; - pss->offset =3D offset; + pss->page =3D offset >> TARGET_PAGE_BITS; } =20 return !!block; @@ -1357,7 +1357,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, unsigned long page_abs) { int tmppages, pages =3D 0; - size_t pagesize =3D qemu_ram_pagesize(pss->block); + size_t pagesize_bits =3D + qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; =20 do { tmppages =3D ram_save_target_page(rs, pss, last_stage, page_abs); @@ -1366,12 +1367,12 @@ static int ram_save_host_page(RAMState *rs, PageSea= rchStatus *pss, } =20 pages +=3D tmppages; - pss->offset +=3D TARGET_PAGE_SIZE; + pss->page++; page_abs++; - } while (pss->offset & (pagesize - 1)); + } while (pss->page & (pagesize_bits - 1)); =20 /* The offset we leave with is the last one we looked at */ - pss->offset -=3D TARGET_PAGE_SIZE; + pss->page--; return pages; } =20 @@ -1402,7 +1403,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } =20 pss.block =3D rs->last_seen_block; - pss.offset =3D rs->last_page << TARGET_PAGE_BITS; + pss.page =3D rs->last_page; pss.complete_round =3D false; =20 if (!pss.block) { @@ -1424,7 +1425,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } while (!pages && again); =20 rs->last_seen_block =3D pss.block; - rs->last_page =3D pss.offset >> TARGET_PAGE_BITS; + rs->last_page =3D pss.page; =20 return pages; } --=20 2.9.3