ia64/xen-unstable

changeset 19374:821a4a8911f0

Add CPU status info and a status call to the CPU on/offline sysctls.

Signed-off-by: Frank van der Linden <frank.vanderlinden@sun.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 17 14:25:41 2009 +0000 (2009-03-17)
parents 372ec886ad0c
children 2725f82a7dca
files xen/arch/x86/smpboot.c xen/arch/x86/sysctl.c xen/include/public/sysctl.h
line diff
     1.1 --- a/xen/arch/x86/smpboot.c	Tue Mar 17 14:24:08 2009 +0000
     1.2 +++ b/xen/arch/x86/smpboot.c	Tue Mar 17 14:25:41 2009 +0000
     1.3 @@ -1426,8 +1426,10 @@ int __devinit __cpu_up(unsigned int cpu)
     1.4  	 * cpu_callin_map is set during AP kickstart process. Its reset
     1.5  	 * when a cpu is taken offline from cpu_exit_clear().
     1.6  	 */
     1.7 -	if (!cpu_isset(cpu, cpu_callin_map))
     1.8 +	if (!cpu_isset(cpu, cpu_callin_map)) {
     1.9  		ret = __smp_prepare_cpu(cpu);
    1.10 +		smpboot_restore_warm_reset_vector();
    1.11 +	}
    1.12  
    1.13  	if (ret)
    1.14  		return -EIO;
     2.1 --- a/xen/arch/x86/sysctl.c	Tue Mar 17 14:24:08 2009 +0000
     2.2 +++ b/xen/arch/x86/sysctl.c	Tue Mar 17 14:25:41 2009 +0000
     2.3 @@ -38,7 +38,7 @@ static long cpu_down_helper(void *data)
     2.4  long arch_do_sysctl(
     2.5      struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
     2.6  {
     2.7 -    long ret = 0;
     2.8 +    long ret = 0, status;
     2.9  
    2.10      switch ( sysctl->cmd )
    2.11      {
    2.12 @@ -102,19 +102,41 @@ long arch_do_sysctl(
    2.13      {
    2.14          unsigned int cpu = sysctl->u.cpu_hotplug.cpu;
    2.15  
    2.16 +        if (cpu_present(cpu)) {
    2.17 +            status = cpu_online(cpu) ? XEN_CPU_HOTPLUG_STATUS_ONLINE :
    2.18 +                XEN_CPU_HOTPLUG_STATUS_OFFLINE;
    2.19 +        } else {
    2.20 +            status = -EINVAL;
    2.21 +        }
    2.22 +
    2.23          switch ( sysctl->u.cpu_hotplug.op )
    2.24          {
    2.25          case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
    2.26              ret = cpu_up(cpu);
    2.27 +            /*
    2.28 +             * In the case of a true hotplug, this CPU wasn't present
    2.29 +             * before, so return the 'new' status for it.
    2.30 +             */
    2.31 +            if (ret == 0 && status == -EINVAL)
    2.32 +                status = XEN_CPU_HOTPLUG_STATUS_NEW;
    2.33              break;
    2.34          case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
    2.35              ret = continue_hypercall_on_cpu(
    2.36                  0, cpu_down_helper, (void *)(unsigned long)cpu);
    2.37              break;
    2.38 +        case XEN_SYSCTL_CPU_HOTPLUG_STATUS:
    2.39 +            ret = 0;
    2.40 +            break;
    2.41          default:
    2.42              ret = -EINVAL;
    2.43              break;
    2.44          }
    2.45 +
    2.46 +        /*
    2.47 +         * If the operation was successful, return the old status.
    2.48 +         */
    2.49 +        if (ret >= 0)
    2.50 +            ret = status;
    2.51      }
    2.52      break;
    2.53  
     3.1 --- a/xen/include/public/sysctl.h	Tue Mar 17 14:24:08 2009 +0000
     3.2 +++ b/xen/include/public/sysctl.h	Tue Mar 17 14:25:41 2009 +0000
     3.3 @@ -262,12 +262,21 @@ struct xen_sysctl_get_pmstat {
     3.4  typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
     3.5  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
     3.6  
     3.7 +/*
     3.8 + * Status codes. Must be greater than 0 to avoid confusing
     3.9 + * sysctl callers that see 0 as a plain successful return.
    3.10 + */
    3.11 +#define XEN_CPU_HOTPLUG_STATUS_OFFLINE 1
    3.12 +#define XEN_CPU_HOTPLUG_STATUS_ONLINE  2
    3.13 +#define XEN_CPU_HOTPLUG_STATUS_NEW     3
    3.14 +
    3.15  #define XEN_SYSCTL_cpu_hotplug       11
    3.16  struct xen_sysctl_cpu_hotplug {
    3.17      /* IN variables */
    3.18      uint32_t cpu;   /* Physical cpu. */
    3.19  #define XEN_SYSCTL_CPU_HOTPLUG_ONLINE  0
    3.20  #define XEN_SYSCTL_CPU_HOTPLUG_OFFLINE 1
    3.21 +#define XEN_SYSCTL_CPU_HOTPLUG_STATUS 2
    3.22      uint32_t op;    /* hotplug opcode */
    3.23  };
    3.24  typedef struct xen_sysctl_cpu_hotplug xen_sysctl_cpu_hotplug_t;