瀏覽代碼

lockref: Relax in cmpxchg loop

While we are likley to succeed and break out of this loop, it isn't
guaranteed.  We should be power and thread friendly if we do have to
go around for a second (or third, or more) attempt.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Luck, Tony 12 年之前
父節點
當前提交
d472d9d98b
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      lib/lockref.c

+ 1 - 0
lib/lockref.c

@@ -19,6 +19,7 @@
 		if (likely(old.lock_count == prev.lock_count)) {		\
 		if (likely(old.lock_count == prev.lock_count)) {		\
 			SUCCESS;						\
 			SUCCESS;						\
 		}								\
 		}								\
+		cpu_relax();							\
 	}									\
 	}									\
 } while (0)
 } while (0)