From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEx6-0000yX-VO 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 1aoEuF-00087j-4P for qemu-devel@nongnu.org; Thu, 07 Apr 2016 14:43:52 -0400 Received: from lists.gnu.org ([2001:4830:134:3::11]:47293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEuF-00087f-27 for qemu-devel@nongnu.org; Thu, 07 Apr 2016 14:43:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEAC-0002g4-ND for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoEAB-0002gy-GM for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:16 -0400 Received: from lists.gnu.org ([2001:4830:134:3::11]:58316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEAB-0002gr-CJ for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEA9-0002gq-Um for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoEA2-0002eL-PP for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:11 -0400 Received: from lists.gnu.org ([2001:4830:134:3::11]:60207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEA2-0002e7-Mu for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoEA1-0002g4-KR for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:56:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoDnR-0003WK-FG for qemu-devel@nongnu.org; Thu, 07 Apr 2016 13:32:48 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:57234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoDnR-0003W1-Bd 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 4E9A321012 for ; Thu, 7 Apr 2016 13:32:44 -0400 (EDT) From: "Emilio G. Cota" Date: Thu, 7 Apr 2016 13:32:30 -0400 Message-Id: <1460050358-25025-6-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 05/13] include/processor.h: define cpu_relax() 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 Taken from the linux kernel. Signed-off-by: Emilio G. Cota --- include/qemu/processor.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/qemu/processor.h diff --git a/include/qemu/processor.h b/include/qemu/processor.h new file mode 100644 index 0000000..675a00a --- /dev/null +++ b/include/qemu/processor.h @@ -0,0 +1,28 @@ +#ifndef QEMU_PROCESSOR_H +#define QEMU_PROCESSOR_H + +#include "qemu/atomic.h" + +#if defined(__i386__) || defined(__x86_64__) +#define cpu_relax() asm volatile("rep; nop" ::: "memory") +#endif + +#ifdef __ia64__ +#define cpu_relax() asm volatile("hint @pause" ::: "memory") +#endif + +#ifdef __aarch64__ +#define cpu_relax() asm volatile("yield" ::: "memory") +#endif + +#if defined(__powerpc64__) +/* set Hardware Multi-Threading (HMT) priority to low; then back to medium */ +#define cpu_relax() asm volatile("or 1, 1, 1;" + "or 2, 2, 2;" ::: "memory") +#endif + +#ifndef cpu_relax +#define cpu_relax() barrier() +#endif + +#endif /* QEMU_PROCESSOR_H */ -- 2.5.0