Ian Campbell
2008-Mar-28 10:26 UTC
[Xen-devel] [PATCH] Linux: Avoid allocations on the resume path which may deadlock due to swap being unavailable.
These two patches avoid a couple of deadlocks when resuming due to swap being unavailable. The blkif_recover patch is simply another case of the issue in 377:e8b49cfbdac0. The thread related one is a bit subtle: the xenbus_watch thread blocks with xenbus_mutex held in kthread_create waiting for the completion to say the thread has been spawned successfully. The thread is stuck waiting on IO due to an attempt to swap while allocating memory in copy_process. This causes the suspend process to block waiting for the xenbus_mutex and therefore the swap device never gets attached. suspend D C02DF2F5 0 14792 1 14772 14790 (L-TLB) c20b5ea8 00000246 00000002 c02df2f5 00000008 c11ba000 00000000 c038aa00 c038aa00 00000000 c3e57660 00000000 00000000 00000009 c3e57550 89c61ba6 00023227 000004b3 c3e57660 c1101960 00000002 89b240b0 89c616f3 00023227 Call Trace: [<c02df2f5>] __mutex_lock_slowpath+0xc5/0x2f0 [<c02df528>] mutex_lock+0x8/0x10 [<c025ef0f>] unregister_xenbus_watch+0x12f/0x1a0 [<c025f82b>] free_otherend_watch+0x1b/0x40 [<c025f869>] talk_to_otherend+0x19/0x40 [<c02608aa>] resume_dev+0x2a/0xd0 [<c0252d54>] bus_for_each_dev+0x54/0x80 [<c02609e4>] xenbus_resume+0x44/0x50 [<c025aa3a>] __xen_suspend+0x9a/0x110 [<c025a1a8>] xen_suspend+0x68/0xd0 [<c0102b55>] kernel_thread_helper+0x5/0x10 blocked waiting to lock xenwatch_mutex in unregister_xenbus_watch: /* Flush any currently-executing callback, unless we are it. :-) */ if (current->pid != xenwatch_pid) { mutex_lock(&xenwatch_mutex); mutex_unlock(&xenwatch_mutex); } the current holder is the xenwatch thread: xenwatch D C02DE102 0 9 7 10 (L-TLB) c11bbee8 00000246 00000002 c02de102 89c366df 00023227 c53e7200 c038aa00 c038aa00 00023227 89c54017 00023227 00000000 0000000a c11b6a70 89c5416d 00023227 00000f8d c11b6b80 c1101960 0000008f 00000000 89c531e0 00023227 Call Trace: [<c02de102>] wait_for_completion+0x82/0xf0 [<c0136c0c>] kthread_create+0x7c/0xd0 [<c025f33b>] xenwatch_thread+0x10b/0x140 [<c0136b86>] kthread+0x106/0x110 [<c0102b55>] kernel_thread_helper+0x5/0x10 and the thread itself: kthread D C02DE736 0 7 1 9 758 6 (L-TLB) c11a9a60 00000246 00000002 c02de736 00000000 c11a9a08 00000003 c038aa00 c038aa00 c11a9ff8 c11bdf80 00000003 00000000 00000009 c1165550 89c616f3 00023227 0000d586 c1165660 c1101960 c01058b1 00000003 89c5416d 00023227 Call Trace: [<c02de736>] io_schedule+0x26/0x30 [<c02226aa>] get_request_wait+0xca/0x110 [<c0223717>] __make_request+0x87/0x3b0 [<c022141a>] generic_make_request+0xea/0x1b0 [<c0223c8b>] submit_bio+0x6b/0x120 [<c015f9ba>] swap_writepage+0x9a/0xc0 [<c014f67a>] shrink_zone+0xefa/0x1080 [<c014ff4a>] try_to_free_pages+0xca/0x1f0 [<c014ad78>] __alloc_pages+0x178/0x2f0 [<c01671fa>] cache_alloc_refill+0x2ea/0x590 [<c0166eff>] kmem_cache_alloc+0x9f/0xb0 [<c011e8c7>] copy_process+0x97/0x1240 [<c011fd5b>] do_fork+0x6b/0x1c0 [<c0102fdb>] kernel_thread+0x8b/0xa0 [<c0136a27>] keventd_create_kthread+0x27/0x80 [<c0132be5>] run_workqueue+0x75/0xf0 [<c0133918>] worker_thread+0x138/0x160 [<c0136b86>] kthread+0x106/0x110 [<c0102b55>] kernel_thread_helper+0x5/0x10 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel