debuggers.hg

changeset 22804:d276f4528b32

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@xen.org>
author Keir Fraser <keir@xen.org>
date Fri Jan 14 14:19:55 2011 +0000 (2011-01-14)
parents 0e693052c791
children bfb1b1adf300
files xen/arch/x86/platform_hypercall.c xen/arch/x86/sysctl.c
line diff
     1.1 --- a/xen/arch/x86/platform_hypercall.c	Fri Jan 14 14:18:31 2011 +0000
     1.2 +++ b/xen/arch/x86/platform_hypercall.c	Fri Jan 14 14:19:55 2011 +0000
     1.3 @@ -55,11 +55,9 @@ static long cpu_frequency_change_helper(
     1.4      return cpu_frequency_change(this_cpu(freq));
     1.5  }
     1.6  
     1.7 -static long cpu_down_helper(void *data)
     1.8 -{
     1.9 -    int cpu = (unsigned long)data;
    1.10 -    return cpu_down(cpu);
    1.11 -}
    1.12 +/* from sysctl.c */
    1.13 +long cpu_up_helper(void *data);
    1.14 +long cpu_down_helper(void *data);
    1.15  
    1.16  ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
    1.17  {
    1.18 @@ -443,40 +441,43 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
    1.19  
    1.20      case XENPF_cpu_online:
    1.21      {
    1.22 -        int cpu;
    1.23 +        int cpu = op->u.cpu_ol.cpuid;
    1.24  
    1.25 -        cpu = op->u.cpu_ol.cpuid;
    1.26 -        if (!cpu_present(cpu))
    1.27 +        if ( !cpu_present(cpu) )
    1.28          {
    1.29              ret = -EINVAL;
    1.30              break;
    1.31          }
    1.32 -        else if (cpu_online(cpu))
    1.33 +
    1.34 +        if ( cpu_online(cpu) )
    1.35          {
    1.36              ret = 0;
    1.37              break;
    1.38          }
    1.39  
    1.40 -        ret = cpu_up(cpu);
    1.41 +        ret = continue_hypercall_on_cpu(
    1.42 +            0, cpu_up_helper, (void *)(unsigned long)cpu);
    1.43          break;
    1.44      }
    1.45  
    1.46      case XENPF_cpu_offline:
    1.47      {
    1.48 -        int cpu;
    1.49 +        int cpu = op->u.cpu_ol.cpuid;
    1.50  
    1.51 -        cpu = op->u.cpu_ol.cpuid;
    1.52 -        if (!cpu_present(cpu))
    1.53 +        if ( !cpu_present(cpu) )
    1.54          {
    1.55              ret = -EINVAL;
    1.56              break;
    1.57 -        } else if (!cpu_online(cpu))
    1.58 +        }
    1.59 +
    1.60 +        if ( !cpu_online(cpu) )
    1.61          {
    1.62              ret = 0;
    1.63              break;
    1.64          }
    1.65 +
    1.66          ret = continue_hypercall_on_cpu(
    1.67 -          0, cpu_down_helper, (void *)(unsigned long)cpu);
    1.68 +            0, cpu_down_helper, (void *)(unsigned long)cpu);
    1.69          break;
    1.70      }
    1.71      break;
     2.1 --- a/xen/arch/x86/sysctl.c	Fri Jan 14 14:18:31 2011 +0000
     2.2 +++ b/xen/arch/x86/sysctl.c	Fri Jan 14 14:19:55 2011 +0000
     2.3 @@ -30,10 +30,30 @@
     2.4  
     2.5  #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
     2.6  
     2.7 -static long cpu_down_helper(void *data)
     2.8 +long cpu_up_helper(void *data)
     2.9  {
    2.10      int cpu = (unsigned long)data;
    2.11 -    return cpu_down(cpu);
    2.12 +    int ret = cpu_up(cpu);
    2.13 +    if ( ret == -EBUSY )
    2.14 +    {
    2.15 +        /* On EBUSY, flush RCU work and have one more go. */
    2.16 +        rcu_barrier();
    2.17 +        ret = cpu_up(cpu);
    2.18 +    }
    2.19 +    return ret;
    2.20 +}
    2.21 +
    2.22 +long cpu_down_helper(void *data)
    2.23 +{
    2.24 +    int cpu = (unsigned long)data;
    2.25 +    int ret = cpu_down(cpu);
    2.26 +    if ( ret == -EBUSY )
    2.27 +    {
    2.28 +        /* On EBUSY, flush RCU work and have one more go. */
    2.29 +        rcu_barrier();
    2.30 +        ret = cpu_down(cpu);
    2.31 +    }
    2.32 +    return ret;
    2.33  }
    2.34  
    2.35  extern int __node_distance(int a, int b);
    2.36 @@ -170,7 +190,8 @@ long arch_do_sysctl(
    2.37          switch ( sysctl->u.cpu_hotplug.op )
    2.38          {
    2.39          case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
    2.40 -            ret = cpu_up(cpu);
    2.41 +            ret = continue_hypercall_on_cpu(
    2.42 +                0, cpu_up_helper, (void *)(unsigned long)cpu);
    2.43              break;
    2.44          case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
    2.45              ret = continue_hypercall_on_cpu(