From: Oleg Nesterov Date: Mon, 1 Dec 2014 21:34:17 +0000 (+0100) Subject: x86/ticketlock: Fix spin_unlock_wait() livelock X-Git-Tag: omap-for-v3.19/fixes-rc1~169^2 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78bff1c8684f;p=pandora-kernel.git x86/ticketlock: Fix spin_unlock_wait() livelock arch_spin_unlock_wait() looks very suboptimal, to the point I think this is just wrong and can lead to livelock: if the lock is heavily contended we can never see head == tail. But we do not need to wait for arch_spin_is_locked() == F. If it is locked we only need to wait until the current owner drops this lock. So we could simply spin until old_head != lock->tickets.head in this case, but .head can overflow and thus we can't check "unlocked" only once before the main loop. Also, the "unlocked" check can ignore TICKET_SLOWPATH_FLAG bit. Signed-off-by: Oleg Nesterov Acked-by: Linus Torvalds Cc: Jeremy Fitzhardinge Cc: Paul E.McKenney Cc: Peter Zijlstra Cc: Waiman Long Link: http://lkml.kernel.org/r/20141201213417.GA5842@redhat.com Signed-off-by: Ingo Molnar --- Reading git-diff-tree failed