浏览代码

Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  mutex: Fix optimistic spinning vs. BKL
Linus Torvalds 15 年之前
父节点
当前提交
fa7eadab4b
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      kernel/mutex.c

+ 7 - 0
kernel/mutex.c

@@ -171,6 +171,13 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 	for (;;) {
 		struct thread_info *owner;
 
+		/*
+		 * If we own the BKL, then don't spin. The owner of
+		 * the mutex might be waiting on us to release the BKL.
+		 */
+		if (unlikely(current->lock_depth >= 0))
+			break;
+
 		/*
 		 * If there's an owner, wait for it to either
 		 * release the lock or go to sleep.