Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2646278imb; Mon, 4 Mar 2019 10:17:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzKI4McV1y4CnYKxLINPlpYQ/6lu7x36XbhF/GdzvegpNG1nh/TthNH0apHHtC4JqhyxXgy X-Received: by 2002:a17:902:e85:: with SMTP id 5mr21795326plx.13.1551723421204; Mon, 04 Mar 2019 10:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551723421; cv=none; d=google.com; s=arc-20160816; b=bwxO4QtNqaKG+dLUgwSTxL/XFpdepB9g8C7QZoej5z14KQFVXHhyCW10kP9Y7oaDR1 UEUnY+UB4JUxAyc59zciCgEz63d8XPNdu8I0p75/ZQ8AXKUGdaCIe7/ipdHwSXCRqYif vB7UzIo3Zlmcs5aJ8t1TycurqP6r2siWt7p1+dN6lRT3HIMidnWojpJ0h4oMv46rUICq zPnagZz6ghRerLAcNCVUrK/so9RgdD8L3XQQZwOczzCJWfczpNxRqQClYpfcR1i3Jm21 rFg9XgJ8jluhcCTuT/aeod2+shzjPcxNNsA0dkBA35ayK3TnBZuEys2DYt4flbhfhh55 6QGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=as8vFNb0SXimid97FEppXy3srmyf242Ykb+aInVpgdY=; b=0kPVsMnrONrRqgSghoZuGOUzJcWeJ3LcQCSVFHiGP7saKfDkl5esAu3iqJh9AHieE6 Hvy72ufdFRCcmCjzNE7iBHn07uQYw4bP9OACeWvi5E3yaMNmUZHrgI4J4lq6ji2LsFxA FQXM1W0hAwd6K/6lOJ1W0sm/9n/7GjYDNPnDqKr+IpXsgeZNGfstIiBS3PYk78wIUqeC 4H7tddbaNtVDXAFWm6ym/c+gyzK/Fd3DooxE70PhwNylSu3WMpwSErshLjJaz/udshh9 kU5B8feZTgeAMGYUD/++AliikuqtLUynzpbjaLDQpV+g1RXBIwfmXJuW+EKrYazTyoB7 PzFg== 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 n81si5902194pfh.272.2019.03.04.10.16.45; Mon, 04 Mar 2019 10:17:01 -0800 (PST) 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 S1726707AbfCDRNa (ORCPT + 99 others); Mon, 4 Mar 2019 12:13:30 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36242 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbfCDRNa (ORCPT ); Mon, 4 Mar 2019 12:13:30 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8718CA78; Mon, 4 Mar 2019 09:13:29 -0800 (PST) Received: from en101 (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 962F73F703; Mon, 4 Mar 2019 09:13:27 -0800 (PST) Date: Mon, 4 Mar 2019 17:13:21 +0000 From: Suzuki K Poulose To: Zenghui Yu Cc: christoffer.dall@arm.com, marc.zyngier@arm.com, Punit Agrawal , julien.thierry@arm.com, LKML , james.morse@arm.com, Zenghui Yu , wanghaibin.wang@huawei.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [RFC PATCH] KVM: arm64: Force a PTE mapping when logging is enabled Message-ID: <20190304171320.GA3984@en101> References: <1551497728-12576-1-git-send-email-yuzenghui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Zenghui, On Sun, Mar 03, 2019 at 11:14:38PM +0800, Zenghui Yu wrote: > I think there're still some problems in this patch... Details below. > > On Sat, Mar 2, 2019 at 11:39 AM Zenghui Yu wrote: > > > > The idea behind this is: we don't want to keep tracking of huge pages when > > logging_active is true, which will result in performance degradation. We > > still need to set vma_pagesize to PAGE_SIZE, so that we can make use of it > > to force a PTE mapping. Yes, you're right. We are indeed ignoring the force_pte flag. > > > > Cc: Suzuki K Poulose > > Cc: Punit Agrawal > > Signed-off-by: Zenghui Yu > > > > --- > > Atfer looking into https://patchwork.codeaurora.org/patch/647985/ , the > > "vma_pagesize = PAGE_SIZE" logic was not intended to be deleted. As far > > as I can tell, we used to have "hugetlb" to force the PTE mapping, but > > we have "vma_pagesize" currently instead. We should set it properly for > > performance reasons (e.g, in VM migration). Did I miss something important? > > > > --- > > virt/kvm/arm/mmu.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c > > index 30251e2..7d41b16 100644 > > --- a/virt/kvm/arm/mmu.c > > +++ b/virt/kvm/arm/mmu.c > > @@ -1705,6 +1705,13 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > > (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm))) && > > !force_pte) { > > gfn = (fault_ipa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT; > > + } else { > > + /* > > + * Fallback to PTE if it's not one of the stage2 > > + * supported hugepage sizes or the corresponding level > > + * doesn't exist, or logging is enabled. > > First, Instead of "logging is enabled", it should be "force_pte is true", > since "force_pte" will be true when: > > 1) fault_supports_stage2_pmd_mappings() return false; or > 2) "logging is enabled" (e.g, in VM migration). > > Second, fallback some unsupported hugepage sizes (e.g, 64K hugepage with > 4K pages) to PTE is somewhat strange. And it will then _unexpectedly_ > reach transparent_hugepage_adjust(), though no real adjustment will happen > since commit fd2ef358282c ("KVM: arm/arm64: Ensure only THP is candidate > for adjustment"). Keeping "vma_pagesize" there as it is will be better, > right? > > So I'd just simplify the logic like: We could fix this right in the beginning. See patch below: > > } else if (force_pte) { > vma_pagesize = PAGE_SIZE; > } > > > Will send a V2 later and waiting for your comments :) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 30251e2..529331e 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1693,7 +1693,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, return -EFAULT; } - vma_pagesize = vma_kernel_pagesize(vma); + /* If we are forced to map at page granularity, force the pagesize here */ + vma_pagesize = force_pte ? PAGE_SIZE : vma_kernel_pagesize(vma); + /* * The stage2 has a minimum of 2 level table (For arm64 see * kvm_arm_setup_stage2()). Hence, we are guaranteed that we can @@ -1701,11 +1703,10 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, * As for PUD huge maps, we must make sure that we have at least * 3 levels, i.e, PMD is not folded. */ - if ((vma_pagesize == PMD_SIZE || - (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm))) && - !force_pte) { + if (vma_pagesize == PMD_SIZE || + (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm))) gfn = (fault_ipa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT; - } + up_read(¤t->mm->mmap_sem); /* We need minimum second+third level pages */ --- Suzuki