From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail203.messagelabs.com (mail203.messagelabs.com [216.82.254.243]) by kanga.kvack.org (Postfix) with SMTP id 0E5818D0001 for ; Mon, 25 Oct 2010 06:49:55 -0400 (EDT) Received: from m6.gw.fujitsu.co.jp ([10.0.50.76]) by fgwmail6.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o9PAnqit001783 for (envelope-from kosaki.motohiro@jp.fujitsu.com); Mon, 25 Oct 2010 19:49:52 +0900 Received: from smail (m6 [127.0.0.1]) by outgoing.m6.gw.fujitsu.co.jp (Postfix) with ESMTP id 4AF2845DE52 for ; Mon, 25 Oct 2010 19:49:52 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (s6.gw.fujitsu.co.jp [10.0.50.96]) by m6.gw.fujitsu.co.jp (Postfix) with ESMTP id 1E0DB45DE54 for ; Mon, 25 Oct 2010 19:49:52 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id DFB781DB8013 for ; Mon, 25 Oct 2010 19:49:51 +0900 (JST) Received: from m107.s.css.fujitsu.com (m107.s.css.fujitsu.com [10.249.87.107]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id 8B5441DB8015 for ; Mon, 25 Oct 2010 19:49:51 +0900 (JST) From: KOSAKI Motohiro Subject: mem-hotplug + ksm make lockdep warning Message-Id: <20101025193711.917F.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Mon, 25 Oct 2010 19:49:50 +0900 (JST) Sender: owner-linux-mm@kvack.org To: LKML , linux-mm , Hugh Dickins Cc: kosaki.motohiro@jp.fujitsu.com List-ID: Hi Hugh, commit 62b61f611e(ksm: memory hotremove migration only) makes following lockdep warnings. Is this intentional? More detail: current lockdep hieralcy is here. memory_notify offline_pages lock_system_sleep(); mutex_lock(&pm_mutex); memory_notify(MEM_GOING_OFFLINE) __blocking_notifier_call_chain down_read(memory_chain.rwsem) ksm_memory_callback() mutex_lock(&ksm_thread_mutex); // memory_chain.rmsem -> ksm_thread_mutex order up_read(memory_chain.rwsem) memory_notify(MEM_OFFLINE) __blocking_notifier_call_chain down_read(memory_chain.rwsem) // ksm_thread_mutex -> memory_chain.rmsem order ksm_memory_callback() mutex_unlock(&ksm_thread_mutex); up_read(memory_chain.rwsem) unlock_system_sleep(); mutex_unlock(&pm_mutex); So, I think pm_mutex protect ABBA deadlock. but it exist only when CONFIG_HIBERNATION=y. IOW, this code is not correct generically. Am I missing something? Thanks. ======================================================= [ INFO: possible circular locking dependency detected ] 2.6.36-rc7-mm1+ #148 ------------------------------------------------------- bash/1621 is trying to acquire lock: ((memory_chain).rwsem){.+.+.+}, at: [] __blocking_notifier_call_chain+0x69/0xc0 but task is already holding lock: (ksm_thread_mutex){+.+.+.}, at: [] ksm_memory_callback+0x3a/0xc0 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (ksm_thread_mutex){+.+.+.}: [] lock_acquire+0xaa/0x140 [] __mutex_lock_common+0x44/0x3f0 [] mutex_lock_nested+0x48/0x60 [] ksm_memory_callback+0x3a/0xc0 [] notifier_call_chain+0x8c/0xe0 [] __blocking_notifier_call_chain+0x7e/0xc0 [] blocking_notifier_call_chain+0x16/0x20 [] memory_notify+0x1b/0x20 [] remove_memory+0x1cc/0x5f0 [] memory_block_change_state+0xfd/0x1a0 [] store_mem_state+0xe2/0xf0 [] sysdev_store+0x20/0x30 [] sysfs_write_file+0xe6/0x170 [] vfs_write+0xc8/0x190 [] sys_write+0x54/0x90 [] system_call_fastpath+0x16/0x1b -> #0 ((memory_chain).rwsem){.+.+.+}: [] __lock_acquire+0x155a/0x1600 [] lock_acquire+0xaa/0x140 [] down_read+0x51/0xa0 [] __blocking_notifier_call_chain+0x69/0xc0 [] blocking_notifier_call_chain+0x16/0x20 [] memory_notify+0x1b/0x20 [] remove_memory+0x56e/0x5f0 [] memory_block_change_state+0xfd/0x1a0 [] store_mem_state+0xe2/0xf0 [] sysdev_store+0x20/0x30 [] sysfs_write_file+0xe6/0x170 [] vfs_write+0xc8/0x190 [] sys_write+0x54/0x90 [] system_call_fastpath+0x16/0x1b other info that might help us debug this: 5 locks held by bash/1621: #0: (&buffer->mutex){+.+.+.}, at: [] sysfs_write_file+0x44/0x170 #1: (s_active#110){.+.+.+}, at: [] sysfs_write_file+0xcd/0x170 #2: (&mem->state_mutex){+.+.+.}, at: [] memory_block_change_state+0x38/0x1a0 #3: (pm_mutex){+.+.+.}, at: [] remove_memory+0x129/0x5f0 #4: (ksm_thread_mutex){+.+.+.}, at: [] ksm_memory_callback+0x3a/0xc0 stack backtrace: Pid: 1621, comm: bash Not tainted 2.6.36-rc7-mm1+ #148 Call Trace: [] print_circular_bug+0xeb/0xf0 [] __lock_acquire+0x155a/0x1600 [] ? finish_task_switch+0x79/0xe0 [] ? schedule+0x419/0xa80 [] lock_acquire+0xaa/0x140 [] ? __blocking_notifier_call_chain+0x69/0xc0 [] down_read+0x51/0xa0 [] ? __blocking_notifier_call_chain+0x69/0xc0 [] __blocking_notifier_call_chain+0x69/0xc0 [] ? next_online_pgdat+0x26/0x50 [] blocking_notifier_call_chain+0x16/0x20 [] memory_notify+0x1b/0x20 [] remove_memory+0x56e/0x5f0 [] ? lock_release_non_nested+0x2f8/0x3a0 [] memory_block_change_state+0xfd/0x1a0 [] ? might_fault+0x5c/0xb0 [] store_mem_state+0xe2/0xf0 [] ? sysfs_write_file+0xcd/0x170 [] sysdev_store+0x20/0x30 [] sysfs_write_file+0xe6/0x170 [] vfs_write+0xc8/0x190 [] sys_write+0x54/0x90 [] system_call_fastpath+0x16/0x1b -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org