Re: [PATCH] LoongArch: KVM: always make pte yong in page map's fast path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Qingtong,

On 2024/6/13 上午8:32, jiaqingtong97@xxxxxxxxx wrote:
From: Jia Qingtong <jiaqingtong97@xxxxxxxxx>

It seems redundant to check if pte is yong before the call to
kvm_pte_mkyoung in kvm_map_page_fast.
Just remove the check.

Signed-off-by: Jia Qingtong <jiaqingtong97@xxxxxxxxx>
---
  arch/loongarch/kvm/mmu.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c
index 98883aa23ab8..a46befcf85dc 100644
--- a/arch/loongarch/kvm/mmu.c
+++ b/arch/loongarch/kvm/mmu.c
@@ -551,10 +551,8 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
  	}
/* Track access to pages marked old */
-	new = *ptep;
-	if (!kvm_pte_young(new))
-		new = kvm_pte_mkyoung(new);
-		/* call kvm_set_pfn_accessed() after unlock */
+	new = kvm_pte_mkyoung(*ptep);
+	/* call kvm_set_pfn_accessed() after unlock */
Thanks for noticing this.

The logic is right, however it does not improve performance to update pte entry unconditionally since pte entry is frequently accessed by HW and multpile CPUs. There may be cache thrashing issue, just maybe from my own point -:)

It is the same such as test_and_set_bit implementation on x86 or other architectures, it is not unconditionally logic or on x86.

Regards
Bibo Mao
if (write && !kvm_pte_dirty(new)) {
  		if (!kvm_pte_write(new)) {

base-commit: eb36e520f4f1b690fd776f15cbac452f82ff7bfa






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux