aboutsummaryrefslogtreecommitdiffstats
path: root/tools/misc
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-01-14 09:53:22 +0000
committerKeir Fraser <keir@xen.org>2011-01-14 09:53:22 +0000
commitf573a5226aa09eadd9cef7849b857a2bcea7443b (patch)
treef83f29e68b349383fd8fd13097d1af31de6d1bb2 /tools/misc
parent2d87af888ff25608e5a09d6d6eb3f1c292051a89 (diff)
downloadxen-f573a5226aa09eadd9cef7849b857a2bcea7443b.tar.gz
xen-f573a5226aa09eadd9cef7849b857a2bcea7443b.tar.bz2
xen-f573a5226aa09eadd9cef7849b857a2bcea7443b.zip
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>
Diffstat (limited to 'tools/misc')
-rw-r--r--tools/misc/xen-hptool.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c
index 374d88315d..24c3e956c0 100644
--- a/tools/misc/xen-hptool.c
+++ b/tools/misc/xen-hptool.c
@@ -2,6 +2,7 @@
#include <xc_private.h>
#include <xc_core.h>
#include <errno.h>
+#include <unistd.h>
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
@@ -241,6 +242,20 @@ static int hp_mem_offline_func(int argc, char *argv[])
return ret;
}
+static int exec_cpu_hp_fn(int (*hp_fn)(xc_interface *, int), int cpu)
+{
+ int ret;
+
+ for ( ; ; )
+ {
+ ret = (*hp_fn)(xch, cpu);
+ if ( (ret >= 0) || (errno != EBUSY) )
+ break;
+ usleep(100000); /* 100ms */
+ }
+
+ return ret;
+}
static int hp_cpu_online_func(int argc, char *argv[])
{
@@ -254,7 +269,7 @@ static int hp_cpu_online_func(int argc, char *argv[])
cpu = atoi(argv[0]);
printf("Prepare to online CPU %d\n", cpu);
- ret = xc_cpu_online(xch, cpu);
+ ret = exec_cpu_hp_fn(xc_cpu_online, cpu);
if (ret < 0)
fprintf(stderr, "CPU %d online failed (error %d: %s)\n",
cpu, errno, strerror(errno));
@@ -275,7 +290,7 @@ static int hp_cpu_offline_func(int argc, char *argv[])
}
cpu = atoi(argv[0]);
printf("Prepare to offline CPU %d\n", cpu);
- ret = xc_cpu_offline(xch, cpu);
+ ret = exec_cpu_hp_fn(xc_cpu_offline, cpu);
if (ret < 0)
fprintf(stderr, "CPU %d offline failed (error %d: %s)\n",
cpu, errno, strerror(errno));