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

[Xen-changelog] [xen-unstable] x86: On CPU online/offline from dom0, try flushing RCU work on EBUSY.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1295014795 0
# Node ID d276f4528b32f6ea0503b3b2306d116ec1f09a7e
# Parent  0e693052c7918734e85efd26bfbe382ed518f5bc
x86: On CPU online/offline from dom0, try flushing RCU work on EBUSY.

Although the caller should react appropriately to EBUSY, if the error
is due to pending RCU work then we can help things along by executing
rcu_barrier() and then retrying. To this end, this changeset is an
optimisation only.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---
 xen/arch/x86/platform_hypercall.c |   49 +++++++++++++++++++-------------------
 xen/arch/x86/sysctl.c             |   27 ++++++++++++++++++--
 2 files changed, 49 insertions(+), 27 deletions(-)

diff -r 0e693052c791 -r d276f4528b32 xen/arch/x86/platform_hypercall.c
--- a/xen/arch/x86/platform_hypercall.c Fri Jan 14 14:18:31 2011 +0000
+++ b/xen/arch/x86/platform_hypercall.c Fri Jan 14 14:19:55 2011 +0000
@@ -55,11 +55,9 @@ static long cpu_frequency_change_helper(
     return cpu_frequency_change(this_cpu(freq));
 }
 
-static long cpu_down_helper(void *data)
-{
-    int cpu = (unsigned long)data;
-    return cpu_down(cpu);
-}
+/* from sysctl.c */
+long cpu_up_helper(void *data);
+long cpu_down_helper(void *data);
 
 ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
 {
@@ -443,40 +441,43 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
 
     case XENPF_cpu_online:
     {
-        int cpu;
-
-        cpu = op->u.cpu_ol.cpuid;
-        if (!cpu_present(cpu))
-        {
-            ret = -EINVAL;
-            break;
-        }
-        else if (cpu_online(cpu))
+        int cpu = op->u.cpu_ol.cpuid;
+
+        if ( !cpu_present(cpu) )
+        {
+            ret = -EINVAL;
+            break;
+        }
+
+        if ( cpu_online(cpu) )
         {
             ret = 0;
             break;
         }
 
-        ret = cpu_up(cpu);
+        ret = continue_hypercall_on_cpu(
+            0, cpu_up_helper, (void *)(unsigned long)cpu);
         break;
     }
 
     case XENPF_cpu_offline:
     {
-        int cpu;
-
-        cpu = op->u.cpu_ol.cpuid;
-        if (!cpu_present(cpu))
-        {
-            ret = -EINVAL;
-            break;
-        } else if (!cpu_online(cpu))
+        int cpu = op->u.cpu_ol.cpuid;
+
+        if ( !cpu_present(cpu) )
+        {
+            ret = -EINVAL;
+            break;
+        }
+
+        if ( !cpu_online(cpu) )
         {
             ret = 0;
             break;
         }
+
         ret = continue_hypercall_on_cpu(
-          0, cpu_down_helper, (void *)(unsigned long)cpu);
+            0, cpu_down_helper, (void *)(unsigned long)cpu);
         break;
     }
     break;
diff -r 0e693052c791 -r d276f4528b32 xen/arch/x86/sysctl.c
--- a/xen/arch/x86/sysctl.c     Fri Jan 14 14:18:31 2011 +0000
+++ b/xen/arch/x86/sysctl.c     Fri Jan 14 14:19:55 2011 +0000
@@ -30,10 +30,30 @@
 
 #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
 
-static long cpu_down_helper(void *data)
+long cpu_up_helper(void *data)
 {
     int cpu = (unsigned long)data;
-    return cpu_down(cpu);
+    int ret = cpu_up(cpu);
+    if ( ret == -EBUSY )
+    {
+        /* On EBUSY, flush RCU work and have one more go. */
+        rcu_barrier();
+        ret = cpu_up(cpu);
+    }
+    return ret;
+}
+
+long cpu_down_helper(void *data)
+{
+    int cpu = (unsigned long)data;
+    int ret = cpu_down(cpu);
+    if ( ret == -EBUSY )
+    {
+        /* On EBUSY, flush RCU work and have one more go. */
+        rcu_barrier();
+        ret = cpu_down(cpu);
+    }
+    return ret;
 }
 
 extern int __node_distance(int a, int b);
@@ -170,7 +190,8 @@ long arch_do_sysctl(
         switch ( sysctl->u.cpu_hotplug.op )
         {
         case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
-            ret = cpu_up(cpu);
+            ret = continue_hypercall_on_cpu(
+                0, cpu_up_helper, (void *)(unsigned long)cpu);
             break;
         case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
             ret = continue_hypercall_on_cpu(

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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