Received: by 2002:a19:c345:0:0:0:0:0 with SMTP id t66csp5487059lff; Tue, 14 Jan 2020 05:10:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwKkWqW2/b9j4x6dKrPcm9XBS/gsJwh6YzjA2JT1Jy7oGAx8OG9rYNEgi6N3cyy1PG6Miiz X-Received: by 2002:a37:85c4:: with SMTP id h187mr22044737qkd.223.1579007451378; Tue, 14 Jan 2020 05:10:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579007451; cv=none; d=google.com; s=arc-20160816; b=IyUWHsTGGOJS0VQGM0SWy8y1g1Pghqo7vEok/qzpY008ifnVJRXgOf9vVlXIGfwl9q SmOMuZLGuTK54R+Hw6kVa5M34ou+oqhOnc324U/bh5PvRk750suwWgc57Sbg29nBWTQK 3HFJI5fxqIigmx9U3sueQFNjaOmHyuO04S9wsOF+HveQSM8y8u3fmIxG2Xvr0YuMXmW2 iFoM6Yb7l1fHMpKyjDMahKgvqGVrlOinl8v/iSIWS5olu8KzznpeBiUGfi4gYcbeHlev mmFIEuw6RWc3tmEslCsFHrE/xG9E8jHIewzyR/6mttpzmdrgmHSlSO+qSRUHTpfHXmcW Kv1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ya1F0mvUWk8XyhM6v0oEY3/vFxdIpuuT2eEdeU07i9U=; b=vOFsS62uCb5CYkKG1G9P0IYBYzJmK/nEjzlAGtdh8LbZ6BFfH/WEs8GO5laXhadHjm WbkmAdkWQQnslYQ6s159vr1p5ZxWhD3Vb5Iw6J2JSZgxe1TKI3mCBX0hv39Sm0Yc4uOT oRwnOQcLR+ozU5egohMFb26QV/fKDZCauysFoFM3sL50uBofAaQmgUwOiw5WgK2HKcr7 MFxltpH3fIEQtmnWOivUbof8ow/XAtPPIZ9oLXcZzrzWEp4Hv0/lvJLFsFNLo0VWGw2h u7TVnGAKjlQbEKnWeq+jflw+j+hfYwoqLvm4ghm1djgCpD7BeA/YiDSx01mtn0zBtBiQ L9eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=YomcFaLP; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a9si7672755qvn.154.2020.01.14.05.10.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jan 2020 05:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=YomcFaLP; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:39132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLy6-00060K-Ar for alex.bennee@linaro.org; Tue, 14 Jan 2020 08:10:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41480) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjg-0003c5-TV for qemu-arm@nongnu.org; Tue, 14 Jan 2020 07:56:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLjd-000260-8X for qemu-arm@nongnu.org; Tue, 14 Jan 2020 07:55:56 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55382 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjd-00025Z-3x for qemu-arm@nongnu.org; Tue, 14 Jan 2020 07:55:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ya1F0mvUWk8XyhM6v0oEY3/vFxdIpuuT2eEdeU07i9U=; b=YomcFaLPNqTDgpjBK2KMmZbhvekGQxXI4rc/jUm4muArv3fptZlBDbCUaDxzqCWQlsr8PZ N0xNLKrZy7SM/x5OuhuhpMpbLYzVQquP9P3LfnESo4R2qr39MfMOp44kBimMREavzX36uW bzzuhXJXwEfJrK5e0nszKY8LFvLpmDs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-ooXaJcDQNCKrHAhYZ5NwTw-1; Tue, 14 Jan 2020 07:55:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 575311800D78; Tue, 14 Jan 2020 12:55:49 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2710B5D9E5; Tue, 14 Jan 2020 12:55:42 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 20/30] migration/postcopy: enable random order target page arrival Date: Tue, 14 Jan 2020 13:52:44 +0100 Message-Id: <20200114125254.4515-21-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: ooXaJcDQNCKrHAhYZ5NwTw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , Marcel Apfelbaum , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , Andrzej Zaborowski , David Gibson Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: uSyzbhTTlysI From: Wei Yang After using number of target page received to track one host page, we could have the capability to handle random order target page arrival in one host page. This is a preparation for enabling compress during postcopy. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 40c3fdd766..cbf8ab6a51 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4050,7 +4050,7 @@ static int ram_load_postcopy(QEMUFile *f) MigrationIncomingState *mis =3D migration_incoming_get_current(); /* Temporary page that is later 'placed' */ void *postcopy_host_page =3D mis->postcopy_tmp_page; - void *last_host =3D NULL; + void *this_host =3D NULL; bool all_zero =3D false; int target_pages =3D 0; =20 @@ -4097,24 +4097,26 @@ static int ram_load_postcopy(QEMUFile *f) * that's moved into place later. * The migration protocol uses, possibly smaller, target-page= s * however the source ensures it always sends all the componen= ts - * of a host page in order. + * of a host page in one chunk. */ page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ if (target_pages =3D=3D 1) { all_zero =3D true; + this_host =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); } else { /* not the 1st TP within the HP */ - if (host !=3D (last_host + TARGET_PAGE_SIZE)) { - error_report("Non-sequential target page %p/%p", - host, last_host); + if (QEMU_ALIGN_DOWN((uintptr_t)host, block->page_size) != =3D + (uintptr_t)this_host) { + error_report("Non-same host page %p/%p", + host, this_host); ret =3D -EINVAL; break; } } =20 - /* * If it's the last part of a host page then we place the host * page @@ -4125,7 +4127,6 @@ static int ram_load_postcopy(QEMUFile *f) } place_source =3D postcopy_host_page; } - last_host =3D host; =20 switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: @@ -4178,7 +4179,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 if (!ret && place_needed) { /* This gets called at the last target page in the host page *= / - void *place_dest =3D host + TARGET_PAGE_SIZE - block->page_siz= e; + void *place_dest =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); =20 if (all_zero) { ret =3D postcopy_place_page_zero(mis, place_dest, --=20 2.24.1