linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] KVM: x86/mmu: Speed up slot_rmap_walk_next for sparsely populated rmaps
@ 2022-05-02 22:03 Vipin Sharma
  2022-05-03  9:32 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Vipin Sharma @ 2022-05-02 22:03 UTC (permalink / raw)
  To: pbonzini
  Cc: seanjc, vkuznets, wanpengli, jmattson, joro, dmatlack, kvm,
	linux-kernel, Vipin Sharma

Avoid calling handlers on empty rmap entries and skip to the next non
empty rmap entry.

Empty rmap entries are noop in handlers.

Signed-off-by: Vipin Sharma <vipinsh@google.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
---

v2:
- Removed noinline from slot_rmap_walk_next signature

v1:
- https://lore.kernel.org/lkml/20220325233125.413634-1-vipinsh@google.com

 arch/x86/kvm/mmu/mmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 77785587332e..4e8d546431eb 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1501,9 +1501,11 @@ static bool slot_rmap_walk_okay(struct slot_rmap_walk_iterator *iterator)
 
 static void slot_rmap_walk_next(struct slot_rmap_walk_iterator *iterator)
 {
-	if (++iterator->rmap <= iterator->end_rmap) {
+	while (++iterator->rmap <= iterator->end_rmap) {
 		iterator->gfn += (1UL << KVM_HPAGE_GFN_SHIFT(iterator->level));
-		return;
+
+		if (iterator->rmap->val)
+			return;
 	}
 
 	if (++iterator->level > iterator->end_level) {

base-commit: 71d7c575a673d42ad7175ad5fc27c85c80330311
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] KVM: x86/mmu: Speed up slot_rmap_walk_next for sparsely populated rmaps
  2022-05-02 22:03 [PATCH v2] KVM: x86/mmu: Speed up slot_rmap_walk_next for sparsely populated rmaps Vipin Sharma
@ 2022-05-03  9:32 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2022-05-03  9:32 UTC (permalink / raw)
  To: Vipin Sharma
  Cc: seanjc, vkuznets, wanpengli, jmattson, joro, dmatlack, kvm, linux-kernel

On 5/3/22 00:03, Vipin Sharma wrote:
> Avoid calling handlers on empty rmap entries and skip to the next non
> empty rmap entry.
> 
> Empty rmap entries are noop in handlers.
> 
> Signed-off-by: Vipin Sharma <vipinsh@google.com>
> Suggested-by: Sean Christopherson <seanjc@google.com>
> ---
> 
> v2:
> - Removed noinline from slot_rmap_walk_next signature
> 
> v1:
> - https://lore.kernel.org/lkml/20220325233125.413634-1-vipinsh@google.com
> 
>   arch/x86/kvm/mmu/mmu.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 77785587332e..4e8d546431eb 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -1501,9 +1501,11 @@ static bool slot_rmap_walk_okay(struct slot_rmap_walk_iterator *iterator)
>   
>   static void slot_rmap_walk_next(struct slot_rmap_walk_iterator *iterator)
>   {
> -	if (++iterator->rmap <= iterator->end_rmap) {
> +	while (++iterator->rmap <= iterator->end_rmap) {
>   		iterator->gfn += (1UL << KVM_HPAGE_GFN_SHIFT(iterator->level));
> -		return;
> +
> +		if (iterator->rmap->val)
> +			return;
>   	}
>   
>   	if (++iterator->level > iterator->end_level) {
> 
> base-commit: 71d7c575a673d42ad7175ad5fc27c85c80330311

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-03  9:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 22:03 [PATCH v2] KVM: x86/mmu: Speed up slot_rmap_walk_next for sparsely populated rmaps Vipin Sharma
2022-05-03  9:32 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).