Skip to contentSkip to conversation

xen: Don't disable the REP emulation optimizations for regular IO

PATCH In review Razvan Cojocaru 4 participants 4 messages Mar 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Don't disable the REP emulation optimizations for regular IO

Currently REP emulations optimizations remain disabled even if the emulation does not happen as a result of a vm_event reply requestion emulation (i.e. even for regular IO). This patch takes emulate_each_rep into account only if emulation has been requested by a vm_event-capable application, and is a noticeable speed optimization for monitored guests.

---
 xen/arch/x86/hvm/emulate.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
xen/arch/x86/hvm/emulate.c +12 -6
index 082aa30..ddc8007 100644
@@ -498,6 +498,7 @@ static int hvmemul_virtual_to_linear(
 {
     struct segment_register *reg;
     int okay;
+    unsigned long max_reps = 4096;
 
     if ( seg == x86_seg_none )
     {
@@ -506,16 +507,21 @@ static int hvmemul_virtual_to_linear(
     }
 
     /*
+     * If introspection has been enabled for this domain, and we're emulating
+     * becase a vm_reply asked us to (i.e. not doing regular IO) reps should
+     * be at most 1, since optimization might otherwise cause a single
+     * vm_event being triggered for repeated writes to a whole page.
+     */
+    if ( unlikely(current->domain->arch.mem_access_emulate_each_rep) &&
+         current->arch.vm_event->emulate_flags != 0 )
+       max_reps = 1;
+
+    /*
      * Clip repetitions to avoid overflow when multiplying by @bytes_per_rep.
      * The chosen maximum is very conservative but it's what we use in
      * hvmemul_linear_to_phys() so there is no point in using a larger value.
-     * If introspection has been enabled for this domain, *reps should be
-     * at most 1, since optimization might otherwise cause a single vm_event
-     * being triggered for repeated writes to a whole page.
      */
-    *reps = min_t(unsigned long, *reps,
-                  unlikely(current->domain->arch.mem_access_emulate_each_rep)
-                           ? 1 : 4096);
+    *reps = min_t(unsigned long, *reps, max_reps);
 
     reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt);
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 10.03.16 at 11:07, <[email protected]> wrote:

Currently REP emulations optimizations remain disabled even if the emulation does not happen as a result of a vm_event reply requestion emulation (i.e. even for regular IO). This patch takes emulate_each_rep into account only if emulation has been requested by a vm_event-capable application, and is a noticeable speed optimization for monitored guests.

Looks reasonable, but this being an event specific change I'm making my ack to this dependent on Tamas'es consent.

Jan

Quoted 40 lines
xen/arch/x86/hvm/emulate.c +12 -6
@@ -498,6 +498,7 @@ static int hvmemul_virtual_to_linear(
 {
     struct segment_register *reg;
     int okay;
+    unsigned long max_reps = 4096;
 
     if ( seg == x86_seg_none )
     {
@@ -506,16 +507,21 @@ static int hvmemul_virtual_to_linear(
     }
 
     /*
+     * If introspection has been enabled for this domain, and we're emulating
+     * becase a vm_reply asked us to (i.e. not doing regular IO) reps should
+     * be at most 1, since optimization might otherwise cause a single
+     * vm_event being triggered for repeated writes to a whole page.
+     */
+    if ( unlikely(current->domain->arch.mem_access_emulate_each_rep) &&
+         current->arch.vm_event->emulate_flags != 0 )
+       max_reps = 1;
+
+    /*
      * Clip repetitions to avoid overflow when multiplying by @bytes_per_rep.
      * The chosen maximum is very conservative but it's what we use in
      * hvmemul_linear_to_phys() so there is no point in using a larger value.
-     * If introspection has been enabled for this domain, *reps should be
-     * at most 1, since optimization might otherwise cause a single vm_event
-     * being triggered for repeated writes to a whole page.
      */
-    *reps = min_t(unsigned long, *reps,
-                  unlikely(current->domain->arch.mem_access_emulate_each_rep)
-                           ? 1 : 4096);
+    *reps = min_t(unsigned long, *reps, max_reps);
 
     reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt);
 
Signature · 1 line
1.9.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Razvan Cojocaru
Quoted 8 lines · Razvan Cojocaru

Currently REP emulations optimizations remain disabled even if the emulation does not happen as a result of a vm_event reply requestion emulation (i.e. even for regular IO). This patch takes emulate_each_rep into account only if emulation has been requested by a vm_event-capable application, and is a noticeable speed optimization for monitored guests.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#3 lore raw
In reply to Razvan Cojocaru
Quoted 9 lines · Razvan Cojocaru

Currently REP emulations optimizations remain disabled even if the emulation does not happen as a result of a vm_event reply requestion emulation (i.e. even for regular IO). This patch takes emulate_each_rep into account only if emulation has been requested by a vm_event-capable application, and is a noticeable speed optimization for monitored guests.

Quoted 17 lines
---
 xen/arch/x86/hvm/emulate.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
xen/arch/x86/hvm/emulate.c +1 -0
index 082aa30..ddc8007 100644
@@ -498,6 +498,7 @@ static int hvmemul_virtual_to_linear(
 {
     struct segment_register *reg;
     int okay;
+    unsigned long max_reps = 4096;
 
     if ( seg == x86_seg_none )
     {

xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear( · line 510

Quoted 4 lines
xen/arch/x86/hvm/emulate.c +1 -0
@@ -506,16 +507,21 @@ static int hvmemul_virtual_to_linear(
     }
 
     /*
+     * If introspection has been enabled for this domain, and we're

emulating

xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear( · line 511

Quoted 1 line
xen/arch/x86/hvm/emulate.c +1 -0
+     * becase a vm_reply asked us to (i.e. not doing regular IO) reps

should

xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear(

Quoted 9 lines
xen/arch/x86/hvm/emulate.c +8 -0
+     * be at most 1, since optimization might otherwise cause a single
+     * vm_event being triggered for repeated writes to a whole page.
+     */
+    if ( unlikely(current->domain->arch.mem_access_emulate_each_rep) &&
+         current->arch.vm_event->emulate_flags != 0 )
+       max_reps = 1;
+
+    /*
      * Clip repetitions to avoid overflow when multiplying by

@bytes_per_rep.

xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear( · line 522

Quoted 2 lines
xen/arch/x86/hvm/emulate.c +0 -0
      * The chosen maximum is very conservative but it's what we use in
      * hvmemul_linear_to_phys() so there is no point in using a larger

value.

xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear( · line 513

Quoted 2 lines
xen/arch/x86/hvm/emulate.c +0 -2
-     * If introspection has been enabled for this domain, *reps should be
-     * at most 1, since optimization might otherwise cause a single

vm_event

xen/arch/x86/hvm/emulate.c static int hvmemul_virtual_to_linear(

Quoted 4 lines
xen/arch/x86/hvm/emulate.c +0 -3
-     * being triggered for repeated writes to a whole page.
      */
-    *reps = min_t(unsigned long, *reps,
-

unlikely(current->domain->arch.mem_access_emulate_each_rep)

Quoted 9 lines
xen/arch/x86/hvm/emulate.c +1 -2
-                           ? 1 : 4096);
+    *reps = min_t(unsigned long, *reps, max_reps);
 
     reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt);
 
--

1.9.1

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel