Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp240939ybb; Tue, 24 Mar 2020 21:28:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvEj12eng89QU1jEZKFrdlpVu60r9cZLXRigbKDCaOOAf7bOOGoujnnw2npXfRUTYgp+Xpf X-Received: by 2002:a9d:6ad9:: with SMTP id m25mr1150931otq.160.1585110496647; Tue, 24 Mar 2020 21:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585110496; cv=none; d=google.com; s=arc-20160816; b=PvyFGjfl+J5kxyp8/l+YlZ8ezAnNBIZt9nvNEuJmut8xaG2fqU7gHQuRLZNIt5dpRu BJXsNcm5Z3aiUTTu2Xul18W1TClmr5qE8hz/9XBE2FuWUVXHLlRrGaECz/bC/dzIdPsE xdovQgwlmvkxZOgxZb1nzmtYE28S9W9LBhofJEGTJfqSr5oC8bWNYqlW7p5q9aYG4BA3 tEcAFHZcCzHcdTR6Xd4+NqQWmKaIQ83pMeCeHHyJgxvmekzTeRQtf4u1moumV0xpquuZ tT5GMcfcc1aAeMyDNBivTgDEOLPE2xrxlqcEnpjW9ZEmTx2UxAQsruDgkEYl24/LElZw b4Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fKIn2lOzxdyNVagO1F8Ma1BXOQAJ5Wwkp9EA20Zhz0s=; b=TRehg7B/TUdit6gc7HoMXlKsUneIv4M/aFmIx2sWOuH6TFPm37Sa6FyogaF5ygXPwV Uclqs5xnoR31FRfc6gPMm3zGhH1xeVe+/uRTRZVZte7xvmYO5ZlYUJ98BSC0mctDVLvi xKZJcCOOweCA8ro7aYF562bXtTumto+wdVnjmt8bTxnUH8Na3lbK3e9VjPa4J0ddjC+J LAjLNk0y0Pp/VODd6bMiwYpf5Jh2nLI+JlLWKKLCyDrEDQ4F3LAZtXtUInVwzseYNgEe 3rwXjqYBMXaLvldIYtflOgx9TiRIM62ducimhslx2SmXjGP7rUJ5BFHbTfsu3PWZBDc+ ykjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n82si6424557oih.195.2020.03.24.21.28.05; Tue, 24 Mar 2020 21:28:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbgCYE0t (ORCPT + 99 others); Wed, 25 Mar 2020 00:26:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39234 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726206AbgCYE0t (ORCPT ); Wed, 25 Mar 2020 00:26:49 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 15AD56D2D2F65F81D46A; Wed, 25 Mar 2020 12:26:44 +0800 (CST) Received: from linux-kDCJWP.huawei.com (10.175.104.212) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Wed, 25 Mar 2020 12:26:33 +0800 From: Keqian Zhu To: , , , CC: Marc Zyngier , Paolo Bonzini , "James Morse" , Julien Thierry , Will Deacon , Suzuki K Poulose , Sean Christopherson , Jay Zhou , , Keqian Zhu Subject: [PATCH 1/3] KVM/memslot: Move the initial set of dirty bitmap to arch Date: Wed, 25 Mar 2020 12:24:21 +0800 Message-ID: <20200325042423.12181-2-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200325042423.12181-1-zhukeqian1@huawei.com> References: <20200325042423.12181-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.212] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, when KVM_DIRTY_LOG_INITIALLY_SET is enabled, the initial set of memslot dirty bitmap is located at arch shared path. By making this implementation be architecture depended, we can realize some architecture depended optimizations (e.g. Only mark dirty for these pages with valid translation entries, then userspace can use this information to only send these pages during migration). Signed-off-by: Keqian Zhu --- arch/x86/kvm/x86.c | 3 +++ virt/kvm/kvm_main.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e54c6ad628a8..ccab8b56bc7c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10031,6 +10031,9 @@ static void kvm_mmu_slot_apply_flags(struct kvm *kvm, * See the comments in fast_page_fault(). */ if (new->flags & KVM_MEM_LOG_DIRTY_PAGES) { + if (kvm_dirty_log_manual_protect_and_init_set(kvm)) + bitmap_set(new->dirty_bitmap, 0, new->npages); + if (kvm_x86_ops->slot_enable_log_dirty) { kvm_x86_ops->slot_enable_log_dirty(kvm, new); } else { diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 28eae681859f..531d96c6871e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1289,9 +1289,6 @@ int __kvm_set_memory_region(struct kvm *kvm, r = kvm_alloc_dirty_bitmap(&new); if (r) return r; - - if (kvm_dirty_log_manual_protect_and_init_set(kvm)) - bitmap_set(new.dirty_bitmap, 0, new.npages); } r = kvm_set_memslot(kvm, mem, &old, &new, as_id, change); -- 2.19.1