All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Maxim Levitsky <mlevitsk@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: kvm_gfn_to_pfn_cache_refresh started getting a warning recently
Date: Wed, 27 Apr 2022 14:22:10 +0200	[thread overview]
Message-ID: <229c4cb9-c8f4-6392-dfb5-c9afedc3262b@redhat.com> (raw)
In-Reply-To: <Ymg2pN9V4uwkmLZ/@google.com>

On 4/26/22 20:15, Sean Christopherson wrote:
> On Tue, Apr 26, 2022, Sean Christopherson wrote:
>> On Tue, Apr 26, 2022, Paolo Bonzini wrote:
>>> On 4/26/22 18:45, Sean Christopherson wrote:
>>>> On Tue, Apr 26, 2022, Maxim Levitsky wrote:
>>>>> [  390.511995] BUG: sleeping function called from invalid context at include/linux/highmem-internal.h:161
>>>>> [  390.513681] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 4439, name: CPU 0/KVM
>>>>
>>>> This is my fault.  memremap() can sleep as well.  I'll work on a fix.
>>>
>>> Indeed, "KVM: Fix race between mmu_notifier invalidation and pfncache
>>> refresh" hadn't gone through a full test cycle yet.
>>
>> And I didn't run with PROVE_LOCKING :-(
>>
>> I'm pretty sure there's an existing memory leak too.  If a refresh occurs, but
>> the pfn ends up being the same, KVM will keep references to both the "old" and the
>> "new", but only release one when the cache is destroyed.
>>
>> The refcounting bug begs the question of why KVM even keeps a reference.  This code
>> really should look exactly like the page fault path, i.e. should drop the reference
>> to the pfn once the pfn has been installed into the cache and obtained protection
>> via the mmu_notifier.
> 
> This is getting a bit gnarly.  It probably makes sense to drop the existing patches
> from kvm/queue, and then I can send a full v2 instead of just the delta?

Yes, that's a good idea.

Paolo


      reply	other threads:[~2022-04-27 12:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 15:33 kvm_gfn_to_pfn_cache_refresh started getting a warning recently Maxim Levitsky
2022-04-26 16:45 ` Sean Christopherson
2022-04-26 16:56   ` Maxim Levitsky
2022-04-26 17:11   ` Paolo Bonzini
2022-04-26 17:34     ` Sean Christopherson
2022-04-26 18:15       ` Sean Christopherson
2022-04-27 12:22         ` 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=229c4cb9-c8f4-6392-dfb5-c9afedc3262b@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=seanjc@google.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.