From: Ben Guthro <bguthro@virtualiron.com>
To: xen-devel@lists.xensource.com
Cc: Robert Phillips <rphillips@virtualiron.com>
Subject: [PV-onHVM][linux-2.6.18-xen.hg][PATCH 1/3] Fix kthread_create
Date: Thu, 06 Sep 2007 13:43:47 -0400 [thread overview]
Message-ID: <46E03C53.2010105@virtualiron.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 340 bytes --]
This patch fixes live migration with PV-on-HVM drivers.
Without this, the kthread_create of the thread to run xen_suspend hangs
forever (at least on RHEL4 64bit).
The comments in the patch explain the problem in more detail.
Signed-off-by: Ben Guthro <bguthro@virtualiron.com>
Signed-off-by: Robert Phillips <rphillips@virtualiron.com>
[-- Attachment #2: lm-kthread.patch --]
[-- Type: text/x-patch, Size: 2635 bytes --]
diff -r 21dbc5f5a258 drivers/xen/core/reboot.c
--- a/drivers/xen/core/reboot.c Wed Jun 27 11:54:32 2007 -0400
+++ b/drivers/xen/core/reboot.c Wed Jun 27 11:54:43 2007 -0400
@@ -78,6 +78,10 @@ static int kthread_create_on_cpu(int (*f
int cpu)
{
struct task_struct *p;
+ /* NB: kthread_create uses the workqueue and
+ * blocks until the new thread is running,
+ * so it will deadlock if called from the worker thread!
+ */
p = kthread_create(f, arg, name);
if (IS_ERR(p))
return PTR_ERR(p);
@@ -94,7 +98,10 @@ static void __shutdown_handler(void *unu
err = kernel_thread(shutdown_process, NULL,
CLONE_FS | CLONE_FILES);
else
- err = kthread_create_on_cpu(xen_suspend, NULL, "suspend", 0);
+ /* It is safe to call kernel_thread from this
+ * (the worker) thread. */
+ err = kernel_thread(xen_suspend, NULL,
+ CLONE_FS | CLONE_FILES);
if (err < 0) {
printk(KERN_WARNING "Error creating shutdown process (%d): "
@@ -138,8 +145,17 @@ static void shutdown_handler(struct xenb
shutting_down = SHUTDOWN_POWEROFF;
else if (strcmp(str, "reboot") == 0)
ctrl_alt_del();
- else if (strcmp(str, "suspend") == 0)
+ else if (strcmp(str, "suspend") == 0) {
shutting_down = SHUTDOWN_SUSPEND;
+ /* Create new thread from this (the xenwatch) thread.
+ * If called from worker thread, we'll deadlock. */
+ err = kthread_create_on_cpu(xen_suspend, NULL, "suspend", 0);
+ if (err < 0) {
+ printk(KERN_WARNING "Error creating shutdown process (%d): "
+ "retrying...\n", -err);
+ schedule_delayed_work(&shutdown_work, HZ/2);
+ }
+ }
else if (strcmp(str, "halt") == 0)
shutting_down = SHUTDOWN_HALT;
else {
@@ -147,7 +163,8 @@ static void shutdown_handler(struct xenb
shutting_down = SHUTDOWN_INVALID;
}
- if (shutting_down != SHUTDOWN_INVALID)
+ if (shutting_down != SHUTDOWN_INVALID &&
+ shutting_down != SHUTDOWN_SUSPEND)
schedule_work(&shutdown_work);
kfree(str);
diff -r 21dbc5f5a258 drivers/xen/xenbus/xenbus_dev.c
--- a/drivers/xen/xenbus/xenbus_dev.c Wed Jun 27 11:54:32 2007 -0400
+++ b/drivers/xen/xenbus/xenbus_dev.c Wed Jun 27 11:54:35 2007 -0400
@@ -386,7 +386,7 @@ static unsigned int xenbus_dev_poll(stru
return 0;
}
-static const struct file_operations xenbus_dev_file_ops = {
+static struct file_operations xenbus_dev_file_ops = {
.read = xenbus_dev_read,
.write = xenbus_dev_write,
.open = xenbus_dev_open,
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2007-09-06 17:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46E03C53.2010105@virtualiron.com \
--to=bguthro@virtualiron.com \
--cc=rphillips@virtualiron.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.