]> git.karo-electronics.de Git - karo-tx-linux.git/commit
staging: zcache: avoid AB-BA deadlock condition
authorAndrea Righi <andrea@betterlinux.com>
Mon, 20 Feb 2012 12:11:49 +0000 (13:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Apr 2012 16:52:08 +0000 (09:52 -0700)
commit32c5edbdda0e9737b0667036ef1210eb0284c54b
treeb0981192f7860c1ea20bb5ceccf8ed93c1d75fff
parent0bd61423aaaa167455003c48b8c3d1f2b9dcc19d
staging: zcache: avoid AB-BA deadlock condition

commit cfbc6a92212e74b07aa76c9e2f20c542e36077fb upstream.

Commit 9256a47 fixed a deadlock condition, being sure that the buddy
list spinlock is always taken before the page spinlock.

However in zbud_free_and_delist() locking order is the opposite
(page lock -> list lock).

Possible unsafe locking scenario (reported by lockdep):

        CPU0                    CPU1
        ----                    ----
   lock(&(&zbpg->lock)->rlock);
                                lock(zbud_budlists_spinlock);
                                lock(&(&zbpg->lock)->rlock);
   lock(zbud_budlists_spinlock);

Fix by grabbing the locks in opposite order in zbud_free_and_delist().

Signed-off-by: Andrea Righi <andrea@betterlinux.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/zcache/zcache-main.c