From: "yezhenyu (A)" <yezhenyu2@huawei.com>
To: "rananta@google.com" <rananta@google.com>,
"will@kernel.org" <will@kernel.org>,
"maz@kernel.org" <maz@kernel.org>,
"oliver.upton@linux.dev" <oliver.upton@linux.dev>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"dmatlack@google.com" <dmatlack@google.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
zhengchuan <zhengchuan@huawei.com>,
Xiexiangyou <xiexiangyou@huawei.com>,
"guoqixin (A)" <guoqixin2@huawei.com>,
"Mawen (Wayne)" <wayne.ma@huawei.com>
Subject: [RFC][PATCH] arm64: tlb: call kvm_call_hyp once during kvm_tlb_flush_vmid_range
Date: Mon, 9 Feb 2026 13:14:07 +0000 [thread overview]
Message-ID: <42bcdd9100bf4c63b79d2b72bd6db951@huawei.com> (raw)
From 9982be89f55bd99b3683337223284f0011ed248e Mon Sep 17 00:00:00 2001
From: eillon <yezhenyu2@huawei.com>
Date: Mon, 9 Feb 2026 19:48:46 +0800
Subject: [RFC][PATCH v1] arm64: tlb: call kvm_call_hyp once during
kvm_tlb_flush_vmid_range
The kvm_tlb_flush_vmid_range() function is performance-critical
during live migration, but there is a while loop when the system
support flush tlb by range when the size is larger than MAX_TLBI_RANGE_PAGES.
This results in frequent entry to kvm_call_hyp() and then a large
amount of time is spent in kvm_clear_dirty_log_protect() during
migration(more than 50%). So, when the address range is large than
MAX_TLBI_RANGE_PAGES, directly call __kvm_tlb_flush_vmid to
optimize performance.
---
arch/arm64/kvm/hyp/pgtable.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 874244df7..9da22b882 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -675,21 +675,19 @@ static bool stage2_has_fwb(struct kvm_pgtable *pgt)
void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu,
phys_addr_t addr, size_t size)
{
- unsigned long pages, inval_pages;
+ unsigned long pages = size >> PAGE_SHIFT;
- if (!system_supports_tlb_range()) {
+ /*
+ * This function is performance-critical during live migration;
+ * thus, when the address range is large than MAX_TLBI_RANGE_PAGES,
+ * directly call __kvm_tlb_flush_vmid to optimize performance.
+ */
+ if (!system_supports_tlb_range() || pages > MAX_TLBI_RANGE_PAGES) {
kvm_call_hyp(__kvm_tlb_flush_vmid, mmu);
return;
}
- pages = size >> PAGE_SHIFT;
- while (pages > 0) {
- inval_pages = min(pages, MAX_TLBI_RANGE_PAGES);
- kvm_call_hyp(__kvm_tlb_flush_vmid_range, mmu, addr, inval_pages);
-
- addr += inval_pages << PAGE_SHIFT;
- pages -= inval_pages;
- }
+ kvm_call_hyp(__kvm_tlb_flush_vmid_range, mmu, addr, pages);
}
#define KVM_S2_MEMATTR(pgt, attr) PAGE_S2_MEMATTR(attr, stage2_has_fwb(pgt))
--
2.43.0
next reply other threads:[~2026-02-09 13:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 13:14 yezhenyu (A) [this message]
2026-02-09 14:35 ` [RFC][PATCH] arm64: tlb: call kvm_call_hyp once during kvm_tlb_flush_vmid_range Marc Zyngier
2026-02-12 12:02 ` yezhenyu (A)
2026-02-16 13:05 ` Marc Zyngier
-- strict thread matches above, loose matches on Subject: below --
2026-02-12 11:54 yezhenyu (A)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42bcdd9100bf4c63b79d2b72bd6db951@huawei.com \
--to=yezhenyu2@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=dmatlack@google.com \
--cc=guoqixin2@huawei.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=rananta@google.com \
--cc=wayne.ma@huawei.com \
--cc=will@kernel.org \
--cc=xiexiangyou@huawei.com \
--cc=zhengchuan@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.