From patchwork Mon Jun 4 09:57:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 162770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9F674B7011 for ; Mon, 4 Jun 2012 21:52:41 +1000 (EST) Received: from localhost ([::1]:41769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU5P-00039F-WF for incoming@patchwork.ozlabs.org; Mon, 04 Jun 2012 06:00:32 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU33-0008Ta-Ry for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:58:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbU2r-0004du-CX for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:58:05 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:46505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU2q-0004at-U6 for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:57:53 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 8FDE34899B; Mon, 4 Jun 2012 18:57:47 +0900 (JST) Received: (nullmailer pid 5188 invoked by uid 1000); Mon, 04 Jun 2012 09:57:46 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Mon, 4 Jun 2012 18:57:41 +0900 Message-Id: <2e2e0c47e7836a8e3a74b837b81588e9e875bde0.1338802192.git.yamahata@valinux.co.jp> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 210.128.90.3 Cc: benoit.hudzia@gmail.com, aarcange@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, t.hirofuchi@aist.go.jp, dlaor@redhat.com, satoshi.itoh@aist.go.jp, mdroth@linux.vnet.ibm.com, yoshikawa.takuya@oss.ntt.co.jp, owasserm@redhat.com, avi@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v2 39/41] postcopy/outgoing: implement prefault 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 When page is requested, send surrounding pages are also sent. Signed-off-by: Isaku Yamahata --- migration-postcopy.c | 56 +++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 51 insertions(+), 5 deletions(-) diff --git a/migration-postcopy.c b/migration-postcopy.c index eb37094..6165657 100644 --- a/migration-postcopy.c +++ b/migration-postcopy.c @@ -353,6 +353,36 @@ int postcopy_outgoing_ram_save_live(QEMUFile *f, int stage, void *opaque) return ret; } +static void postcopy_outgoing_ram_save_page(PostcopyOutgoingState *s, + uint64_t pgoffset, bool *written, + bool forward, + int prefault_pgoffset) +{ + ram_addr_t offset; + int ret; + + if (forward) { + pgoffset += prefault_pgoffset; + } else { + if (pgoffset < prefault_pgoffset) { + return; + } + pgoffset -= prefault_pgoffset; + } + + offset = pgoffset << TARGET_PAGE_BITS; + if (offset >= s->last_block_read->length) { + assert(forward); + assert(prefault_pgoffset > 0); + return; + } + + ret = ram_save_page(s->mig_buffered_write, s->last_block_read, offset); + if (ret > 0) { + *written = true; + } +} + /* * return value * 0: continue postcopy mode @@ -364,6 +394,7 @@ static int postcopy_outgoing_handle_req(PostcopyOutgoingState *s, bool *written) { int i; + uint64_t j; RAMBlock *block; DPRINTF("cmd %d state %d\n", req->cmd, s->state); @@ -398,11 +429,26 @@ static int postcopy_outgoing_handle_req(PostcopyOutgoingState *s, break; } for (i = 0; i < req->nr; i++) { - DPRINTF("offs[%d] 0x%"PRIx64"\n", i, req->pgoffs[i]); - int ret = ram_save_page(s->mig_buffered_write, s->last_block_read, - req->pgoffs[i] << TARGET_PAGE_BITS); - if (ret > 0) { - *written = true; + DPRINTF("pgoffs[%d] 0x%"PRIx64"\n", i, req->pgoffs[i]); + postcopy_outgoing_ram_save_page(s, req->pgoffs[i], written, + true, 0); + } + /* forward prefault */ + for (j = 1; j <= s->ms->params.prefault_forward; j++) { + for (i = 0; i < req->nr; i++) { + DPRINTF("pgoffs[%d] + 0x%"PRIx64" 0x%"PRIx64"\n", + i, j, req->pgoffs[i] + j); + postcopy_outgoing_ram_save_page(s, req->pgoffs[i], written, + true, j); + } + } + /* backward prefault */ + for (j = 1; j <= s->ms->params.prefault_backward; j++) { + for (i = 0; i < req->nr; i++) { + DPRINTF("pgoffs[%d] - 0x%"PRIx64" 0x%"PRIx64"\n", + i, j, req->pgoffs[i] - j); + postcopy_outgoing_ram_save_page(s, req->pgoffs[i], written, + false, j); } } break;