Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2917841imm; Mon, 13 Aug 2018 02:49:26 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyCmumMPJfTa1zU87hrAglKYPIeAoNtRr94LRnsCIskuoQ7vJAWSKvawo1kgftfZT7sXSwW X-Received: by 2002:a65:5a8a:: with SMTP id c10-v6mr15901552pgt.389.1534153766002; Mon, 13 Aug 2018 02:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534153765; cv=none; d=google.com; s=arc-20160816; b=AebBR8XdC7DkZs0OBIzsPiGA19+Lj0SgFcB/eNfFHb8XpTrM/K137mJPq1aV2DmANq 5wFlelL7CUCYUHsUc1rVXEEshfBRZwUb3AvUYYC5kAIPB9Lc4DZaOiyl+Dfx9xcZ6YT8 y7NRRD0b//Lvn1YpfEHHD/iotlgxEw5QQBBWeeOBELq/0gNa8FxJsh9e3y03c2cKBMKe w1YVpMe2hjdqHsTuHTZgb8c5tTW2YyCzT6x6E+yO390dFZHruL3Xr7gTiYeXV1TANS/2 +vLloVu4uvIlKQ3dxOViSrk3ehpn6udCGJAWicPYslMIrzY6qe45ODd/oecb0SU879TK L33g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=sNg2QcsnwIY+ihItaIu1kk58mYNevYf+tr9MPHoJUy4=; b=wQqPmJAcXsmsdTstJNfICtM3VvFQ8cVCtFwGgPjY9rmJ4pNb/57Rf8ptiyr5fiYNOp KLFsHKX1Ew23OdDQUI0BGN94AgpUVJt+PK+KGZMrK5Pg0DxRLyXHgu6IBZTyEJ13bll6 vYpUwlbFLotcx9bCoBF0xyHugflwlQtItf2dZUSBE+63lueVqaiVhcyWqAtBirifF1u0 ev4pzSaoHV/fF2XnMjxi93Lbye0DQ2ksvOy3pKp/2Adi5eIcW93hHho7g7j6oKH2TD9Z YW1XkWYHpeg1lcy1sC9ZGxg9npJdnJ10t2GyVhrABEPQvWQwdmOCP3Iy7XZSgl5/3/l+ ptjw== 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 u24-v6si16355682pgk.72.2018.08.13.02.49.11; Mon, 13 Aug 2018 02:49:25 -0700 (PDT) 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 S1729020AbeHMM2F (ORCPT + 99 others); Mon, 13 Aug 2018 08:28:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56168 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728310AbeHMM2E (ORCPT ); Mon, 13 Aug 2018 08:28:04 -0400 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 117777A9; Mon, 13 Aug 2018 02:46:35 -0700 (PDT) Received: from [10.37.9.188] (unknown [10.37.9.188]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D7503F73C; Mon, 13 Aug 2018 02:46:33 -0700 (PDT) Subject: Re: [PATCH v2 2/2] KVM: arm/arm64: Skip updating PTE entry if no change To: Punit Agrawal , kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, marc.zyngier@arm.com, christoffer.dall@arm.com, stable@vger.kernel.org References: <20180813094049.3726-1-punit.agrawal@arm.com> <20180813094049.3726-3-punit.agrawal@arm.com> From: Suzuki K Poulose Message-ID: <3ef331d7-d31a-a61b-7ad0-eb7c8bee10bd@arm.com> Date: Mon, 13 Aug 2018 10:47:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180813094049.3726-3-punit.agrawal@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/13/2018 10:40 AM, Punit Agrawal wrote: > When there is contention on faulting in a particular page table entry > at stage 2, the break-before-make requirement of the architecture can > lead to additional refaulting due to TLB invalidation. > > Avoid this by skipping a page table update if the new value of the PTE > matches the previous value. > > Fixes: d5d8184d35c9 ("KVM: ARM: Memory virtualization setup") > Change-Id: I28e17daf394a4821b13c2cf8726bf72bf30434f9 > Signed-off-by: Punit Agrawal > Cc: Marc Zyngier > Cc: Christoffer Dall > Cc: Suzuki Poulose > Cc: stable@vger.kernel.org > --- > virt/kvm/arm/mmu.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c > index 2ab977edc63c..d0a9dccc3793 100644 > --- a/virt/kvm/arm/mmu.c > +++ b/virt/kvm/arm/mmu.c > @@ -1120,6 +1120,10 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, > /* Create 2nd stage page table mapping - Level 3 */ > old_pte = *pte; > if (pte_present(old_pte)) { > + /* Skip page table update if there is no change */ > + if (pte_val(old_pte) == pte_val(*new_pte)) > + goto out; > + > kvm_set_pte(pte, __pte(0)); > kvm_tlb_flush_vmid_ipa(kvm, addr); > } else { > @@ -1127,6 +1131,7 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, > } > > kvm_set_pte(pte, *new_pte); > +out: Similar comments as the previous patch, either way: Reviewed-by: Suzuki K Poulose