[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] Fix potential kthread deadlock during Xen suspend.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1189155842 -3600
# Node ID 1e2284d885fbe9fc0f18143ccce7fdcc30788e94
# Parent  f30b59f550c2ac03734c7a8cb63f658f16ca087a
Fix potential kthread deadlock during Xen suspend.

kthread_create() depends on keventd, so it cannot be executed from
keventd. Replace use of kthread_create() with an approach based on
kernel_thread().

Based on an original patch by:
 Signed-off-by: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
 Signed-off-by: Robert Phillips <rphillips@xxxxxxxxxxxxxxx>

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 drivers/xen/core/reboot.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)

diff -r f30b59f550c2 -r 1e2284d885fb drivers/xen/core/reboot.c
--- a/drivers/xen/core/reboot.c Fri Aug 31 10:45:38 2007 +0100
+++ b/drivers/xen/core/reboot.c Fri Sep 07 10:04:02 2007 +0100
@@ -8,7 +8,6 @@
 #include <asm/hypervisor.h>
 #include <xen/xenbus.h>
 #include <linux/kmod.h>
-#include <linux/kthread.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 
@@ -68,36 +67,31 @@ static int shutdown_process(void *__unus
 
 static int xen_suspend(void *__unused)
 {
-       int err = __xen_suspend(fast_suspend);
+       int err;
+
+       daemonize("suspend");
+       err = set_cpus_allowed(current, cpumask_of_cpu(0));
+       if (err) {
+               printk(KERN_ERR "Xen suspend can't run on CPU0 (%d)\n", err);
+               goto out;
+       }
+
+       err = __xen_suspend(fast_suspend);
        if (err)
                printk(KERN_ERR "Xen suspend failed (%d)\n", err);
+
+ out:
        shutting_down = SHUTDOWN_INVALID;
        return 0;
 }
 
-static int kthread_create_on_cpu(int (*f)(void *arg),
-                                void *arg,
-                                const char *name,
-                                int cpu)
-{
-       struct task_struct *p;
-       p = kthread_create(f, arg, name);
-       if (IS_ERR(p))
-               return PTR_ERR(p);
-       kthread_bind(p, cpu);
-       wake_up_process(p);
-       return 0;
-}
-
 static void __shutdown_handler(void *unused)
 {
        int err;
 
-       if (shutting_down != SHUTDOWN_SUSPEND)
-               err = kernel_thread(shutdown_process, NULL,
-                                   CLONE_FS | CLONE_FILES);
-       else
-               err = kthread_create_on_cpu(xen_suspend, NULL, "suspend", 0);
+       err = kernel_thread((shutting_down == SHUTDOWN_SUSPEND) ?
+                           xen_suspend : shutdown_process,
+                           NULL, CLONE_FS | CLONE_FILES);
 
        if (err < 0) {
                printk(KERN_WARNING "Error creating shutdown process (%d): "

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.