From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88248C4BA12 for ; Wed, 26 Feb 2020 15:54:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 581E5222C2 for ; Wed, 26 Feb 2020 15:54:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fvSUnfJI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 581E5222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6z1Q-0003yp-GB for qemu-devel@archiver.kernel.org; Wed, 26 Feb 2020 10:54:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33884) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6z08-0002Qc-KM for qemu-devel@nongnu.org; Wed, 26 Feb 2020 10:53:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6z07-0002G8-8q for qemu-devel@nongnu.org; Wed, 26 Feb 2020 10:53:32 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22905 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 1j6z07-0002Fs-5C for qemu-devel@nongnu.org; Wed, 26 Feb 2020 10:53:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582732410; 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; bh=Vl2hCVippo1INZegASPeZHcaHQ5Tuv+1R5+bAXmxp68=; b=fvSUnfJIl6KN4uQ1n7OK2t7DTyKvMaK2ud2Hp1OmAhIi1mNjsyU1Ww0WOM84JY4MI5Cr64 oSDiLhkKGT0EyWbejd/d/YtobKfAGHzOmNJM73f0mfvk3RAT2g0S39iRJWwzmLcyocxQ8N fjNGrd8oGlalPvvGzDkQ9nJ1RCPOq4s= 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-382-dq4OQj2uPQ-4Uki2HnBtlQ-1; Wed, 26 Feb 2020 10:53:23 -0500 X-MC-Unique: dq4OQj2uPQ-4Uki2HnBtlQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A44F100A5F1; Wed, 26 Feb 2020 15:53:21 +0000 (UTC) Received: from t480s.redhat.com (ovpn-117-196.ams2.redhat.com [10.36.117.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9581B1001DC0; Wed, 26 Feb 2020 15:53:05 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v3 00/13] migrate/ram: Fix resizing RAM blocks while migrating Date: Wed, 26 Feb 2020 16:52:51 +0100 Message-Id: <20200226155304.60219-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrea Arcangeli , Stefano Stabellini , Eduardo Habkost , Juan Quintela , Stefan Hajnoczi , David Hildenbrand , Richard Henderson , "Dr . David Alan Gilbert" , Peter Xu , Paul Durrant , Alex Williamson , "Michael S. Tsirkin" , Shannon Zhao , Igor Mammedov , Anthony Perard , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This is the follow up of "[PATCH RFC] memory: Don't allow to resize RAM while migrating" [1] This series contains some (slightly modified) patches also contained in: "[PATCH v2 fixed 00/16] Ram blocks with resizable anonymous allocations under POSIX" [2] That series will be based on this series. The last patch (#13) in this series could be moved to the other series, but I decided to include it in here for now (similar context). I realized that resizing RAM blocks while the guest is being migrated (precopy: resize while still running on the source, postcopy: resize while already running on the target) is buggy. In case of precopy, we can simply cancel migration. Postcopy handling is more involved. Resizing can currently happen during a guest reboot, triggered by ACPI rebuilds. Along with the fixes, some cleanups. [1] https://lkml.kernel.org/r/20200213172016.196609-1-david@redhat.com [2] https://lkml.kernel.org/r/20200212134254.11073-1-david@redhat.com I am using the prototype of virtio-mem to test (which also makes use of resizable allocations). Things I was able to reproduce: - Resize while still running on the migration source. Migration is canceled -- Test case for "migraton/ram: Handle RAM block resizes during precopy" - Resize (grow+shrink) on the migration target during postcopy migration in the precopy stage (when syncing RAM blocks). -- Test case for "migration/ram: Discard RAM when growing RAM blocks after ram_postcopy_incoming_init()" and overall RAM size synchronization in the precopy stage. - Resize (grow+shrink) on the migration tagret during postcopy migration while already running on the target. -- Test case for "migration/ram: Handle RAM block resizes during postcopy" -- Test case for "migration/ram: Tolerate partially changed mappings in postcopy code" - I can see that -ENOENT is actually triggered and that migration succeeds. Migration seems to work just fine. In addition I run avocado-vt migration tests + usual QEMU checks. v2 -> v3: - Rebased on current master - Added RBs - "migration/ram: Tolerate partially changed mappings in postcopy code" -- Extended the comment for the uffdio unregister part. v1 -> v2: - "util: vfio-helpers: Factor out and fix processing of existing ram blocks" -- Stringify error - "migraton/ram: Handle RAM block resizes during precopy" -- Simplified check if we're migrating on the source - "exec: Relax range check in ram_block_discard_range()" -- Added to make discard during resizes actually work - "migration/ram: Discard new RAM when growing RAM blocks after ram_postcopy_incoming_init()" -- Better checks if in the right postcopy mode. -- Better patch subject/description/comments - "migration/ram: Handle RAM block resizes during postcopy" -- Better comments -- Adapt to changed postcopy checks - "migrate/ram: Get rid of "place_source" in ram_load_postcopy()" -- Dropped, as broken - "migration/ram: Tolerate partially changed mappings in postcopy code" -- Better comment / description. Clarify that no implicit wakeup will happen -- Warn on EINVAL (older kernels) -- Wake up any waiter explicitly David Hildenbrand (13): util: vfio-helpers: Factor out and fix processing of existing ram blocks stubs/ram-block: Remove stubs that are no longer needed numa: Teach ram block notifiers about resizeable ram blocks numa: Make all callbacks of ram block notifiers optional migration/ram: Handle RAM block resizes during precopy exec: Relax range check in ram_block_discard_range() migration/ram: Discard RAM when growing RAM blocks after ram_postcopy_incoming_init() migration/ram: Simplify host page handling in ram_load_postcopy() migration/ram: Consolidate variable reset after placement in ram_load_postcopy() migration/ram: Handle RAM block resizes during postcopy migration/multifd: Print used_length of memory block migration/ram: Use offset_in_ramblock() in range checks migration/ram: Tolerate partially changed mappings in postcopy code exec.c | 27 +++++-- hw/core/numa.c | 41 +++++++++-- hw/i386/xen/xen-mapcache.c | 7 +- include/exec/cpu-common.h | 1 + include/exec/memory.h | 10 +-- include/exec/ramblock.h | 10 +++ include/exec/ramlist.h | 13 ++-- migration/migration.c | 9 ++- migration/migration.h | 1 + migration/multifd.c | 2 +- migration/postcopy-ram.c | 54 +++++++++++++- migration/ram.c | 144 ++++++++++++++++++++++++++++--------- stubs/ram-block.c | 20 ------ target/i386/hax-mem.c | 5 +- target/i386/sev.c | 18 ++--- util/vfio-helpers.c | 41 ++++------- 16 files changed, 285 insertions(+), 118 deletions(-) --=20 2.24.1