debuggers.hg

changeset 22799:c3b5924919e3

tools/misc/xen-hptool: Silently retry on CPU hotplug EBUSY failure.

EBUSY is a legitimate soft failure, due to inability to acquire a
lock, or because RCU work has not been done since a CPU was last
offlined.

Signed-off-by: Keir Fraser <keir@xen.org>
author Keir Fraser <keir@xen.org>
date Fri Jan 14 09:53:22 2011 +0000 (2011-01-14)
parents ff97273750b8
children 6c9bcfb0fb84
files tools/misc/xen-hptool.c
line diff
     1.1 --- a/tools/misc/xen-hptool.c	Fri Jan 14 09:52:02 2011 +0000
     1.2 +++ b/tools/misc/xen-hptool.c	Fri Jan 14 09:53:22 2011 +0000
     1.3 @@ -2,6 +2,7 @@
     1.4  #include <xc_private.h>
     1.5  #include <xc_core.h>
     1.6  #include <errno.h>
     1.7 +#include <unistd.h>
     1.8  
     1.9  #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
    1.10  
    1.11 @@ -241,6 +242,20 @@ static int hp_mem_offline_func(int argc,
    1.12      return ret;
    1.13  }
    1.14  
    1.15 +static int exec_cpu_hp_fn(int (*hp_fn)(xc_interface *, int), int cpu)
    1.16 +{
    1.17 +    int ret;
    1.18 +
    1.19 +    for ( ; ; )
    1.20 +    {
    1.21 +        ret = (*hp_fn)(xch, cpu);
    1.22 +        if ( (ret >= 0) || (errno != EBUSY) )
    1.23 +            break;
    1.24 +        usleep(100000); /* 100ms */
    1.25 +    }
    1.26 +
    1.27 +    return ret;
    1.28 +}
    1.29  
    1.30  static int hp_cpu_online_func(int argc, char *argv[])
    1.31  {
    1.32 @@ -254,7 +269,7 @@ static int hp_cpu_online_func(int argc, 
    1.33  
    1.34      cpu = atoi(argv[0]);
    1.35      printf("Prepare to online CPU %d\n", cpu);
    1.36 -    ret = xc_cpu_online(xch, cpu);
    1.37 +    ret = exec_cpu_hp_fn(xc_cpu_online, cpu);
    1.38      if (ret < 0)
    1.39          fprintf(stderr, "CPU %d online failed (error %d: %s)\n",
    1.40                  cpu, errno, strerror(errno));
    1.41 @@ -275,7 +290,7 @@ static int hp_cpu_offline_func(int argc,
    1.42      }
    1.43      cpu = atoi(argv[0]);
    1.44      printf("Prepare to offline CPU %d\n", cpu);
    1.45 -    ret = xc_cpu_offline(xch, cpu);
    1.46 +    ret = exec_cpu_hp_fn(xc_cpu_offline, cpu);
    1.47      if (ret < 0)
    1.48          fprintf(stderr, "CPU %d offline failed (error %d: %s)\n",
    1.49                  cpu, errno, strerror(errno));