From nobody Sat May 18 21:45:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588103073; cv=none; d=zohomail.com; s=zohoarc; b=OBPl+fkm4byPO8FbXKZKpBEkYfGfd2mbuEK8ilOOkJS0qSztyssfup19lQMWtwpjCN0yCD+95s/JUgtFA7xacSpZr5gDF4akM8sVCX/S7Iww/+Q8kfsrAE/8q9Ok6kFCQjw09Z3hAZWrnPUWCi3wvKIYaVENvoiaXP3v+e8fUL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588103073; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EZznPfOzrDLzLrIvwsRJ50QCk3D2FtsvBi3yPYnpJWI=; b=GD7bo8Hau3qux0Jh3P0SiF38mXQLPOTOsc+8FKNhVNiRUfpiieKyFlRcvo2WtNbKWVWa2PkRrO4UC1He3aE2CLx2P7r6UiOxWCTjU5RDewnbTlHMxuBPFKQfZmsMMQrz0/rp2Zzaq7K3FSFvoIrvSlc3PLulJhoDvPI2XrWl+ro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588103073460200.63083438928084; Tue, 28 Apr 2020 12:44:33 -0700 (PDT) Received: from localhost ([::1]:47678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTW9d-0007xG-EC for importer@patchew.org; Tue, 28 Apr 2020 15:44:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33404) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTW7Z-0005dv-Lr for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTW7Y-0006sg-NA for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:42:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25344 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTW7Y-0006sC-8L for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:42:20 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-397-1atRpVX6P_a6HtK8DEG1bw-1; Tue, 28 Apr 2020 15:42:17 -0400 Received: by mail-qk1-f197.google.com with SMTP id a187so24442856qkg.18 for ; Tue, 28 Apr 2020 12:42:17 -0700 (PDT) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id j92sm14275237qtd.58.2020.04.28.12.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 12:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588102939; 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=EZznPfOzrDLzLrIvwsRJ50QCk3D2FtsvBi3yPYnpJWI=; b=ILMdzVFbFFz1tLAYcZUu9YutdrmOKB+irlamkvpJrhZK1F8jfKNmCrCDZaN9rtuA36zGyh EYFfAjYs7KvSM1ASgmqpBnsYg9JUpk/sURGeLYtBKPdUWkVhhfB8c+LeHJ3vKMOOpp5mLL msmueoy1v6krk85XGShNHq4rK9AV6Ok= X-MC-Unique: 1atRpVX6P_a6HtK8DEG1bw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j8HZaXRpKqMlGVGZxC3vqXUpalYaLscomhn30S95wLk=; b=P/1s0lFUkr8CoxNx0Y6L99jAeN90VrGhSwcdE3zLTyIlUaPZwM8YqL6AokuBtf/8FP Tm8CldPLAnsTeMNbLWqmbn+AGb/ILXddVKLcQq/qOS6BG7lBk8N+GqjMrAO68nA4PWLW HS9bqPS1L55UqZ4Nmz+w7vLMDyGJYB16tN2cg1k2U7pCHZqTS7w5nuTWqcMaYzEFmBIx HMCslOHE0m7yNEbR4OsTyukl+Kq4oBGZ9KDG7rt6Emx5+S+0Y7YAqb7qJU1negGK5Bv1 CZirs9IaVYujEAVa14l8QHiqRE7eyh1giue3R10jW9uTUxglo70N5Byz8HIhRm5IQgeJ xFdQ== X-Gm-Message-State: AGi0PuZ9/GmiSm/qhJxKdI95jvu2HNlTvDdXa0UaYwZHUPsIL4zVNUVy mxd9uV7ZS1/sqCZvzgC8Gd4cQr937ho8hf5mHL28jKUR3qk6+4aygQoNRkomizwV3KRG4ymk0ct 2t0ti3WMI6oggKOw= X-Received: by 2002:a37:6191:: with SMTP id v139mr26818554qkb.469.1588102937155; Tue, 28 Apr 2020 12:42:17 -0700 (PDT) X-Google-Smtp-Source: APiQypI/1TuGLJnOpmLJPszo7iUOvTCnD2YASytQt0QUljLXX9AwU7HLc9zbNuiEIxKXBh/R6yzZRQ== X-Received: by 2002:a37:6191:: with SMTP id v139mr26818522qkb.469.1588102936904; Tue, 28 Apr 2020 12:42:16 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH RFC 1/4] migration: Export migration_bitmap_sync_precopy() Date: Tue, 28 Apr 2020 15:42:16 -0400 Message-Id: <20200428194219.10963-2-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200428194219.10963-1-peterx@redhat.com> References: <20200428194219.10963-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=peterx@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/28 04:15:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.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: Paolo Bonzini , Tian Kevin , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make it usable outside migration. To make it easier to use, remove the RAMState parameter since after all ram.c has the reference of ram_state directly from its context. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert --- include/migration/misc.h | 1 + migration/ram.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index d2762257aa..e338be8c30 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -66,6 +66,7 @@ void remove_migration_state_change_notifier(Notifier *not= ify); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); +void migration_bitmap_sync_precopy(void); /* ...and after the device transmission */ bool migration_in_postcopy_after_devices(MigrationState *); void migration_global_dump(Monitor *mon); diff --git a/migration/ram.c b/migration/ram.c index 04f13feb2e..d737175d4e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -970,7 +970,7 @@ static void migration_bitmap_sync(RAMState *rs) } } =20 -static void migration_bitmap_sync_precopy(RAMState *rs) +void migration_bitmap_sync_precopy(void) { Error *local_err =3D NULL; =20 @@ -983,7 +983,7 @@ static void migration_bitmap_sync_precopy(RAMState *rs) local_err =3D NULL; } =20 - migration_bitmap_sync(rs); + migration_bitmap_sync(ram_state); =20 if (precopy_notify(PRECOPY_NOTIFY_AFTER_BITMAP_SYNC, &local_err)) { error_report_err(local_err); @@ -2303,7 +2303,7 @@ static void ram_init_bitmaps(RAMState *rs) WITH_RCU_READ_LOCK_GUARD() { ram_list_init_bitmaps(); memory_global_dirty_log_start(); - migration_bitmap_sync_precopy(rs); + migration_bitmap_sync_precopy(); } qemu_mutex_unlock_ramlist(); qemu_mutex_unlock_iothread(); @@ -2592,7 +2592,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) =20 WITH_RCU_READ_LOCK_GUARD() { if (!migration_in_postcopy()) { - migration_bitmap_sync_precopy(rs); + migration_bitmap_sync_precopy(); } =20 ram_control_before_iterate(f, RAM_CONTROL_FINISH); @@ -2642,7 +2642,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, remaining_size < max_size) { qemu_mutex_lock_iothread(); WITH_RCU_READ_LOCK_GUARD() { - migration_bitmap_sync_precopy(rs); + migration_bitmap_sync_precopy(); } qemu_mutex_unlock_iothread(); remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; --=20 2.24.1 From nobody Sat May 18 21:45:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588103158; cv=none; d=zohomail.com; s=zohoarc; b=ckft6jPxKv8fS35APHQ40PkRMrjPQBNqZnQDtTYHQEfM0stsmZK9wjqARnxx4DqpIIW67oxIcRVDB2gEhmf8nA0ZAayzvyD6tpStqICvBrh+uDeYVQyS1tG8NtbAJKRt8yeDLKQXqnrsfYwM6Rzo1kigWz7cSJUy9I5nJ52dtTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588103158; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zuy1iMRmPIFo+AO2BN7flgYL2QbOrH67o5VmfdIqjvI=; b=jIjEh5TDk6cZQzTFDwVUmkHXRt8aRPmiaG6QpgFR05rJ1/oRbcjIbYrQYt815ChnEF0F9oGQfLPu0WogkXgx+t0b6wBdYgEtNBqXUw04jWLZXmdmasXf6R/LLabGet8pHJPAYoV0+sbGpZLwsMzKgkWiKugW0K08/elmmUVTPDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588103158652921.7074924261168; Tue, 28 Apr 2020 12:45:58 -0700 (PDT) Received: from localhost ([::1]:47816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTWB3-0002cy-B3 for importer@patchew.org; Tue, 28 Apr 2020 15:45:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33418) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTW7h-0005iI-Qo for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTW7f-0006uj-EJ for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:42:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:20295 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTW7d-0006tS-UZ for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:42:26 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-sBZsa508OdOebFTOawZ95A-1; Tue, 28 Apr 2020 15:42:20 -0400 Received: by mail-qk1-f199.google.com with SMTP id 11so19519638qkh.7 for ; Tue, 28 Apr 2020 12:42:20 -0700 (PDT) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id n92sm14133460qtd.68.2020.04.28.12.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 12:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588102944; 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=Zuy1iMRmPIFo+AO2BN7flgYL2QbOrH67o5VmfdIqjvI=; b=J2iPg9/GUxavurcDRu0bV2BjJyG7MsC4/QM+H2xZUhdX/vTkaoJCRgX+SbgRXlPR5lUcpF 5FX+aCKZmJRS5ICq3rJIZ6Vowzy7fIb0c2Ebx8KunKKvPd74kKRcf/nRIXaQlgdQ5hODY2 YGZhzwQyW7uH7JF81jd99diz98pMkw0= X-MC-Unique: sBZsa508OdOebFTOawZ95A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xuRNcZqOedqLdZtDlBrMErqG8jwgO5FGr6fT7gMV6U0=; b=YHuVoaLTCMGqG2MCbTxQGdxbA2QWRaRWeM5cdoKZgej1N/3DRYmK/J6PRNjDOb2UBs KMh/d/dRq5+vWjL6NZnKbR6cn57ubs9DUCDNrVMhwBToRABNTIqzkKYCLDgUuK5ZdjmB Q+wnIVsMsLpc7ill6Ykuagnuz6/hhpb4kUm9Jir46DzbqXLHsrANFQSmMYu8x5ZnU+oL C3ph208y1wsCgwXLGKFS0+kiw+1jKEDzRVzeTSyIR8rtmiQzPGDgZtfZQur5M/Ecu7MN /CziczpI+zb+4pLAdttXdcKiF1NSm39zzMGRjnoknzDxGkaZxLAbONYjFL9ha1512LNQ 9biw== X-Gm-Message-State: AGi0PubN7ORVDKc+xM6CORx6mhZ4fEy38zw4zVz8FhWcn3SFcrMNJr2Z B/bzxDf4mWpA35xWPNOeMHewWESM5TjToRP+VJvu+3rpi0uIcTkUd63dA5Aju0Af8xHAdaf5ZCl l/VRLVCJk5XizdYs= X-Received: by 2002:a37:5744:: with SMTP id l65mr30286835qkb.470.1588102940202; Tue, 28 Apr 2020 12:42:20 -0700 (PDT) X-Google-Smtp-Source: APiQypIVpkZMo/e+bCoONrLDgj6/d0/g5VJRBmytw7HmuYUyErWUzOP1kxPmZccdIYlgsoQ4CHxigA== X-Received: by 2002:a37:5744:: with SMTP id l65mr30286816qkb.470.1588102939983; Tue, 28 Apr 2020 12:42:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH RFC 2/4] migration: Introduce migrate_is_precopy() Date: Tue, 28 Apr 2020 15:42:17 -0400 Message-Id: <20200428194219.10963-3-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200428194219.10963-1-peterx@redhat.com> References: <20200428194219.10963-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=peterx@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/28 02:16:38 X-ACL-Warn: Detected OS = 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: Paolo Bonzini , Tian Kevin , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Export a helper globally to check whether we're during a precopy. Signed-off-by: Peter Xu --- include/migration/misc.h | 1 + migration/migration.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/migration/misc.h b/include/migration/misc.h index e338be8c30..b4f6bf7842 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -61,6 +61,7 @@ void migration_shutdown(void); void qemu_start_incoming_migration(const char *uri, Error **errp); bool migration_is_idle(void); bool migration_is_active(MigrationState *); +bool migration_is_precopy(void); void add_migration_state_change_notifier(Notifier *notify); void remove_migration_state_change_notifier(Notifier *notify); bool migration_in_setup(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 187ac0410c..0082880279 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1795,6 +1795,13 @@ bool migration_is_active(MigrationState *s) s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); } =20 +bool migration_is_precopy(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s && s->state =3D=3D MIGRATION_STATUS_ACTIVE; +} + void migrate_init(MigrationState *s) { /* --=20 2.24.1 From nobody Sat May 18 21:45:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588103248; cv=none; d=zohomail.com; s=zohoarc; b=cH57JFH1u7RPIz9BjuQuv3mPuJTnJlRMPYLTC1xqnO/JJ5yj/Qpce22f8SDTc995pIxnrYxphCISUUpP5HbzlHdJ/FIoMoE9RHjfV5iZMD9O+7PARBtTT0k1njryItqCFBK60U9ACDAjmKnXfasSxJkVUca/h/bEVCIdwVCNaKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588103248; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KWiKFx7T2RcB/8ceBskFUXxef1SdqAE1qyzvy2ePBgA=; b=jcsG/wGMBd1O+dvSgdunfMIyuXGMVVcmBwTnvnuIJQTUdR0kBjdYLfzQtd3m2RM4texA69fKpB7ReMc3WnLCQa7ozssxxzyW6iYWMusaHjXMs/MPUbcH5nLuhhbY5NpmuEFmTLsXvZhKBHN+1CTebv5nrxloeRJJHnEy81C2DQQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588103248056206.61695558326835; Tue, 28 Apr 2020 12:47:28 -0700 (PDT) Received: from localhost ([::1]:47904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTWCU-0005F0-PI for importer@patchew.org; Tue, 28 Apr 2020 15:47:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33538) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTW8j-0006oQ-Ru for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:43:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTW8j-0007Az-B5 for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:43:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60502 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTW8i-0007As-U6 for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:43:32 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-JJO1Meg_PVamgTTddoM4Jw-1; Tue, 28 Apr 2020 15:43:30 -0400 Received: by mail-qk1-f199.google.com with SMTP id x7so24473666qkb.17 for ; Tue, 28 Apr 2020 12:43:30 -0700 (PDT) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id j92sm14277695qtd.58.2020.04.28.12.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 12:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588103012; 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=KWiKFx7T2RcB/8ceBskFUXxef1SdqAE1qyzvy2ePBgA=; b=ENWQ1YNj7MKl5cZEgDr/nWcvcNvYC2Irz/cJo/cnGh48/dzvz/6PNRpkFX2fq3l36fsKCd gR+ASMUxPgGGtE9sITGmgBP4Ea0zWAVJ+Ilv0iaDB+3O1XJFnLwVZ0wejFAydhcvaaoKMJ 0HiN087C7n+7H/yhxI+LGSqbvrlhZkk= X-MC-Unique: JJO1Meg_PVamgTTddoM4Jw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l9EJm6lx5UW6V7ifVpZVbM1fIyRcFIsgTY1TmlPa2ZA=; b=ctzr3aAYnaHspEN9egXmCb0OnnMEDNulfetynhWa2+qwuAj0MlJBoqZfZKrRSULDtc 7fr3CPBA/73aMqMhuvTlxWygPxASTHW+vqS/tZ3qi5mD8evZi9G/U91+v4pBiLBhwr8y qEpoYN5iG4WUCDjhw3V/mHQp70+jAZkWn4OZHJSs70MGOSRY4+hV8aFpLOAhCO4Z9gI0 rBFIA2UNqEMTkVwvvz7U6cWi51w3ti9WLhCHfQBqfafpWRnnhI8i3pZCPIE0egFvyjo5 4qddADPy7ACTHyWa2B0YqN/T34RadRTpH3xn8iML+1fMcenTQ/cYYhFg+CL4dyxEYFee tG/w== X-Gm-Message-State: AGi0PuYpn1ceUozznh/yItp4clEGVY2N6Dbds8xkRQfA2fGyuRShLYiB bzci/eeOvSyYHaqwA9N2EocJg1lxjruL1euG824e1XE/GHJu+uXMz6DaauRI//+egzGy//xeTYp UJspzN8FpLHNNYvk= X-Received: by 2002:a37:a090:: with SMTP id j138mr29953692qke.168.1588103009498; Tue, 28 Apr 2020 12:43:29 -0700 (PDT) X-Google-Smtp-Source: APiQypLpD/bS2J5EyCoFE9zrsM73H3G52b3w5H7U4t7mnMuvlwvlpzdkMhqq9+flZsofYaZSH6H5qQ== X-Received: by 2002:a37:a090:: with SMTP id j138mr29953508qke.168.1588103006960; Tue, 28 Apr 2020 12:43:26 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH RFC 3/4] vl: Sync dirty bits for system resets during precopy Date: Tue, 28 Apr 2020 15:42:18 -0400 Message-Id: <20200428194219.10963-4-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200428194219.10963-1-peterx@redhat.com> References: <20200428194219.10963-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=peterx@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/28 02:16:38 X-ACL-Warn: Detected OS = 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: Paolo Bonzini , Tian Kevin , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" System resets will also reset system memory layout. Although the memory la= yout after the reset should probably the same as before the reset, we still need= to do frequent memory section removals and additions during the reset process. Those operations could accidentally lose per-mem-section information like K= VM memslot dirty bitmaps. Previously we keep those dirty bitmaps by sync it during memory removal. However that's hard to make it right after all [1]. Instead, we sync dirty pages before system reset if we know we're during a precopy migration. This should solve the same problem explicitly. [1] https://lore.kernel.org/qemu-devel/20200327150425.GJ422390@xz-x1/ Signed-off-by: Peter Xu --- softmmu/vl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/softmmu/vl.c b/softmmu/vl.c index 32c0047889..8f864fee43 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1387,6 +1387,22 @@ void qemu_system_reset(ShutdownCause reason) =20 cpu_synchronize_all_states(); =20 + /* + * System reboot could reset memory layout. Although the final status= of + * the memory layout should be the same as before the reset, the memory + * sections can still be removed and added back frequently due to the = reset + * process. This could potentially drop dirty bits in track for those + * memory sections before the reset. + * + * Do a global dirty sync before the reset happens if we are during a + * precopy, so we don't lose the dirty bits during the memory shuffles. + */ + if (migration_is_precopy()) { + WITH_RCU_READ_LOCK_GUARD() { + migration_bitmap_sync_precopy(); + } + } + if (mc && mc->reset) { mc->reset(current_machine); } else { --=20 2.24.1 From nobody Sat May 18 21:45:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588103077; cv=none; d=zohomail.com; s=zohoarc; b=Xvszt5y6WktvZRVG3t2X1S7yIgdOxUakqd8ZCYPS95+RiapKJ6ioeQRkX9S80aSLuNn2QKByafUuBadJmzhRlD4E82GdFBL3NP2YCgwaiMwgjVMiRX+00ewUlzolDqtSVhCF686RfXySps+Xs7NuqSeIvGeV/oXP1d55tC1St2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588103077; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8Lnbg1QoqysmcI1QpHi4Ugfwik3iNp8wG0u4WHFvFYc=; b=EmucdJZ7s7jYTqU+G1kZgpzzTdi2zbZMvz9L80gw/VznckhPeZf8KZ1RperYCYGRW099BCG9Au/MZqceCBF8hHpZvle6XonEeEMbV8AcNuI9HutY7Q7MBCumRXFefM2ZA3zd85KORIxyIlu2UTek94nXAOseNxVHvA67Fu6O2hg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588103077015418.59051642261954; Tue, 28 Apr 2020 12:44:37 -0700 (PDT) Received: from localhost ([::1]:47682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTW9h-00083e-02 for importer@patchew.org; Tue, 28 Apr 2020 15:44:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33548) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTW8n-0006to-U2 for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:43:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTW8m-0007Do-H1 for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:43:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29549 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTW8m-0007BJ-36 for qemu-devel@nongnu.org; Tue, 28 Apr 2020 15:43:36 -0400 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-mBaXvpenPy-Dquclno1caQ-1; Tue, 28 Apr 2020 15:43:33 -0400 Received: by mail-qv1-f72.google.com with SMTP id 65so23744198qva.17 for ; Tue, 28 Apr 2020 12:43:33 -0700 (PDT) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id l24sm14239691qtp.8.2020.04.28.12.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 12:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588103015; 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=8Lnbg1QoqysmcI1QpHi4Ugfwik3iNp8wG0u4WHFvFYc=; b=NVX1LhUcqPOlq3T5g9w68K2eu8pav1V0jMy/ROS9aGHR7W2FhgYheG/N5Gp7HMLt2VyC72 5lloSIo+z2zV3D+BjaBLznxPecl2m+mKmDGc+V+8ksPDyNsTo85U0g8Rdy7RRC62UWMicv Bbbbjhooad62oleIvaGEdJlmbLiFLHs= X-MC-Unique: mBaXvpenPy-Dquclno1caQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IbXTrIQrGmJBwtzshAWiRUJozp+LdTeq7bHKm90eFnE=; b=NPF6RTAA+QQMOndGttS08SojAbC92WkwN1H5gtiB5eBa7AcI0j1WaLpz1NVdF+qoS6 sdbj33DJhWa15IFrdcrqT/WR3aIgSNrZ7HTmMBB4t01sbiwly6DwTdLhQ1jFX3hSkF4b qE7Now3j7eO1Pj+4WN+Ft4gzubM8jiB22kdPa5YDtVdNmMSQxu547TbaDTIyOxBqMdY3 eQopIrRe/dX8d1BBhCQFfXYNE/JVKf+ozKc8NcVkgIPKPPCjSsB90ZJu6zeOPoD8qQ3G r/M/jayqdcwNQ+TidzyfMENNHXf3UJIJeNxU7gZJ6X9gedX4ozauRHqTkhgfweDhyT1u ns9w== X-Gm-Message-State: AGi0Puabe6ezmjm4ayP7mfs5OD/7oJqqvW1ejMR5rSHCJ88T6ZaW34V7 rSxDQngjZfmb5Pr9kNhM3uq9wPuN7VavX83Gz8xhzHliAuFDhsYVAh4uE7cJLNvyYoLQ+3wEzZc gA63kGyHaTg9v6gM= X-Received: by 2002:ac8:f23:: with SMTP id e32mr30727050qtk.368.1588103012182; Tue, 28 Apr 2020 12:43:32 -0700 (PDT) X-Google-Smtp-Source: APiQypKJICGBvNYz1WYnmC8J1Reoa6vGgFHzA2cmnkiX4vno/3BqnrCHcZ2g9Iwr/u81OvrzkA63sQ== X-Received: by 2002:ac8:f23:: with SMTP id e32mr30726982qtk.368.1588103011459; Tue, 28 Apr 2020 12:43:31 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH RFC 4/4] kvm: No need to sync dirty bitmap before memslot removal any more Date: Tue, 28 Apr 2020 15:42:19 -0400 Message-Id: <20200428194219.10963-5-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200428194219.10963-1-peterx@redhat.com> References: <20200428194219.10963-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=peterx@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/28 04:15:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.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: Paolo Bonzini , Tian Kevin , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" With the system reset dirty sync in qemu_system_reset(), we should be able = to drop this operation now. After all it doesn't really fix the problem clean= ly because logically we could still have a race [1]. [1] https://lore.kernel.org/qemu-devel/20200327150425.GJ422390@xz-x1/ Signed-off-by: Peter Xu --- accel/kvm/kvm-all.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 439a4efe52..e1c87fa4e1 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1061,9 +1061,6 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, if (!mem) { goto out; } - if (mem->flags & KVM_MEM_LOG_DIRTY_PAGES) { - kvm_physical_sync_dirty_bitmap(kml, section); - } =20 /* unregister the slot */ g_free(mem->dirty_bmap); --=20 2.24.1