Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Sean Christopherson <seanjc@google.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	kernel-team@fb.com
Subject: Re: [PATCH] KVM: use set_page_dirty rather than SetPageDirty
Date: Wed, 26 Jan 2022 15:11:03 -0800	[thread overview]
Message-ID: <YfHVB5RmLZn2ku5M@zen> (raw)
In-Reply-To: <YfHEJpP+1c9QZxA0@google.com>

On Wed, Jan 26, 2022 at 09:59:02PM +0000, Sean Christopherson wrote:
> On Wed, Jan 26, 2022, Boris Burkov wrote:
> > I tested this fix on the workload and it did prevent the hangs. However,
> > I am unsure if the fix is appropriate from a locking perspective, so I
> > hope to draw some extra attention to that aspect. set_page_dirty_lock in
> > mm/page-writeback.c has a comment about locking that says set_page_dirty
> > should be called with the page locked or while definitely holding a
> > reference to the mapping's host inode. I believe that the mmap should
> > have that reference, so for fear of hurting KVM performance or
> > introducing a deadlock, I opted for the unlocked variant.
> 
> KVM doesn't hold a reference per se, but it does subscribe to mmu_notifier events
> and will not mark the page dirty after KVM has been instructed to unmap the page
> (barring bugs, which we've had a slew of).  So yeah, the unlocked variant should
> be safe.
> 
> Is it feasible to trigger this behavior in a selftest?  KVM has had, and probably
> still has, many bugs that all boil down to KVM assuming guest memory is backed by
> either anonymous memory or something like shmem/HugeTLBFS/memfd that isn't typically
> truncated by the host.

I haven't been able to isolate a reproducer, yet. I am a bit stumped
because there isn't a lot for me to go off from that stack I shared--the
best I have so far is that I need to trick KVM into emulating
instructions at some point to get to this 'complete_userspace_io'
codepath? I will keep trying, since I think it would be valuable to know
what exactly happened. Open to try any suggestions you might have as
well.

Thanks for the response,
Boris

  reply	other threads:[~2022-01-26 23:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 19:54 [PATCH] KVM: use set_page_dirty rather than SetPageDirty Boris Burkov
2022-01-26 21:59 ` Sean Christopherson
2022-01-26 23:11   ` Boris Burkov [this message]
2022-01-27  0:02     ` Chris Mason
2022-01-27  1:36       ` Sean Christopherson
2022-01-27 15:00         ` Chris Mason
2022-01-27 12:20       ` Paolo Bonzini
2022-01-27 14:52         ` Chris Mason

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=YfHVB5RmLZn2ku5M@zen \
    --to=boris@bur.io \
    --cc=kernel-team@fb.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox