From patchwork Fri Jun 10 14:26:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 633762 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rR4Kc5X4Dz9sXR for ; Sat, 11 Jun 2016 00:28:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=CDZUJfH3; dkim-atps=neutral Received: from localhost ([::1]:41411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNQI-0005Ev-LS for incoming@patchwork.ozlabs.org; Fri, 10 Jun 2016 10:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNOp-0003ec-SW for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBNOk-0005gN-7P for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:02 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNOk-0005gA-1O for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:26:58 -0400 Received: by mail-pf0-x242.google.com with SMTP id t190so5238235pfb.2 for ; Fri, 10 Jun 2016 07:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=skPzWfVCwmMchKMxLqEDiEv+DU6DSx0JHfgAnh+eLZ0=; b=CDZUJfH3SCk1yEN878KmOIlN6GznYCHcfPpQ8psbtqmmJK18ymdZ549taaTea7pNfd JfZ3b5qTyuERHqSusg0FzAhl41g5RHS4l3wCJ43OAaWWs2CpfTuNWYGFDdmFiYf3HbcR xkxvTXgGlAt8m/r+AivM+K4cj8cplAwNRoYE3NkC999f5zQvzi4S0LaF4b3QarYj3MKd ffBiwihI5sef0Dqxm0Jj0ULSJ0NW1E2AyFT/abwbnMsu8S467IrDXvL8Yw8bgcmwIZ9y hMoyHz1FZ7DrEK5xIXi0SOLNxuaSo3L5s6kLOXBKVN/g/GaO6ThRdabWUBxY1gsJOaHK pBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=skPzWfVCwmMchKMxLqEDiEv+DU6DSx0JHfgAnh+eLZ0=; b=fqpbulZd2XPgrQYzQlbk7SCxod7lYXo0P/i6/jqAclXbPJNqYTFnyyeDj1WDTWT84d hN4vciuVO352l3hYSFZED5NLWC5Akmueef4kRjHrtxjiR+2fk3FYgsXwVtJnZMeSiphy NYoGm/1PxeVGQjdK5wfQ6uQ5UpD0ed3+iw+PYAEs1wD+LeKkuPz8R/W5raCiBE9gJESf XMj6L1bKqhNR8JHG8pgkv5QjSZQP3PIt6rcJg/rNh/x6Eff7j87g1UdDXrMlBT7HRH08 MPjmqRa9kAbcG+rO31GQAjdSf1OmAnQ/DqRXoNkUytvf5T25ov8xFRLlzoMGMZq4Ydbf IdNA== X-Gm-Message-State: ALyK8tIFlnlbch/fXcbUprD5NdBGV3QFAkjR4GdHSMkE45PTXo46Fg8CDKkC4o7wNsackw== X-Received: by 10.98.31.140 with SMTP id l12mr2605574pfj.51.1465568817410; Fri, 10 Jun 2016 07:26:57 -0700 (PDT) Received: from anchor.twiddle.net (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id vy8sm18227219pab.22.2016.06.10.07.26.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 07:26:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 Jun 2016 07:26:42 -0700 Message-Id: <1465568813-19771-5-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465568813-19771-1-git-send-email-rth@twiddle.net> References: <1465568813-19771-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 04/15] 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@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Taken from the linux kernel. Reviewed-by: Sergey Fedorov Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Message-Id: <1465412133-3029-5-git-send-email-cota@braap.org> Signed-off-by: Richard Henderson --- include/qemu/processor.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 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..42bcc99 --- /dev/null +++ b/include/qemu/processor.h @@ -0,0 +1,30 @@ +/* + * 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") + +#elif defined(__ia64__) +# define cpu_relax() asm volatile("hint @pause" ::: "memory") + +#elif defined(__aarch64__) +# define cpu_relax() asm volatile("yield" ::: "memory") + +#elif 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") + +#else +# define cpu_relax() barrier() +#endif + +#endif /* QEMU_PROCESSOR_H */