linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Sean Christopherson <seanjc@google.com>
Cc: "borntraeger@linux.ibm.com" <borntraeger@linux.ibm.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"frankja@linux.ibm.com" <frankja@linux.ibm.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"imbrenda@linux.ibm.com" <imbrenda@linux.ibm.com>,
	"david@redhat.com" <david@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [EXTERNAL] [PATCH v2] KVM: Don't actually set a request when evicting vCPUs for GFN cache invd
Date: Fri, 25 Feb 2022 16:59:59 +0000	[thread overview]
Message-ID: <915ddc7327585bbe8587b91b8cd208520d684db1.camel@infradead.org> (raw)
In-Reply-To: <YhkAJ+nw2lCzRxsg@google.com>

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

On Fri, 2022-02-25 at 16:13 +0000, Sean Christopherson wrote:
> On Fri, Feb 25, 2022, Woodhouse, David wrote:
> > Since we need an active vCPU context to do dirty logging (thanks, dirty
> > ring)... and since any time vcpu_run exits to userspace for any reason
> > might be the last time we ever get an active vCPU context... I think
> > that kind of fundamentally means that we must flush dirty state to the
> > log on *every* return to userspace, doesn't it?
> 
> I would rather add a variant of mark_page_dirty_in_slot() that takes a vCPU, which
> we whould have in all cases.  I see no reason to require use of kvm_get_running_vcpu().

We already have kvm_vcpu_mark_page_dirty(), but it can't use just 'some
vcpu' because the dirty ring is lockless. So if you're ever going to
use anything other than kvm_get_running_vcpu() we need to add locks.

And while we *could* do that, I don't think it would negate the
fundamental observation that *any* time we return from vcpu_run to
userspace, that could be the last time. Userspace might read the dirty
log for the *last* time, and any internally-cached "oh, at some point
we need to mark <this> page dirty" is lost because by the time the vCPU
is finally destroyed, it's too late.

I think I'm going to rip out the 'dirty' flag from the gfn_to_pfn_cache
completely and add a function (to be called with an active vCPU
context) which marks the page dirty *now*.

KVM_GUEST_USES_PFN users like nested VMX will be expected to do this
before returning from vcpu_run anytime it's in L2 guest mode. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

  reply	other threads:[~2022-02-25 17:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 16:53 [PATCH v2] KVM: Don't actually set a request when evicting vCPUs for GFN cache invd Sean Christopherson
2022-02-23 17:01 ` David Woodhouse
2022-02-23 17:08   ` Sean Christopherson
2022-02-24 10:14 ` [EXTERNAL] " David Woodhouse
     [not found] ` <2547e9675d855449bc5cc7efb97251d6286a377c.camel@amazon.co.uk>
2022-02-25 16:13   ` Sean Christopherson
2022-02-25 16:59     ` David Woodhouse [this message]
2022-02-25 17:27       ` [EXTERNAL] " Sean Christopherson
2022-02-25 18:41         ` David Woodhouse
2022-02-25 18:52           ` Sean Christopherson
2022-02-25 20:15             ` David Woodhouse
2022-02-27 15:11             ` [PATCH] KVM: Remove dirty handling from gfn_to_pfn_cache completely David Woodhouse
2022-03-08 15:41 ` [PATCH v2] KVM: Don't actually set a request when evicting vCPUs for GFN cache invd Paolo Bonzini

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=915ddc7327585bbe8587b91b8cd208520d684db1.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).