From patchwork Sat Apr 30 03:33:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 8986501 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1BFB69F46D for ; Sat, 30 Apr 2016 03:35:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FD99201CE for ; Sat, 30 Apr 2016 03:35:48 +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 C4814201CD for ; Sat, 30 Apr 2016 03:35:47 +0000 (UTC) Received: from localhost ([::1]:57168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awLh1-0006nu-Oz for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Apr 2016 23:35:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awLfJ-0003tw-3s for qemu-devel@nongnu.org; Fri, 29 Apr 2016 23:34:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awLf7-000058-EA for qemu-devel@nongnu.org; Fri, 29 Apr 2016 23:33:51 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:38744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awLf6-0008TP-66 for qemu-devel@nongnu.org; Fri, 29 Apr 2016 23:33:45 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6879A20A0E for ; Fri, 29 Apr 2016 23:33:20 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Fri, 29 Apr 2016 23:33:20 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=pn4Lkl703x0h4ln9O8/TZmilIHM=; b=KJe817 g05i7nNIADJxhac9xo43nh4GSSfoaTHsg9rNms7Y7h7Ivnhdhu5bxEsyI/qlACW9 c3el0pTi1JtF5PNY4/Y3j9DrMB4KpLyp3F3nNPuE+6dSz59FmRfiKXc/f0+EA46a Q6hKEMmcF05MQ6qc8cCVtj3vv0ACtUUOWOUAI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=pn4Lkl703x0h4ln 9O8/TZmilIHM=; b=cBLeeJcuJY/KHrB6njGkBOCkCKvx660Q0XZZnmA06h80L7c HjgO3fUzP9E7BkU84doHyns2ky7Em2MTEgzhm2RbR+29ov/wc9cET6lA6P2Aw4/a NnGIs9o2A0pQffKHsKFcWqTRHghZL1gEvXjbgyQlL7cxKdfLOD2CD6TG8K+Y= X-Sasl-enc: 4Gb/frh50kj/JVE0s7aSqaZpqDw4l1XFL9N1MIfvdFwL 1461987200 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 20752C00012; Fri, 29 Apr 2016 23:33:20 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers , MTTCG Devel Date: Fri, 29 Apr 2016 23:33:07 -0400 Message-Id: <1461987197-31264-5-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461987197-31264-1-git-send-email-cota@braap.org> References: <1461987197-31264-1-git-send-email-cota@braap.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH v4 04/14] 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: Paolo Bonzini , Sergey Fedorov , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Crosthwaite 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 Reviewed-by: Alex Bennée 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 */