From: Marcelo Tosatti <mtosatti@redhat.com>
To: Sheng Yang <sheng@linux.intel.com>
Cc: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH] kvm: Flush coalesced MMIO buffer periodly
Date: Mon, 25 Jan 2010 14:08:03 -0200 [thread overview]
Message-ID: <20100125160803.GA16043@amt.cnet> (raw)
In-Reply-To: <1264405604-13506-1-git-send-email-sheng@linux.intel.com>
On Mon, Jan 25, 2010 at 03:46:44PM +0800, Sheng Yang wrote:
> The default action of coalesced MMIO is, cache the writing in buffer, until:
> 1. The buffer is full.
> 2. Or the exit to QEmu due to other reasons.
>
> But this would result in a very late writing in some condition.
> 1. The each time write to MMIO content is small.
> 2. The writing interval is big.
> 3. No need for input or accessing other devices frequently.
>
> This issue was observed in a experimental embbed system. The test image
> simply print "test" every 1 seconds. The output in QEmu meets expectation,
> but the output in KVM is delayed for seconds.
>
> Per Avi's suggestion, I hooked flushing coalesced MMIO buffer in VGA update
> handler. By this way, We don't need vcpu explicit exit to QEmu to
> handle this issue.
Sheng,
Can you send this to QEMU upstream first, since the feature is present
there.
> Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> ---
> cpu-all.h | 2 ++
> exec.c | 6 ++++++
> kvm-all.c | 20 ++++++++++++++++++++
> qemu-kvm.c | 9 +++++++--
> qemu-kvm.h | 2 ++
> vl.c | 2 ++
> 6 files changed, 39 insertions(+), 2 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 8ed76c7..51effc0 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -916,6 +916,8 @@ void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
>
> void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
>
> +void qemu_flush_coalesced_mmio_buffer(void);
> +
> /*******************************************/
> /* host CPU ticks (if available) */
>
> diff --git a/exec.c b/exec.c
> index 99e88e1..40c01a1 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2424,6 +2424,12 @@ void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size)
> kvm_uncoalesce_mmio_region(addr, size);
> }
>
> +void qemu_flush_coalesced_mmio_buffer(void)
> +{
> + if (kvm_enabled())
> + kvm_flush_coalesced_mmio_buffer();
> +}
> +
> #ifdef __linux__
>
> #include <sys/vfs.h>
> diff --git a/kvm-all.c b/kvm-all.c
> index 0423fff..3d9fcc0 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -25,6 +25,9 @@
> #include "hw/hw.h"
> #include "gdbstub.h"
> #include "kvm.h"
> +#ifndef KVM_UPSTREAM
> +#include "libkvm.h"
> +#endif
>
> #ifdef KVM_UPSTREAM
> /* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */
> @@ -385,6 +388,23 @@ int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
> return ret;
> }
>
> +void kvm_flush_coalesced_mmio_buffer(void)
> +{
> +#ifdef KVM_CAP_COALESCED_MMIO
> + if (kvm_state->coalesced_mmio_ring) {
> + struct kvm_coalesced_mmio_ring *ring =
> + kvm_state->coalesced_mmio_ring;
> + while (ring->first != ring->last) {
> + cpu_physical_memory_rw(ring->coalesced_mmio[ring->first].phys_addr,
> + &ring->coalesced_mmio[ring->first].data[0],
> + ring->coalesced_mmio[ring->first].len, 1);
> + smp_wmb();
Tab breakage.
next prev parent reply other threads:[~2010-01-25 16:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-25 7:46 [PATCH] kvm: Flush coalesced MMIO buffer periodly Sheng Yang
2010-01-25 16:08 ` Marcelo Tosatti [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-01-21 9:37 Sheng Yang
2010-01-21 10:19 ` Avi Kivity
2010-01-22 2:22 ` Sheng Yang
2010-01-24 7:35 ` Avi Kivity
2010-01-25 7:45 ` Sheng Yang
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=20100125160803.GA16043@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=sheng@linux.intel.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.