qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, dgilbert@redhat.com
Subject: Re: [PATCH RFC v2 9/9] KVM: Dirty ring support
Date: Tue, 28 Apr 2020 16:20:41 -0400	[thread overview]
Message-ID: <20200428202041.GA4280@xz-x1> (raw)
In-Reply-To: <20200428200509.13150-7-peterx@redhat.com>

On Tue, Apr 28, 2020 at 04:05:09PM -0400, Peter Xu wrote:
> +/*
> + * Flush all the existing dirty pages to the KVM slot buffers.  When
> + * this call returns, we guarantee that all the touched dirty pages
> + * before calling this function have been put into the per-kvmslot
> + * dirty bitmap.
> + *
> + * To achieve this, we need to:
> + *
> + * (1) Kick all vcpus out, this will make sure that we flush all the
> + *     dirty buffers that potentially in the hardware (PML) into the
> + *     dirty rings, after that,
> + *
> + * (2) Kick the reaper thread and make sure it reaps all the dirty
> + *     page that is in the dirty rings.

Please note that some of the comments might be outdated, like this one...

(I think I'll remove these two paragraph in the next post)

> + *
> + * This function must be called with BQL held.
> + */
> +static void kvm_dirty_ring_flush(struct KVMDirtyRingReaper *r)
> +{
> +    trace_kvm_dirty_ring_flush(0);
> +
> +    /*
> +     * The function needs to be serialized.  Since this function
> +     * should always be with BQL held, serialization is guaranteed.
> +     * However, let's be sure of it.
> +     */
> +    assert(qemu_mutex_iothread_locked());
> +
> +    /*
> +     * First make sure to flush the hardware buffers by kicking all
> +     * vcpus out in a synchronous way.
> +     */
> +    kvm_cpu_synchronize_kick_all();
> +
> +    /*
> +     * Recycle the dirty bits outside the reaper thread.  We're safe because
> +     * kvm_dirty_ring_reap() is internally protected by a mutex.

Same here; the comment is obsolete.  There used to be a mutex after v1 and
before v2, but I removed the mutex because now we simply always take the BQL so
that mutex is not needed any more.

I'm not sure whether there's still obsolete comments here and there (since the
code does changed quite a bit).  Anyway please stick to the code if there's
conflicts, and I'll try to fix the comments up.

> +     */
> +    kvm_dirty_ring_reap(kvm_state);
> +
> +    trace_kvm_dirty_ring_flush(1);
> +}

-- 
Peter Xu



      reply	other threads:[~2020-04-28 20:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 19:56 [PATCH RFC v2 0/9] KVM: Dirty ring support (QEMU part) Peter Xu
2020-04-28 19:56 ` [PATCH RFC v2 1/9] KVM: Fixup kvm_log_clear_one_slot() ioctl return check Peter Xu
2020-04-28 19:57 ` [PATCH RFC v2 2/9] linux-headers: Update Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 3/9] memory: Introduce log_sync_global() to memory listener Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 4/9] KVM: Create the KVMSlot dirty bitmap on flag changes Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 5/9] KVM: Provide helper to get kvm dirty log Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 6/9] KVM: Provide helper to sync dirty bitmap from slot to ramblock Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 7/9] KVM: Cache kvm slot dirty bitmap size Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 8/9] KVM: Add dirty-gfn-count property Peter Xu
2020-04-28 20:05 ` [PATCH RFC v2 9/9] KVM: Dirty ring support Peter Xu
2020-04-28 20:20   ` Peter Xu [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=20200428202041.GA4280@xz-x1 \
    --to=peterx@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=pbonzini@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).