From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A470C433E0 for ; Mon, 8 Mar 2021 16:36:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A15866522B for ; Mon, 8 Mar 2021 16:36:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A15866522B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZymD2Qe0O9EpCcoySf+vr2S2AQgOLAooVUXaQHmPRJE=; b=W5ONK1C8xPfb2xtKXVFE/SsXA er4tduVfmXxWyso8Yo03D2f+fe/fYtZExo8kPphVA+knEutZSoJzr3kM9muRQTW9yU34ia5qVH2UL Wl02QI+Od5o+Ne4z6W9mqKFQNu9ZDVSx4zWVb4cjmTl16UiNZfOiRG5Ic4GaKc3B+uUKJMPgA0xeh qtS3Pm0/NQx6Co/neqkQbn+lnp+I2ftAkw/hG0AbzY9s4zKBiC7ucy6/Fb+GMVziw73/gGdvRKv7g nX4JiaTmJko85cGrkLqJWAC1SLaIK8jQ2XCYegh72FDALE8TC44DUGYqFIi+THLw3I0WQmasvYPqm fo1XaiJoA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJIqd-0014aN-RH; Mon, 08 Mar 2021 16:35:12 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJIqT-0014Xi-Qy for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 16:35:04 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C22365227; Mon, 8 Mar 2021 16:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615221300; bh=/a8q5f9+mgUFjkaLUOWpenLQISW7GAOWifO2INunHhc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=t5mel8PvzyIhShxoDA+EYt9ooh6ur1wDK1mo2e24m54Zx3cROiOtV0NEhX4/3rRSl /TlHqZIXfRKvEQOHpJErHsLES1zBkjwEoExPy6eht2zFRgBtMpqY5ls2zXbjfMo3Pn C1J3+tV/nHLvKuNv/hMb/40sr4OIwG0Fg7LZfzb5tYfh6bpBtEUMzd9M/XftoY2IeF We5ZbQAUx2VgWHkI4eEwybZK2xxJT+l5Sx7kWe/31C2e2rnE/pjyq0ED4mWGN4oG9d bfqXkhSEHSlb5p42qw8nyzwEf1xamImHeIz7i9CtXfsH5iv6hd5MXuAR14aqd1Wx3E E8wW/7oQAOKsg== Date: Mon, 8 Mar 2021 16:34:55 +0000 From: Will Deacon To: Yanan Wang Cc: Marc Zyngier , Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, yuzenghui@huawei.com Subject: Re: [PATCH 2/2] KVM: arm64: Skip the cache flush when coalescing tables into a block Message-ID: <20210308163454.GA26561@willie-the-truck> References: <20210125141044.380156-1-wangyanan55@huawei.com> <20210125141044.380156-3-wangyanan55@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210125141044.380156-3-wangyanan55@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_163502_532257_B6A7CEDF X-CRM114-Status: GOOD ( 22.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 25, 2021 at 10:10:44PM +0800, Yanan Wang wrote: > After dirty-logging is stopped for a VM configured with huge mappings, > KVM will recover the table mappings back to block mappings. As we only > replace the existing page tables with a block entry and the cacheability > has not been changed, the cache maintenance opreations can be skipped. > > Signed-off-by: Yanan Wang > --- > arch/arm64/kvm/mmu.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 8e8549ea1d70..37b427dcbc4f 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -744,7 +744,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > { > int ret = 0; > bool write_fault, writable, force_pte = false; > - bool exec_fault; > + bool exec_fault, adjust_hugepage; > bool device = false; > unsigned long mmu_seq; > struct kvm *kvm = vcpu->kvm; > @@ -872,12 +872,18 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > mark_page_dirty(kvm, gfn); > } > > - if (fault_status != FSC_PERM && !device) > + /* > + * There is no necessity to perform cache maintenance operations if we > + * will only replace the existing table mappings with a block mapping. > + */ > + adjust_hugepage = fault_granule < vma_pagesize ? true : false; nit: you don't need the '? true : false' part That said, your previous patch checks for 'fault_granule > vma_pagesize', so I'm not sure the local variable helps all that much here because it obscures the size checks in my opinion. It would be more straight-forward if we could structure the logic as: if (fault_granule < vma_pagesize) { } else if (fault_granule > vma_page_size) { } else { } With some comments describing what we can infer about the memcache and cache maintenance requirements for each case. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel