From patchwork Wed Dec 12 04:16:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mackerras X-Patchwork-Id: 10725533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED19113BF for ; Wed, 12 Dec 2018 04:17:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4101FF40 for ; Wed, 12 Dec 2018 04:17:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFD8429FDE; Wed, 12 Dec 2018 04:17:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7081FF40 for ; Wed, 12 Dec 2018 04:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726436AbeLLERg (ORCPT ); Tue, 11 Dec 2018 23:17:36 -0500 Received: from ozlabs.org ([203.11.71.1]:57911 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726237AbeLLERg (ORCPT ); Tue, 11 Dec 2018 23:17:36 -0500 Received: by ozlabs.org (Postfix, from userid 1003) id 43F3SF5WfDz9sB7; Wed, 12 Dec 2018 15:17:33 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1544588253; bh=TxjSX4tNzq1R6wxAGg8hb1mHRaY8b1f0iL5gdoDOJA0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=agaEqEPnvYjTcH2FEzNJwDP26iPJqw1X9oOUOHB0GAOO2/VVpik9AJdpk0YkCS3MO BSa8D6QmK0Ey6aqvNqrKtYm+oeFAytGb+bIBfPBkhbfxx8kwfPqbXUROT1UdL3S71D e5dSu5JIr4SLTt5072o0RRgB5pUfZArjW5cdHYiUIijqLqGvvdw4+wkkKtmg8A+wCn F3GQPHGOdUSjC5/Xh9QcLOiZ0xFqEp208nprbfu79BhNvSXj2PWMRW/T8aTSQHSROd oBb57tAkz+chEh2DocmPCk7QhPu9RocVbTvbOGP3YfI1nToykWN+NxqSW5UfEAmyVk mFGYyoulTF6IQ== Date: Wed, 12 Dec 2018 15:16:17 +1100 From: Paul Mackerras To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: David Gibson Subject: [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging Message-ID: <20181212041617.GC22265@blackberry> References: <20181212041430.GA22265@blackberry> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181212041430.GA22265@blackberry> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For radix guests, this makes KVM map guest memory as individual pages when dirty page logging is enabled for the memslot corresponding to the guest real address. Having a separate partition-scoped PTE for each system page mapped to the guest means that we have a separate dirty bit for each page, thus making the reported dirty bitmap more accurate. Without this, if part of guest memory is backed by transparent huge pages, the dirty status is reported at a 2MB granularity rather than a 64kB (or 4kB) granularity for that part, causing userspace to have to transmit more data when migrating the guest. Signed-off-by: Paul Mackerras Reviewed-by: Suraj Jitindar Singh Reviewed-by: David Gibson --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index d68162e..87ad35e 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -683,6 +683,7 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu, pte_t pte, *ptep; unsigned int shift, level; int ret; + bool large_enable; /* used to check for invalidations in progress */ mmu_seq = kvm->mmu_notifier_seq; @@ -732,12 +733,15 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu, pte = *ptep; local_irq_enable(); + /* If we're logging dirty pages, always map single pages */ + large_enable = !(memslot->flags & KVM_MEM_LOG_DIRTY_PAGES); + /* Get pte level from shift/size */ - if (shift == PUD_SHIFT && + if (large_enable && shift == PUD_SHIFT && (gpa & (PUD_SIZE - PAGE_SIZE)) == (hva & (PUD_SIZE - PAGE_SIZE))) { level = 2; - } else if (shift == PMD_SHIFT && + } else if (large_enable && shift == PMD_SHIFT && (gpa & (PMD_SIZE - PAGE_SIZE)) == (hva & (PMD_SIZE - PAGE_SIZE))) { level = 1;