All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/manage: Always freeze/thaw processes when suspend/resuming
@ 2014-08-18  9:41 Ross Lagerwall
  2014-08-22 11:00 ` David Vrabel
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Lagerwall @ 2014-08-18  9:41 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Boris Ostrovsky, David Vrabel

Always freeze processes when suspending and thaw processes when resuming
to prevent a race noticeable with HVM guests.

This prevents a deadlock where the khubd kthread (which is designed to
be freezable) acquires a usb device lock and then tries to allocate
memory which requires the disk which hasn't been resumed yet.
Meanwhile, the xenwatch thread deadlocks waiting for the usb device
lock.

Freezing processes fixes this because the khubd thread is only thawed
after the xenwatch thread finishes resuming all the devices.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 drivers/xen/manage.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 5f1e1f3..f8bb36f 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -103,16 +103,11 @@ static void do_suspend(void)
 
 	shutting_down = SHUTDOWN_SUSPEND;
 
-#ifdef CONFIG_PREEMPT
-	/* If the kernel is preemptible, we need to freeze all the processes
-	   to prevent them from being in the middle of a pagetable update
-	   during suspend. */
 	err = freeze_processes();
 	if (err) {
 		pr_err("%s: freeze failed %d\n", __func__, err);
 		goto out;
 	}
-#endif
 
 	err = dpm_suspend_start(PMSG_FREEZE);
 	if (err) {
@@ -157,10 +152,8 @@ out_resume:
 	dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE);
 
 out_thaw:
-#ifdef CONFIG_PREEMPT
 	thaw_processes();
 out:
-#endif
 	shutting_down = SHUTDOWN_INVALID;
 }
 #endif	/* CONFIG_HIBERNATE_CALLBACKS */
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen/manage: Always freeze/thaw processes when suspend/resuming
  2014-08-18  9:41 [PATCH] xen/manage: Always freeze/thaw processes when suspend/resuming Ross Lagerwall
@ 2014-08-22 11:00 ` David Vrabel
  2014-08-22 14:39   ` Ross Lagerwall
  0 siblings, 1 reply; 3+ messages in thread
From: David Vrabel @ 2014-08-22 11:00 UTC (permalink / raw)
  To: Ross Lagerwall, xen-devel; +Cc: Boris Ostrovsky, David Vrabel

On 18/08/14 10:41, Ross Lagerwall wrote:
> Always freeze processes when suspending and thaw processes when resuming
> to prevent a race noticeable with HVM guests.
> 
> This prevents a deadlock where the khubd kthread (which is designed to
> be freezable) acquires a usb device lock and then tries to allocate
> memory which requires the disk which hasn't been resumed yet.
> Meanwhile, the xenwatch thread deadlocks waiting for the usb device
> lock.
> 
> Freezing processes fixes this because the khubd thread is only thawed
> after the xenwatch thread finishes resuming all the devices.

I think this is the safest fix for this issue but I'm a bit concerned
about how much extra time the freeze_processes() call will add to the
suspend.

Can you measure how long it takes for a typical VM?

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen/manage: Always freeze/thaw processes when suspend/resuming
  2014-08-22 11:00 ` David Vrabel
@ 2014-08-22 14:39   ` Ross Lagerwall
  0 siblings, 0 replies; 3+ messages in thread
From: Ross Lagerwall @ 2014-08-22 14:39 UTC (permalink / raw)
  To: David Vrabel, xen-devel; +Cc: Boris Ostrovsky

On 08/22/2014 12:00 PM, David Vrabel wrote:
> On 18/08/14 10:41, Ross Lagerwall wrote:
>> Always freeze processes when suspending and thaw processes when resuming
>> to prevent a race noticeable with HVM guests.
>>
>> This prevents a deadlock where the khubd kthread (which is designed to
>> be freezable) acquires a usb device lock and then tries to allocate
>> memory which requires the disk which hasn't been resumed yet.
>> Meanwhile, the xenwatch thread deadlocks waiting for the usb device
>> lock.
>>
>> Freezing processes fixes this because the khubd thread is only thawed
>> after the xenwatch thread finishes resuming all the devices.
>
> I think this is the safest fix for this issue but I'm a bit concerned
> about how much extra time the freeze_processes() call will add to the
> suspend.
>
> Can you measure how long it takes for a typical VM?
>

With 2 vCPUs and 1024MB RAM, 8ms for freeze_processes() and 6ms for 
thaw_processes().

With 4 vCPUs and 4096MB RAM, 8ms for freeze_processes() and 5ms for 
thaw_processes().

With 4 vCPUs and 4096MB RAM running stress -c 4, 12ms for 
freeze_processes() and 66ms for thaw_processes().

It doesn't seem to take too long...

Cheers
-- 
Ross Lagerwall

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-22 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-18  9:41 [PATCH] xen/manage: Always freeze/thaw processes when suspend/resuming Ross Lagerwall
2014-08-22 11:00 ` David Vrabel
2014-08-22 14:39   ` Ross Lagerwall

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.