From nobody Mon Feb 9 18:19:52 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 1490303861621940.7269823080384; Thu, 23 Mar 2017 14:17:41 -0700 (PDT) Received: from localhost ([::1]:58692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA72-00027C-BG for importer@patchew.org; Thu, 23 Mar 2017 17:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dL-0000B9-V7 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dK-0000jJ-Is for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45748) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dK-0000j5-9r for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:58 -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 44F54C04B31F for ; Thu, 23 Mar 2017 20:46:58 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8EE253; Thu, 23 Mar 2017 20:46:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 44F54C04B31F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 44F54C04B31F From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:41 +0100 Message-Id: <20170323204544.12015-49-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-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.31]); Thu, 23 Mar 2017 20:46:58 +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] [PATCH 48/51] ram: Use ramblock and page offset instead of absolute offset 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" This removes the needto pass also the absolute offset. Signed-off-by: Juan Quintela --- migration/ram.c | 56 ++++++++++++++++++++++------------------------= ---- migration/trace-events | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ef3b428..3f283ba 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -611,12 +611,10 @@ 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: page where we start the search - * @page: pointer into where to store the dirty page */ static inline unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, - unsigned long start, - unsigned long *page) + unsigned long start) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; unsigned long nr =3D base + start; @@ -633,17 +631,18 @@ unsigned long migration_bitmap_find_dirty(RAMState *r= s, RAMBlock *rb, next =3D find_next_bit(bitmap, size, nr); } =20 - *page =3D next; return next - base; } =20 static inline bool migration_bitmap_clear_dirty(RAMState *rs, + RAMBlock *rb, unsigned long page) { bool ret; unsigned long *bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; + unsigned long nr =3D (rb->offset >> TARGET_PAGE_BITS) + page; =20 - ret =3D test_and_clear_bit(page, bitmap); + ret =3D test_and_clear_bit(nr, bitmap); =20 if (ret) { rs->migration_dirty_pages--; @@ -1057,10 +1056,9 @@ static int ram_save_compressed_page(RAMState *rs, Pa= geSearchStatus *pss, * @again: set to false if the search has scanned the whole of RAM * @page: pointer into where to store the dirty page */ -static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, - bool *again, unsigned long *page) +static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *ag= ain) { - pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page, p= age); + pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && pss->page >=3D rs->last_page) { /* @@ -1110,8 +1108,7 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, * @offset: used to return the offset within the RAMBlock * @page: pointer into where to store the dirty page */ -static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset, - unsigned long *page) +static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset) { RAMBlock *block =3D NULL; =20 @@ -1121,7 +1118,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_= t *offset, QSIMPLEQ_FIRST(&rs->src_page_requests); block =3D entry->rb; *offset =3D entry->offset; - *page =3D (entry->offset + entry->rb->offset) >> TARGET_PAGE_BITS; =20 if (entry->len > TARGET_PAGE_SIZE) { entry->len -=3D TARGET_PAGE_SIZE; @@ -1148,15 +1144,14 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_add= r_t *offset, * @pss: data about the state of the current dirty page scan * @page: pointer into where to store the dirty page */ -static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, - unsigned long *page) +static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) { RAMBlock *block; ram_addr_t offset; bool dirty; =20 do { - block =3D unqueue_page(rs, &offset, page); + block =3D unqueue_page(rs, &offset); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again @@ -1165,16 +1160,18 @@ static bool get_queued_page(RAMState *rs, PageSearc= hStatus *pss, */ if (block) { unsigned long *bitmap; + unsigned long page; + bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; - dirty =3D test_bit(*page, bitmap); + page =3D (block->offset + offset) >> TARGET_PAGE_BITS; + dirty =3D test_bit(page, bitmap); if (!dirty) { trace_get_queued_page_not_dirty(block->idstr, (uint64_t)of= fset, - *page, - test_bit(*page, + page, + test_bit(page, atomic_rcu_read(&rs->ram_bitmap)->unsentmap)); } else { - trace_get_queued_page(block->idstr, (uint64_t)offset, - *page); + trace_get_queued_page(block->idstr, (uint64_t)offset, page= ); } } =20 @@ -1300,16 +1297,17 @@ err: * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @page: page number of the dirty page */ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, unsigned long page) + bool last_stage) { int res =3D 0; =20 /* Check the pages is dirty and if it is send it */ - if (migration_bitmap_clear_dirty(rs, page)) { + if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { unsigned long *unsentmap; + unsigned long page =3D + (pss->block->offset >> TARGET_PAGE_BITS) + pss->page; if (!rs->preffer_xbzrle && migrate_use_compression()) { res =3D ram_save_compressed_page(rs, pss, last_stage); } else { @@ -1343,25 +1341,22 @@ static int ram_save_target_page(RAMState *rs, PageS= earchStatus *pss, * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @page: Page number of the dirty page */ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, - unsigned long page) + bool last_stage) { int tmppages, pages =3D 0; 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); + tmppages =3D ram_save_target_page(rs, pss, last_stage); if (tmppages < 0) { return tmppages; } =20 pages +=3D tmppages; pss->page++; - page++; } while (pss->page & (pagesize_bits - 1)); =20 /* The offset we leave with is the last one we looked at */ @@ -1388,7 +1383,6 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) PageSearchStatus pss; int pages =3D 0; bool again, found; - unsigned long page; /* Page number of the dirty page */ =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -1405,15 +1399,15 @@ static int ram_find_and_save_block(RAMState *rs, bo= ol last_stage) =20 do { again =3D true; - found =3D get_queued_page(rs, &pss, &page); + found =3D get_queued_page(rs, &pss); =20 if (!found) { /* priority queue empty, so just search for something dirty */ - found =3D find_dirty_block(rs, &pss, &again, &page); + found =3D find_dirty_block(rs, &pss, &again); } =20 if (found) { - pages =3D ram_save_host_page(rs, &pss, last_stage, page); + pages =3D ram_save_host_page(rs, &pss, last_stage); } } while (!pages && again); =20 diff --git a/migration/trace-events b/migration/trace-events index 7372ce2..0a3f033 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -63,7 +63,7 @@ put_qtailq_end(const char *name, const char *reason) "%s = %s" qemu_file_fclose(void) "" =20 # migration/ram.c -get_queued_page(const char *block_name, uint64_t tmp_offset, uint64_t ram_= addr) "%s/%" PRIx64 " ram_addr=3D%" PRIx64 +get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long= page) "%s/%" PRIx64 " page=3D%lu" get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, uin= t64_t ram_addr, int sent) "%s/%" PRIx64 " ram_addr=3D%" PRIx64 " (sent=3D%d= )" migration_bitmap_sync_start(void) "" migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64 --=20 2.9.3