From: BVK Chaitanya <bayapuneni_chaitanya@symantec.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: Xen-devel@lists.xensource.com
Subject: Re: [PATCH] serialize suspend-resume process
Date: Thu, 31 Jul 2008 20:57:35 +0530 [thread overview]
Message-ID: <4891D9E7.70602@symantec.com> (raw)
In-Reply-To: <C4B78C8C.24ED9%keir.fraser@eu.citrix.com>
Hi Keir,
diff -r 44e3ace9a1f1 drivers/xen/core/reboot.c
--- a/drivers/xen/core/reboot.c Thu Jul 31 09:46:58 2008 +0100
+++ b/drivers/xen/core/reboot.c Fri Aug 01 04:14:43 2008 +0530
@@ -108,6 +116,31 @@ static int xen_suspend(void *__unused)
return 0;
}
+static void switch_shutdown_state(int new_state)
+{
+ int prev_state, old_state = SHUTDOWN_INVALID;
+
+ /* We only drive shutdown_state into an active state. */
+ if (new_state == SHUTDOWN_INVALID)
+ return;
+
+ do {
+ /* We drop this transition if already in an active state. */
+ if ((old_state != SHUTDOWN_INVALID) &&
+ (old_state != SHUTDOWN_RESUMING))
+ return;
+ /* Attempt to transition. */
+ prev_state = old_state;
+ old_state = cmpxchg(&shutting_down, old_state, new_state);
+ } while (old_state != prev_state);
+
+ /* Either we kick off the work, or we leave it to xen_suspend(). */
+ if (old_state == SHUTDOWN_INVALID)
+ schedule_work(&shutdown_work);
+ else
+ BUG_ON(old_state != SHUTDOWN_RESUMING);
+}
+
static void __shutdown_handler(void *unused)
{
int err;
It is doing a busy-wait loop till suspend-resume cycle completes, if
any. I found that it may go more than 25 msec sometimes.
@@ -220,26 +247,24 @@ static struct xenbus_watch sysrq_watch =
static irqreturn_t suspend_int(int irq, void* dev_id, struct pt_regs
*ptregs)
{
- shutting_down = SHUTDOWN_SUSPEND;
- schedule_work(&shutdown_work);
-
+ switch_shutdown_state(SHUTDOWN_SUSPEND);
return IRQ_HANDLED;
}
And you are calling the above busy-wait loop from within an irq handler.
AFAIK it runs in interrupt-context and might cause dead-lock on
uniprocessor setups (especially if underlying process context belongs to
suspend thread itself).
regards,
--
bvk-chaitanya
next prev parent reply other threads:[~2008-07-31 15:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-31 11:09 [PATCH] serialize suspend-resume process BVK Chaitanya
2008-07-31 11:17 ` Keir Fraser
2008-07-31 11:57 ` BVK Chaitanya
2008-07-31 12:23 ` Keir Fraser
2008-07-31 13:04 ` BVK Chaitanya
2008-07-31 13:07 ` Keir Fraser
2008-07-31 13:34 ` BVK Chaitanya
2008-07-31 13:46 ` Keir Fraser
2008-07-31 14:10 ` BVK Chaitanya
2008-07-31 14:12 ` Neil Turton
2008-07-31 14:36 ` Keir Fraser
2008-07-31 15:27 ` BVK Chaitanya [this message]
2008-07-31 15:24 ` Keir Fraser
2008-08-01 5:31 ` BVK Chaitanya
2008-08-01 5:58 ` BVK Chaitanya
2008-08-01 8:01 ` Keir Fraser
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=4891D9E7.70602@symantec.com \
--to=bayapuneni_chaitanya@symantec.com \
--cc=Xen-devel@lists.xensource.com \
--cc=keir.fraser@eu.citrix.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.