読者です 読者をやめる 読者になる 読者になる

inconsistent lock state

Debug Hacksの発売日がYLUGのメールでは25日に発売ってメールがあったけど、
amazonだと27日になってたので取り合えず有隣堂に行ったが売ってなかったorz

昨日、カーネルをビルドしているときにふとdmesgコマンドをつかったら出ていたログ。

[ 5403.140662] 
[ 5403.140664] =================================
[ 5403.140670] [ INFO: inconsistent lock state ]
[ 5403.140674] 2.6.30-rc3-x86tip-tip #1
[ 5403.140677] ---------------------------------
[ 5403.140679] inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-W} usage.
[ 5403.140683] kswapd0/260 [HC0[0]:SC0[0]:HE1:SE1] takes:
[ 5403.140686]  (&inode->inotify_mutex){+.+.?.}, at: [] inotify_inode_is_dead+0x29/0x8a
[ 5403.140698] {RECLAIM_FS-ON-W} state was registered at:
[ 5403.140701]   [] 0xffffffffffffffff
[ 5403.140721] irq event stamp: 1193443
[ 5403.140723] hardirqs last  enabled at (1193443): [] __call_rcu+0xfe/0x110
[ 5403.140731] hardirqs last disabled at (1193442): [] __call_rcu+0x34/0x110
[ 5403.140737] softirqs last  enabled at (1192044): [] call_softirq+0x1c/0x30
[ 5403.140744] softirqs last disabled at (1192039): [] call_softirq+0x1c/0x30
[ 5403.140750] 
[ 5403.140751] other info that might help us debug this:
[ 5403.140754] 2 locks held by kswapd0/260:
[ 5403.140756]  #0:  (shrinker_rwsem){++++..}, at: [] shrink_slab+0x35/0x153
[ 5403.140764]  #1:  (&type->s_umount_key#16){++++.+}, at: [] shrink_dcache_memory+0xb2/0x18c
[ 5403.140774] 
[ 5403.140775] stack backtrace:
[ 5403.140778] Pid: 260, comm: kswapd0 Not tainted 2.6.30-rc3-x86tip-tip #1
[ 5403.140781] Call Trace:
[ 5403.140788]  [] ? valid_state+0x170/0x181
[ 5403.140793]  [] ? check_usage_forwards+0x0/0x4d
[ 5403.140797]  [] ? mark_lock+0xfa/0x20a
[ 5403.140802]  [] ? __lock_acquire+0x33c/0xc34
[ 5403.140807]  [] ? register_lock_class+0x20/0x34e
[ 5403.140812]  [] ? lock_acquire+0xc9/0xf5
[ 5403.140816]  [] ? inotify_inode_is_dead+0x29/0x8a
[ 5403.140821]  [] ? inotify_inode_is_dead+0x29/0x8a
[ 5403.140827]  [] ? __mutex_lock_common+0x46/0x39c
[ 5403.140831]  [] ? inotify_inode_is_dead+0x29/0x8a
[ 5403.140837]  [] ? native_sched_clock+0x2e/0x5b
[ 5403.140841]  [] ? inotify_inode_is_dead+0x29/0x8a
[ 5403.140845]  [] ? dentry_iput+0x7f/0xc5
[ 5403.140849]  [] ? d_kill+0x4c/0x6d
[ 5403.140853]  [] ? __shrink_dcache_sb+0x2ae/0x347
[ 5403.140858]  [] ? shrink_dcache_memory+0xeb/0x18c
[ 5403.140862]  [] ? shrink_slab+0xe0/0x153
[ 5403.140866]  [] ? kswapd+0x4ae/0x63d
[ 5403.140873]  [] ? isolate_pages_global+0x0/0x22c
[ 5403.140877]  [] ? autoremove_wake_function+0x0/0x2e
[ 5403.140882]  [] ? trace_hardirqs_on_caller+0x11d/0x140
[ 5403.140886]  [] ? kswapd+0x0/0x63d
[ 5403.140891]  [] ? kthread+0x54/0x80
[ 5403.140895]  [] ? trace_hardirqs_on_thunk+0x3a/0x3f
[ 5403.140900]  [] ? child_rip+0xa/0x20
[ 5403.140906]  [] ? finish_task_switch+0x36/0x127
[ 5403.140911]  [] ? restore_args+0x0/0x30
[ 5403.140915]  [] ? cpuacct_charge+0x17/0x98
[ 5403.140919]  [] ? schedule+0xf9/0x7b6
[ 5403.140924]  [] ? _spin_unlock+0x17/0x20
[ 5403.140928]  [] ? kthread+0x0/0x80
[ 5403.140932]  [] ? child_rip+0x0/0x20

valid_state()はkernel/lockdep.cにいて、変なビットがセットされてたら上のようなエラーメッセージを表示する。
カーネルのビルドはよくするけどこんなのは初めて見たo( ̄ー ̄;)ゞ
通常はmakeの-jオプションに2をしているけど昨日は5でやってみたからそれが関係あんのかな?

inotify_inode_is_dead()はfs/notifyのinotify.cに存在

/**
 * inotify_inode_is_dead - an inode has been deleted, cleanup any watches
 * @inode: inode that is about to be removed
 */
void inotify_inode_is_dead(struct inode *inode)
{
	struct inotify_watch *watch, *next;

	mutex_lock(&inode->inotify_mutex);
	list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
		struct inotify_handle *ih = watch->ih;
		mutex_lock(&ih->mutex);
		inotify_remove_watch_locked(ih, watch);
		mutex_unlock(&ih->mutex);
	}
	mutex_unlock(&inode->inotify_mutex);
}
EXPORT_SYMBOL_GPL(inotify_inode_is_dead);

細かいところまでみてないので、原因なんかはまったくわからないけど(T△T)
カーネルの動きを勉強すると言う意味では良い題材かも。