mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zdenek Kaspar <zkaspar82@gmail.com>
Subject: Re: [PATCH] KVM: x86: Zap the oldest MMU pages, not the newest
Date: Mon, 18 Jan 2021 18:34:10 +0100	[thread overview]
Message-ID: <0e8b9adb-1010-1b76-620b-4235eee405cf@redhat.com> (raw)
In-Reply-To: <20210113205030.3481307-1-seanjc@google.com>

On 13/01/21 21:50, Sean Christopherson wrote:
> Walk the list of MMU pages in reverse in kvm_mmu_zap_oldest_mmu_pages().
> The list is FIFO, meaning new pages are inserted at the head and thus
> the oldest pages are at the tail.  Using a "forward" iterator causes KVM
> to zap MMU pages that were just added, which obliterates guest
> performance once the max number of shadow MMU pages is reached.
> 
> Fixes: 6b82ef2c9cf1 ("KVM: x86/mmu: Batch zap MMU pages when recycling oldest pages")
> Reported-by: Zdenek Kaspar <zkaspar82@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>   arch/x86/kvm/mmu/mmu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 6d16481aa29d..ed861245ecf0 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -2417,7 +2417,7 @@ static unsigned long kvm_mmu_zap_oldest_mmu_pages(struct kvm *kvm,
>   		return 0;
>   
>   restart:
> -	list_for_each_entry_safe(sp, tmp, &kvm->arch.active_mmu_pages, link) {
> +	list_for_each_entry_safe_reverse(sp, tmp, &kvm->arch.active_mmu_pages, link) {
>   		/*
>   		 * Don't zap active root pages, the page itself can't be freed
>   		 * and zapping it will just force vCPUs to realloc and reload.
> 

Queued for 5.11, thanks.

Paolo


      reply	other threads:[~2021-01-18 17:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 20:50 Sean Christopherson
2021-01-18 17:34 ` Paolo Bonzini [this message]

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=0e8b9adb-1010-1b76-620b-4235eee405cf@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=zkaspar82@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®