From patchwork Mon Dec 19 14:13:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 132256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 41E9DB704E for ; Tue, 20 Dec 2011 02:19:26 +1100 (EST) Received: from localhost ([::1]:52017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RcdzX-0005FN-BL for incoming@patchwork.ozlabs.org; Mon, 19 Dec 2011 09:14:59 -0500 Received: from eggs.gnu.org ([140.186.70.92]:48558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdyk-0002wV-A7 for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rcdyi-0001vr-PY for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdyi-0001v5-F8 for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:08 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBJEE5QZ012055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Dec 2011 09:14:05 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBJEE0NB009673; Mon, 19 Dec 2011 09:14:04 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id C0CE7250BB2; Mon, 19 Dec 2011 16:13:54 +0200 (IST) From: Avi Kivity To: Stefano Stabellini , qemu-devel@nongnu.org, "Michael S. Tsirkin" Date: Mon, 19 Dec 2011 16:13:40 +0200 Message-Id: <1324304024-11220-20-git-send-email-avi@redhat.com> In-Reply-To: <1324304024-11220-1-git-send-email-avi@redhat.com> References: <1324304024-11220-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: xen-devel@lists.xensource.com, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 19/23] kvm: avoid cpu_get_physical_page_desc() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This reaches into the innards of the memory core, which are being changed. Switch to a memory API version. Signed-off-by: Avi Kivity --- kvm-all.c | 27 ++++++++++----------------- 1 files changed, 10 insertions(+), 17 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 138e0a2..d94710c 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -340,16 +340,12 @@ static int kvm_set_migration_log(int enable) } /* get kvm's dirty pages bitmap and update qemu's */ -static int kvm_get_dirty_pages_log_range(unsigned long start_addr, - unsigned long *bitmap, - unsigned long offset, - unsigned long mem_size) +static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, + unsigned long *bitmap) { unsigned int i, j; unsigned long page_number, addr, addr1, c; - ram_addr_t ram_addr; - unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / - HOST_LONG_BITS; + unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; /* * bitmap-traveling is faster than memory-traveling (for addr...) @@ -363,9 +359,8 @@ static int kvm_get_dirty_pages_log_range(unsigned long start_addr, c &= ~(1ul << j); page_number = i * HOST_LONG_BITS + j; addr1 = page_number * TARGET_PAGE_SIZE; - addr = offset + addr1; - ram_addr = cpu_get_physical_page_desc(addr); - cpu_physical_memory_set_dirty(ram_addr); + addr = section->offset_within_region + addr1; + memory_region_set_dirty(section->mr, addr); } while (c != 0); } } @@ -382,14 +377,15 @@ static int kvm_get_dirty_pages_log_range(unsigned long start_addr, * @start_add: start of logged region. * @end_addr: end of logged region. */ -static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, - target_phys_addr_t end_addr) +static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) { KVMState *s = kvm_state; unsigned long size, allocated_size = 0; KVMDirtyLog d; KVMSlot *mem; int ret = 0; + target_phys_addr_t start_addr = section->offset_within_address_space; + target_phys_addr_t end_addr = start_addr + section->size; d.dirty_bitmap = NULL; while (start_addr < end_addr) { @@ -428,8 +424,7 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, break; } - kvm_get_dirty_pages_log_range(mem->start_addr, d.dirty_bitmap, - mem->start_addr, mem->memory_size); + kvm_get_dirty_pages_log_range(section, d.dirty_bitmap); start_addr = mem->start_addr + mem->memory_size; } g_free(d.dirty_bitmap); @@ -686,11 +681,9 @@ static void kvm_region_del(MemoryListener *listener, static void kvm_log_sync(MemoryListener *listener, MemoryRegionSection *section) { - target_phys_addr_t start = section->offset_within_address_space; - target_phys_addr_t end = start + section->size; int r; - r = kvm_physical_sync_dirty_bitmap(start, end); + r = kvm_physical_sync_dirty_bitmap(section); if (r < 0) { abort(); }