From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Xu <peterx@redhat.com>,
QEMU Devel Mailing List <qemu-devel@nongnu.org>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: Question on dirty sync before kvm memslot removal
Date: Tue, 31 Mar 2020 17:34:43 +0200 [thread overview]
Message-ID: <62aa8314-954f-7397-8bf4-d81d926c4f0b@redhat.com> (raw)
In-Reply-To: <20200331152314.GG522868@xz-x1>
On 31/03/20 17:23, Peter Xu wrote:
>> Or KVM_MEM_READONLY.
> Yeah, I used a new flag because I thought READONLY was a bit tricky to
> be used directly here. The thing is IIUC if guest writes to a
> READONLY slot then KVM should either ignore the write or trigger an
> error which I didn't check, however here what we want to do is to let
> the write to fallback to the userspace so it's neither dropped (we
> still want the written data to land gracefully on RAM), nor triggering
> an error (because the slot is actually writable).
No, writes fall back to userspace with KVM_MEM_READONLY.
>> The problem here is also that the GFN is not an unique identifier of the
>> QEMU ram_addr_t. However you don't really need to kick all vCPUs out,
>> do you? You can protect the dirty ring with its own per-vCPU mutex and
>> harvest the pages from the main thread.
> I'm not sure I get the point, but just to mention that currently the
> dirty GFNs are collected in a standalone thread (in the QEMU series
> it's called the reaper thread) rather than in the per vcpu thread
> because the KVM_RESET_DIRTY_RINGS is per-vm after all. One major
> reason to kick the vcpus is to make sure the hardware cached dirty
> GFNs (i.e. PML) are flushed synchronously.
But you're referring to KVM kicking vCPUs not qemu_vcpu_kick. Can you
just do an iteration of reaping after setting KVM_MEM_READONLY?
> I think the whole kick operation is indeed too heavy for this when
> with the run_on_cpu() trick, because the thing we want to know (pml
> flushing) is actually per-vcpu and no BQL interaction. Do we have/need
> a lightweight way to kick one vcpu in synchronous way? I was
> wondering maybe something like responding a "sync kick" request in the
> vcpu thread right after KVM_RUN ends (when we don't have BQL yet).
> Would that make sense?
Not synchronously, because anything synchronous is very susceptible to
deadlocks.
Thanks,
Paolo
next prev parent reply other threads:[~2020-03-31 15:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 15:04 Question on dirty sync before kvm memslot removal Peter Xu
2020-03-30 13:11 ` Paolo Bonzini
2020-03-31 15:23 ` Peter Xu
2020-03-31 15:34 ` Paolo Bonzini [this message]
2020-03-31 16:51 ` Peter Xu
2020-03-31 23:12 ` Paolo Bonzini
2020-04-01 23:09 ` Peter Xu
2020-04-02 20:47 ` Peter Xu
2020-04-02 22:32 ` Peter Xu
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=62aa8314-954f-7397-8bf4-d81d926c4f0b@redhat.com \
--to=pbonzini@redhat.com \
--cc=dgilbert@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).