Received: from eggs.gnu.org ([2001:4830:134:3::10]:48306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEx9-0000yN-QA for qemu-devel@nongnu.org; Thu, 07 Apr 2016 14:46:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoEuD-00086Y-6k for qemu-devel@nongnu.org; Thu, 07 Apr 2016 14:43:51 -0400 Received: from lists.gnu.org ([2001:4830:134:3::11]:39439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEuD-00086T-3X for qemu-devel@nongnu.org; Thu, 07 Apr 2016 14:43:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEAO-0002gq-Jd for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoDnR-0003Wn-JL for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:32:48 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:59823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoDnR-0003WD-Er for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:32:45 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 9FD2E20CF3 for ; Thu, 7 Apr 2016 13:32:44 -0400 (EDT) From: "Emilio G. Cota" Date: Thu, 7 Apr 2016 13:32:32 -0400 Message-Id: <1460050358-25025-8-git-send-email-cota@braap.org> In-Reply-To: <1460050358-25025-1-git-send-email-cota@braap.org> References: <1460050358-25025-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [PATCH v2 07/13] qemu-thread: call cpu_relax() while spinning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers , MTTCG Devel Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Peter Maydell , Sergey Fedorov Signed-off-by: Emilio G. Cota --- include/qemu/thread.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index 1aa843b..599965e 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -2,6 +2,7 @@ #define __QEMU_THREAD_H 1 #include +#include "qemu/processor.h" #include "qemu/atomic.h" typedef struct QemuMutex QemuMutex; @@ -74,7 +75,9 @@ static inline void qemu_spin_init(QemuSpin *spin) static inline void qemu_spin_lock(QemuSpin *spin) { do { - while (atomic_read(&spin->value)); + while (atomic_read(&spin->value)) { + cpu_relax(); + } } while (atomic_xchg(&spin->value, true)); } -- 2.5.0