From patchwork Wed Apr 20 17:32:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 8893701 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 052FABF29F for ; Wed, 20 Apr 2016 17:32:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A4D2201F2 for ; Wed, 20 Apr 2016 17:32:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B256201C8 for ; Wed, 20 Apr 2016 17:32:16 +0000 (UTC) Received: from localhost ([::1]:53264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asvz5-0008RR-EI for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Apr 2016 13:32:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asvyx-0008Na-Pm for qemu-devel@nongnu.org; Wed, 20 Apr 2016 13:32:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asvyt-0002dP-QN for qemu-devel@nongnu.org; Wed, 20 Apr 2016 13:32:07 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:39329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asvyt-0002dJ-MU for qemu-devel@nongnu.org; Wed, 20 Apr 2016 13:32:03 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7DB0A209F3 for ; Wed, 20 Apr 2016 13:32:03 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 20 Apr 2016 13:32:03 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=f/NSlM55dvPht0ukEL7eYbKF0jg =; b=MrtF/kv60kL57tOdDPG0uXcFsoimQDlmgKmpGLzWN7Hp7FzRAyX2rvtWu2v VcyCzGLWJFPDn5vhoVPneIn9iow0X05WIC8RBFkN2l95AYX2yX59JyynSJpk2pE2 vmpyYsn9eaBinAsIehFtwnNtxk01umIMhh4Tc8aU7aHa8bM0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=f/NS lM55dvPht0ukEL7eYbKF0jg=; b=P4A3UlD0ytMF9Rdc88pFuw+Lp18umopo9Az/ BZLwLeGzkrTWwgUNW+q1Usk4f8zF1uJeEqSUMMfAedeg8yQXQ21OS5qbCjkYVV1b aVU1WLrwdj+RN2yEMIy8AJKy4+vDIunZhF7ZwRyymCE2krnJIoJ9g49O3L8fxiZP jxgwV74= X-Sasl-enc: 2tNibLC368cEEe/AgOUg0js0pGNvrqceOOXN5F3P/eHR 1461173523 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 18AB1C00017; Wed, 20 Apr 2016 13:32:03 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers , MTTCG Devel Date: Wed, 20 Apr 2016 13:32:02 -0400 Message-Id: <1461173522-20980-1-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461107270-19234-5-git-send-email-cota@braap.org> References: <1461107270-19234-5-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.26 Subject: [Qemu-devel] [UPDATED v3 04/11] include/processor.h: define cpu_relax() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Peter Crosthwaite , Sergey Fedorov , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Taken from the linux kernel. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/qemu/processor.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 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..4e6a71f --- /dev/null +++ b/include/qemu/processor.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016, Emilio G. Cota + * + * License: GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ +#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 */