Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2310099ybt; Tue, 16 Jun 2020 02:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzckVO0MwnJ+lwdPUUVfIr3TSMv/MIkbxWCDJrH3xZS06rBajciuWvyXvV0fARrQzdj7f2s X-Received: by 2002:a17:906:7693:: with SMTP id o19mr1808087ejm.295.1592300449586; Tue, 16 Jun 2020 02:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592300449; cv=none; d=google.com; s=arc-20160816; b=XE2RfNKg6UPz1fQXkQQXdg2/Jkxi7O3HC9OQVPXcA947va7CmnAQdA7svI/FO8p8ag jxOm0XSGgm50bFCxuCMNUkiHJ4UUOOHVvPqrycPLTOd58DVqK5EuyhL2IaKnGSESPg8R rLL91FNRCNLbqub2v8VRwM+JrNSdIIOnhltxIS5YIYgUARnrXrceuClckrzAhO+CZsq9 NMUT+znZBMBt+hJpMtut7IMgeoRUwwUdkVpnMhx4WFpIudCaskNe9LJfivZ5CoTsyrx7 H8/YcEm8uXtvYrlu5nby2mtQ7cZ4sc+UzfwFJNc+9bcPH7SD9PZ0lkMrfK/Hc14dkk61 rZJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Sctk5R5pLSdbKPKiPZDxAUWzAlO/S8FMvByytihF2Is=; b=gZQ0Hvi1d8/nesPGTQkg3R/2Hiewgr/6Jl/47r17Y2bXzS11p8qrtqrjx344d5IFvi rkKKvoS6aKV7tdUAoPVBikcwWL1xEPvWoK3HfjyK8l9ybyzqOCeqvfTzzZQRI4W0CwPw uvi7AeacQULT5qZaQ1LAkJ9oDRgzecRtb5g8dKDYDx/cb3+RS/Lwgkbk+aKwgFdzude9 YqYeSJBe1p37dSKBDtmxlstfgksCAopr312T1qQ+rXf6+B0fk9kl8QSUO6xdyVYx44Bn gxZ3Q5+wtYVH5nQ64TFBXMSvQTuzKZYr/THlomwoEd+SCv/dRwGWhvWnlUoMTUcFX7K1 JG4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si10760333ejd.353.2020.06.16.02.40.27; Tue, 16 Jun 2020 02:40:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728584AbgFPJhD (ORCPT + 99 others); Tue, 16 Jun 2020 05:37:03 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6266 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728335AbgFPJgV (ORCPT ); Tue, 16 Jun 2020 05:36:21 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DC5347673396AED17823; Tue, 16 Jun 2020 17:36:18 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.173.221.230) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 16 Jun 2020 17:36:10 +0800 From: Keqian Zhu To: , , , CC: Catalin Marinas , Marc Zyngier , James Morse , Will Deacon , "Suzuki K Poulose" , Sean Christopherson , Julien Thierry , Mark Brown , "Thomas Gleixner" , Andrew Morton , Alexios Zavras , , , , Keqian Zhu Subject: [PATCH 08/12] KVM: Omit dirty log sync in log clear if initially all set Date: Tue, 16 Jun 2020 17:35:49 +0800 Message-ID: <20200616093553.27512-9-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20200616093553.27512-1-zhukeqian1@huawei.com> References: <20200616093553.27512-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.221.230] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Synchronizing dirty log during log clear is useful only when the dirty bitmap of userspace contains dirty bits that memslot dirty bitmap does not contain, because we can sync new dirty bits to memslot dirty bitmap, then we can clear them by the way and avoid reporting them to userspace later. With dirty bitmap "initially all set" feature, the above situation will not appear if userspace logic is normal, so we can omit dirty log sync in log clear. This is valuable when dirty log sync is a high-cost operation, such as arm64 DBM. Signed-off-by: Keqian Zhu --- virt/kvm/kvm_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 3722343fd460..6c147d6f9da6 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1554,7 +1554,8 @@ static int kvm_clear_dirty_log_protect(struct kvm *kvm, (log->num_pages < memslot->npages - log->first_page && (log->num_pages & 63))) return -EINVAL; - kvm_arch_sync_dirty_log(kvm, memslot); + if (!kvm_dirty_log_manual_protect_and_init_set(kvm)) + kvm_arch_sync_dirty_log(kvm, memslot); flush = false; dirty_bitmap_buffer = kvm_second_dirty_bitmap(memslot); -- 2.19.1