hap dirty vram tracking
PATCH 1/1 hap dirty vram tracking
Hi all,
currently HAP systems suffer a significant performance loss when a vnc client is connect or the sdl interface is used, because HAP is lacking an implementation of track_dirty_vram.
As a consequence qemu always tries to update the whole screen because it does not know which areas of the screen have been updated by the guest.
This patch implements track_dirty_vram for HAP enabling the logdirty mechanism only in a specific gfn range and adding a paging_log_dirty_range function that returns the log dirty bitmap in a requested range.
Paging_log_dirty_range is different from paging_log_dirty_op because operates on a range and also because it does not pause the domain. In order not to lose any update I moved clean_dirty_bitmap at the beginning of the function before evaluating the logdirty bitmap.
The bitmap is still safe because it is protected by the logdirty lock.
---
xen/arch/x86/hvm/hvm.c +5 -3
@@ -34,6 +34,7 @@#include <xen/event.h> #include <xen/paging.h> #include <asm/shadow.h> +#include <asm/hap.h> #include <asm/current.h> #include <asm/e820.h> #include <asm/io.h>
@@ -2653,12 +2654,13 @@ goto param_fail2; rc = -EINVAL ; -if ( !shadow_mode_enabled (d)) - goto param_fail2;if ( d->vcpu[0 ] ==NULL ) goto param_fail2; - rc =shadow_track_dirty_vram (d, a.first_pfn, a.nr, a.dirty_bitmap); +if (shadow_mode_enabled (d) ) + rc =shadow_track_dirty_vram (d, a.first_pfn, a.nr, a.dirty_bitmap); +else + rc =hap_track_dirty_vram (d, a.first_pfn, a.nr, a.dirty_bitmap); param_fail2:rcu_unlock_domain (d);
xen/arch/x86/mm/hap/hap.c +147 -4
171 lines not on this page · raw message
xen/arch/x86/mm/paging.c +157 -0
174 lines not on this page · raw message
xen/arch/x86/mm/shadow/private.h +0 -11
@@ -590,17 +590,6 @@ }/**************************************************************************/ -/* VRAM dirty tracking support */ - -struct sh_dirty_vram { -unsigned long begin_pfn; -unsigned long end_pfn; -paddr_t *sl1ma; -uint8_t *dirty_bitmap; -s_time_t last_dirty; -}; - -/**************************************************************************/ /* Shadow-page refcounting. */ void sh_destroy_shadow (struct vcpu *v,mfn_t smfn);
xen/include/asm-x86/hap.h +5 -0
@@ -91,6 +91,11 @@void hap_final_teardown (struct domain *d);void hap_teardown (struct domain *d);void hap_vcpu_init (struct vcpu *v); +void hap_logdirty_init (struct domain *d); +int hap_track_dirty_vram (struct domain *d, +unsigned long begin_pfn, +unsigned long nr, +XEN_GUEST_HANDLE_64 (uint8) dirty_bitmap);extern struct paging_mode hap_paging_real_mode;extern struct paging_mode hap_paging_protected_mode;
xen/include/asm-x86/paging.h +6 -0
@@ -139,6 +139,12 @@/* free log dirty bitmap resource */ void paging_free_log_dirty_bitmap (struct domain *d); +/* get the dirty bitmap for a specific range of pfns */ +int paging_log_dirty_range (struct domain *d, +unsigned long begin_pfn, +unsigned long nr, +XEN_GUEST_HANDLE_64 (uint8) dirty_bitmap); +/* enable log dirty */ int paging_log_dirty_enable (struct domain *d);
xen/include/xen/sched.h +11 -0
@@ -165,6 +165,17 @@#define domain_unlock (d) spin_unlock_recursive(&(d)->domain_lock)#define domain_is_locked (d) spin_is_locked(&(d)->domain_lock) +/* VRAM dirty tracking support */ + +struct sh_dirty_vram { +unsigned long begin_pfn; +unsigned long end_pfn; +paddr_t *sl1ma; +uint8_t *dirty_bitmap; +s_time_t last_dirty; +}; + +/**************************************************************************/ struct domain {domid_t domain_id;