Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1494018ybt; Thu, 2 Jul 2020 06:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytWvpcP5T+uEL3FOFazWNHkuV4kdU0zFsFpAWl2JlrzT6wMJDKtR4HSjbHrUTsp86R5fp6 X-Received: by 2002:a17:906:c1d8:: with SMTP id bw24mr18171628ejb.91.1593698230644; Thu, 02 Jul 2020 06:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593698230; cv=none; d=google.com; s=arc-20160816; b=VBJ9tIQiMlj7BElFhCe3FcfYMkqttbUCU9KjoB7QS/wd5I3fYFk6x1Nf7BUcR3T9O9 dK+I5rkrMajViXgRXHC8Q8kINf19mOTPmIOgqY4PWHTEpYdxPJf7X0SJNTjipPy8vmAZ Y+4DdGREPk3v4Gf6USEh/7XamQa8RXjNn4DmuVFS2Lkscl3MqTprCSVaoOIv32oHA01w E/awzZKs9cqOtj5Zy6MT8Tf8pIomHEsNgINWf4ZnOyC729JyA+IQsYfo3jW+6amCgDqf MAJmYN0L7MArNjGqd0p3iwxNoI87NWYkuT7No+MSXDo6xGyb2uZGV2kJ/Je5Cact62L/ jGPA== 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=OHI6mXOOrNEie1BDU3wHJCBM+O/NB4+Uyh0G3yZwn4s=; b=Z1BfzJau5agwnYKJbPqfufzIBREuqf3bjAzBWSw/CsU67Oqi86elktmC48iFSN54p4 O4PiHAwcb05SgcIUkiO/2OqDmdQqwS4Uc/eT2kNDlDrdesPirbQeM1N/PaIjnOaH75zk Yd8WSVMKroddN7+ng/nib5K/6AQDZt1ghiHkXDcHd7g8dYc82lG3DnrJHJIZ0D/qTT68 6S5fGqTIZb0AVF6lc8K7ivyoxQmaRxkLuY7C+I2PNyG5d0Dbtxfa7OGETceCr7AHnDm6 ucr9aVrW4aiPE2pYnWPZzVysQwlfHM2lKD7HVPPXLCEM2q69K+JCqP6EmvRNaNeDV8Cs dRbQ== 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 be11si3680332edb.482.2020.07.02.06.56.48; Thu, 02 Jul 2020 06:57:10 -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 S1729478AbgGBN4e (ORCPT + 99 others); Thu, 2 Jul 2020 09:56:34 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:43088 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729472AbgGBN4W (ORCPT ); Thu, 2 Jul 2020 09:56:22 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A246244A5C93F08B323C; Thu, 2 Jul 2020 21:56:15 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.22) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 2 Jul 2020 21:56:09 +0800 From: Keqian Zhu To: , , , CC: Catalin Marinas , Marc Zyngier , James Morse , Will Deacon , "Suzuki K Poulose" , Steven Price , "Sean Christopherson" , Julien Thierry , Mark Brown , "Thomas Gleixner" , Andrew Morton , Alexios Zavras , , , , Keqian Zhu Subject: [PATCH v2 8/8] KVM: Omit dirty log sync in log clear if initially all set Date: Thu, 2 Jul 2020 21:55:56 +0800 Message-ID: <20200702135556.36896-9-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20200702135556.36896-1-zhukeqian1@huawei.com> References: <20200702135556.36896-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.22] 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 a852af5c3214..3f9e51d52b7a 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