Эх сурвалжийг харах

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: Improve the scalability of optimistic spinning
Linus Torvalds 14 жил өмнө
parent
commit
3b6c5507a6
1 өөрчлөгдсөн 9 нэмэгдсэн , 1 устгасан
  1. 9 1
      kernel/sched.c

+ 9 - 1
kernel/sched.c

@@ -3865,8 +3865,16 @@ int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner)
 		/*
 		/*
 		 * Owner changed, break to re-assess state.
 		 * Owner changed, break to re-assess state.
 		 */
 		 */
-		if (lock->owner != owner)
+		if (lock->owner != owner) {
+			/*
+			 * If the lock has switched to a different owner,
+			 * we likely have heavy contention. Return 0 to quit
+			 * optimistic spinning and not contend further:
+			 */
+			if (lock->owner)
+				return 0;
 			break;
 			break;
+		}
 
 
 		/*
 		/*
 		 * Is that owner really running on that cpu?
 		 * Is that owner really running on that cpu?