[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xen/vcpu: Improve code generation for VCPUOP_register_runstate_memory_area



Both XLAT_vcpu_runstate_info() and __copy_to_guest() are common paths in their
respective cases, but the optimiser can't/doesn't merge them.

Rearrange the code to do so explicitly.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
CC: Teddy Astie <teddy.astie@xxxxxxxxxx>

Bloat-o-meter reports:

  add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-110 (-110)
  Function                                     old     new   delta
  common_vcpu_op                              1943    1902     -41
  compat_vcpu_op                               967     898     -69

and the size of the stack frame doesn't change at all.
---
 xen/arch/x86/x86_64/domain.c | 13 ++++++-------
 xen/common/domain.c          | 11 +++++------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/x86_64/domain.c b/xen/arch/x86/x86_64/domain.c
index 533b0b21a00e..1510d593b18c 100644
--- a/xen/arch/x86/x86_64/domain.c
+++ b/xen/arch/x86/x86_64/domain.c
@@ -44,6 +44,7 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, 
XEN_GUEST_HANDLE_PARAM(void) arg)
     {
         struct compat_vcpu_register_runstate_memory_area area;
         struct compat_vcpu_runstate_info info;
+        struct vcpu_runstate_info runstate, *rs;
 
         area.addr.p = 0;
 
@@ -64,16 +65,14 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 
         /* Update the newly-registered runstate area, best-effort. */
         if ( v == current )
-        {
-            XLAT_vcpu_runstate_info(&info, &v->runstate);
-        }
+            rs = &v->runstate;
         else
         {
-            struct vcpu_runstate_info runstate;
-
-            vcpu_runstate_get(v, &runstate);
-            XLAT_vcpu_runstate_info(&info, &runstate);
+            rs = &runstate;
+            vcpu_runstate_get(v, rs);
         }
+
+        XLAT_vcpu_runstate_info(&info, rs);
         __copy_to_guest(v->runstate_guest.compat, &info, 1);
 
         break;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index b41be89cd0b9..2e6a1f9b98f7 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2318,7 +2318,7 @@ long common_vcpu_op(int cmd, struct vcpu *v, 
XEN_GUEST_HANDLE_PARAM(void) arg)
     case VCPUOP_register_runstate_memory_area:
     {
         struct vcpu_register_runstate_memory_area area;
-        struct vcpu_runstate_info runstate;
+        struct vcpu_runstate_info runstate, *rs;
 
         rc = -EFAULT;
         if ( copy_from_guest(&area, arg, 1) )
@@ -2340,15 +2340,14 @@ long common_vcpu_op(int cmd, struct vcpu *v, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 
         /* Update the newly-registered runstate area, best-effort. */
         if ( v == current )
-        {
-            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
-        }
+            rs = &v->runstate;
         else
         {
-            vcpu_runstate_get(v, &runstate);
-            __copy_to_guest(runstate_guest(v), &runstate, 1);
+            rs = &runstate;
+            vcpu_runstate_get(v, rs);
         }
 
+        __copy_to_guest(runstate_guest(v), rs, 1);
         break;
     }
 

base-commit: 8b0a70ddd29dec2f86a49c21e3664a21e281e859
-- 
2.39.5




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.