]> git.baikalelectronics.ru Git - kernel.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>
Fri, 24 Feb 2012 19:59:59 +0000 (11:59 -0800)
commit555ef07e56394ade1b9795e05ce35db83b53c5fd
tree65f1f8fc6817dd0c0c0a626b437d46b1ee826671
parent6de4a57954a5b98612a7ff3299976b758c8a5f50
staging: zcache: avoid AB-BA deadlock condition

Commit 959c817 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>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/zcache/zcache-main.c