This patch is userspace part of the "batch writes to MMIO" patch.

When kernel has to send MMIO writes to userspace, it stores them
in memory until it has to pass the hand to userspace for another
reason. This avoids too have to many context switches on operations
that can wait.

Signed-off-by: Laurent Vivier <[EMAIL PROTECTED]>
---
 libkvm/libkvm.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 329f29f..be74477 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -864,6 +864,10 @@ int kvm_run(kvm_context_t kvm, int vcpu)
        int r;
        int fd = kvm->vcpu_fd[vcpu];
        struct kvm_run *run = kvm->run[vcpu];
+#if defined(__x86_64__) || defined(__i386__)
+       struct kvm_batch *batch = (void *)run + 2 * PAGE_SIZE;
+       int i;
+#endif
 
 again:
        if (!kvm->irqchip_in_kernel)
@@ -882,6 +886,19 @@ again:
 
        post_kvm_run(kvm, vcpu);
 
+#if defined(__x86_64__) || defined(__i386__)
+       for (i = 0; i < run->batch_count; i++) {
+               if ((batch[i].phys_addr > 0xa0000-4 &&
+                    batch[i].phys_addr <= 0xa0000) && batch[i].len == 3)
+                       continue;
+               kvm->callbacks->mmio_write(kvm->opaque,
+                                          batch[i].phys_addr,
+                                          &batch[i].data[0], batch[i].len);
+
+       }
+       run->batch_count = 0;
+#endif
+
        if (r == -1) {
                r = handle_io_window(kvm);
                goto more;
-- 
1.5.2.4


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to