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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 C0CD2C433E0 for ; Tue, 19 Jan 2021 19:32:13 +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 24A7423108 for ; Tue, 19 Jan 2021 19:32:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24A7423108 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]:57688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1wjb-000682-OK for qemu-devel@archiver.kernel.org; Tue, 19 Jan 2021 14:32:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1w4Y-00037u-Pt for qemu-devel@nongnu.org; Tue, 19 Jan 2021 13:49:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l1w4U-0003OR-QJ for qemu-devel@nongnu.org; Tue, 19 Jan 2021 13:49:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611082181; 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: in-reply-to:in-reply-to:references:references; bh=H7VJ5MiBCmmnFOA63SOxUr95vzWqr3sK2jd1G5Au9ZU=; b=K9JcSlcgG60cokT/AK99ot5bZQKFNST9HQwJcdKpVC2a3OtZ/OUDiKHuSKftzz+NTElIB1 l+t3lnBiHUdVmSmnLO7foJrdzRauRaWZaGwjd0DEDF9+VkVvUAwRGSll9Db8eAip025ExU DJOXOGFV7G2uaZILb52jqaWbuyjQLqQ= 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-560-3OXzJBwYMDiPH38D33CPtA-1; Tue, 19 Jan 2021 13:49:39 -0500 X-MC-Unique: 3OXzJBwYMDiPH38D33CPtA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DCB780A5C0; Tue, 19 Jan 2021 18:49:38 +0000 (UTC) Received: from work-vm (ovpn-115-97.ams2.redhat.com [10.36.115.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E656F669EC; Tue, 19 Jan 2021 18:49:33 +0000 (UTC) Date: Tue, 19 Jan 2021 18:49:31 +0000 From: "Dr. David Alan Gilbert" To: Andrey Gruzdev Subject: Re: [PATCH v11 4/5] migration: implementation of background snapshot thread Message-ID: <20210119184931.GJ3008@work-vm> References: <20210106152120.31279-1-andrey.gruzdev@virtuozzo.com> <20210106152120.31279-5-andrey.gruzdev@virtuozzo.com> MIME-Version: 1.0 In-Reply-To: <20210106152120.31279-5-andrey.gruzdev@virtuozzo.com> User-Agent: Mutt/1.14.6 (2020-07-11) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=63.128.21.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.195, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Juan Quintela , qemu-devel@nongnu.org, Peter Xu , Markus Armbruster , Paolo Bonzini , Den Lunev Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" * Andrey Gruzdev (andrey.gruzdev@virtuozzo.com) wrote: > Introducing implementation of 'background' snapshot thread > which in overall follows the logic of precopy migration > while internally utilizes completely different mechanism > to 'freeze' vmstate at the start of snapshot creation. > > This mechanism is based on userfault_fd with wr-protection > support and is Linux-specific. I noticed there weren't any bdrv_ calls in here; I guess with a snapshot you still have the source running so still have it accessing the disk; do you do anything to try and wire the ram snapshotting up to disk snapshotting? > Signed-off-by: Andrey Gruzdev > Acked-by: Peter Xu > --- > migration/migration.c | 255 +++++++++++++++++++++++++++++++++++++++++- > migration/migration.h | 3 + > migration/ram.c | 2 + > migration/savevm.c | 1 - > migration/savevm.h | 2 + > 5 files changed, 260 insertions(+), 3 deletions(-) > > diff --git a/migration/migration.c b/migration/migration.c > index 2c2cb9ef01..0901a15ac5 100644 > - qemu_thread_create(&s->thread, "live_migration", migration_thread, s, > - QEMU_THREAD_JOINABLE); > + > + if (migrate_background_snapshot()) { > + qemu_thread_create(&s->thread, "background_snapshot", Unfortunately that wont work - there's a 14 character limit on the thread name length; I guess we just shorten that to bg_snapshot Other than that, Reviewed-by: Dr. David Alan Gilbert > + bg_migration_thread, s, QEMU_THREAD_JOINABLE); > + } else { > + qemu_thread_create(&s->thread, "live_migration", > + migration_thread, s, QEMU_THREAD_JOINABLE); > + } > s->migration_thread_running = true; > } > > diff --git a/migration/migration.h b/migration/migration.h > index f40338cfbf..0723955cd7 100644 > --- a/migration/migration.h > +++ b/migration/migration.h > @@ -20,6 +20,7 @@ > #include "qemu/thread.h" > #include "qemu/coroutine_int.h" > #include "io/channel.h" > +#include "io/channel-buffer.h" > #include "net/announce.h" > #include "qom/object.h" > > @@ -147,8 +148,10 @@ struct MigrationState { > > /*< public >*/ > QemuThread thread; > + QEMUBH *vm_start_bh; > QEMUBH *cleanup_bh; > QEMUFile *to_dst_file; > + QIOChannelBuffer *bioc; > /* > * Protects to_dst_file pointer. We need to make sure we won't > * yield or hang during the critical section, since this lock will > diff --git a/migration/ram.c b/migration/ram.c > index 5707382db1..05fe0c8592 100644 > --- a/migration/ram.c > +++ b/migration/ram.c > @@ -1471,6 +1471,7 @@ static RAMBlock *poll_fault_page(RAMState *rs, ram_addr_t *offset) > page_address = (void *) uffd_msg.arg.pagefault.address; > bs = qemu_ram_block_from_host(page_address, false, offset); > assert(bs && (bs->flags & RAM_UF_WRITEPROTECT) != 0); > + > return bs; > } > #endif /* CONFIG_LINUX */ > @@ -1836,6 +1837,7 @@ static void ram_save_host_page_post(RAMState *rs, PageSearchStatus *pss, > /* Un-protect memory range. */ > res = uffd_change_protection(rs->uffdio_fd, page_address, run_length, > false, false); > + > /* We don't want to override existing error from ram_save_host_page(). */ > if (res < 0 && *res_override >= 0) { > *res_override = res; > diff --git a/migration/savevm.c b/migration/savevm.c > index 27e842812e..dd4ad0aaaf 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -1354,7 +1354,6 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy) > return 0; > } > > -static > int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, > bool in_postcopy, > bool inactivate_disks) > diff --git a/migration/savevm.h b/migration/savevm.h > index ba64a7e271..aaee2528ed 100644 > --- a/migration/savevm.h > +++ b/migration/savevm.h > @@ -64,5 +64,7 @@ int qemu_loadvm_state(QEMUFile *f); > void qemu_loadvm_state_cleanup(void); > int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); > int qemu_load_device_state(QEMUFile *f); > +int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, > + bool in_postcopy, bool inactivate_disks); > > #endif > -- > 2.25.1 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK