WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH][Linux] Fix access to xenstore hangs after hotremove

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH][Linux] Fix access to xenstore hangs after hotremove CPU
From: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2007 13:24:47 +0900
Delivery-date: Mon, 26 Nov 2007 20:25:27 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

CPU hotplug doesn't support user-space event channels.

$ echo 0 > /sys/devices/system/cpu/cpu1/online
$ xenstore-ls
... hangs up ...

Attached patch fixes it.

Thanks,
Kouya

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r fd879c0688bf drivers/xen/evtchn/evtchn.c
--- a/drivers/xen/evtchn/evtchn.c       Fri Nov 23 16:26:56 2007 +0000
+++ b/drivers/xen/evtchn/evtchn.c       Tue Nov 27 11:26:51 2007 +0900
@@ -231,6 +231,15 @@ static ssize_t evtchn_write(struct file 
        return rc;
 }
 
+static unsigned int next_bind_cpu(cpumask_t map)
+{
+       static unsigned int bind_cpu;
+       bind_cpu = next_cpu(bind_cpu, map);
+       if (bind_cpu >= NR_CPUS)
+               bind_cpu = first_cpu(map);
+       return bind_cpu;
+}
+
 static void evtchn_bind_to_user(struct per_user_data *u, int port)
 {
        spin_lock_irq(&port_user_lock);
@@ -238,13 +247,8 @@ static void evtchn_bind_to_user(struct p
        BUG_ON(port_user[port] != NULL);
        port_user[port] = u;
 
-       if (u->bind_cpu == -1) {
-               static unsigned int bind_cpu;
-               bind_cpu = next_cpu(bind_cpu, cpu_online_map);
-               if (bind_cpu >= NR_CPUS)
-                       bind_cpu = first_cpu(cpu_online_map);
-               u->bind_cpu = bind_cpu;
-       }
+       if (u->bind_cpu == -1)
+               u->bind_cpu = next_bind_cpu(cpu_online_map);
 
        rebind_evtchn_to_cpu(port, u->bind_cpu);
 
@@ -483,6 +487,42 @@ static struct miscdevice evtchn_miscdev 
        .fops         = &evtchn_fops,
 };
 
+#ifdef CONFIG_HOTPLUG_CPU
+#include <linux/cpu.h>
+
+static int evtchn_cpu_notify(struct notifier_block *nfb,
+                       unsigned long action, void *hcpu)
+{
+       int hotcpu = (unsigned long)hcpu;
+       cpumask_t map = cpu_online_map;
+       int port, newcpu;
+       struct per_user_data *u;
+
+       switch (action) {
+       case CPU_DOWN_PREPARE:
+               cpu_clear(hotcpu, map);
+               spin_lock_irq(&port_user_lock);
+               for (port = 0; port < NR_EVENT_CHANNELS; port++) {
+                       if ((u = port_user[port]) != NULL && 
+                           u->bind_cpu == hotcpu &&
+                           (newcpu = next_bind_cpu(map)) < NR_CPUS) {
+                               rebind_evtchn_to_cpu(port, newcpu);
+                               u->bind_cpu = newcpu;
+                       }
+               }
+               spin_unlock_irq(&port_user_lock);
+               break;
+       default:
+               return NOTIFY_DONE;
+       }
+       return NOTIFY_OK;
+}
+
+static struct notifier_block __cpuinitdata cpu_nfb = {
+       .notifier_call = evtchn_cpu_notify
+};
+#endif
+
 static int __init evtchn_init(void)
 {
        int err;
@@ -502,6 +542,9 @@ static int __init evtchn_init(void)
 
        printk("Event-channel device installed.\n");
 
+#ifdef CONFIG_HOTPLUG_CPU
+       register_cpu_notifier(&cpu_nfb);
+#endif
        return 0;
 }
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>