lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1626747709-34013-4-git-send-email-linyunsheng@huawei.com>
Date:   Tue, 20 Jul 2021 10:21:48 +0800
From:   Yunsheng Lin <linyunsheng@...wei.com>
To:     <davem@...emloft.net>, <kuba@...nel.org>, <mst@...hat.com>,
        <jasowang@...hat.com>
CC:     <nickhu@...estech.com>, <green.hu@...il.com>,
        <deanbo422@...il.com>, <akpm@...ux-foundation.org>,
        <yury.norov@...il.com>, <andriy.shevchenko@...ux.intel.com>,
        <ojeda@...nel.org>, <ndesaulniers@...ogle.com>, <joe@...ches.com>,
        <linux-kernel@...r.kernel.org>,
        <virtualization@...ts.linux-foundation.org>,
        <netdev@...r.kernel.org>, <linuxarm@...neuler.org>
Subject: [PATCH v2 3/4] tools headers UAPI: add cpu_relax() implementation for x86 and arm64

As x86 and arm64 is the two available systems that I can build
and test the cpu_relax() implementation, so only add cpu_relax()
implementation for x86 and arm64, other arches can be added easily
when needed.

Signed-off-by: Yunsheng Lin <linyunsheng@...wei.com>
---
 tools/include/asm/processor.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 tools/include/asm/processor.h

diff --git a/tools/include/asm/processor.h b/tools/include/asm/processor.h
new file mode 100644
index 0000000..f9b3902
--- /dev/null
+++ b/tools/include/asm/processor.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __TOOLS_LINUX_ASM_PROCESSOR_H
+#define __TOOLS_LINUX_ASM_PROCESSOR_H
+
+#if defined(__i386__) || defined(__x86_64__)
+/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
+static __always_inline void rep_nop(void)
+{
+	asm volatile("rep; nop" ::: "memory");
+}
+
+static __always_inline void cpu_relax(void)
+{
+	rep_nop();
+}
+#elif defined(__aarch64__)
+static inline void cpu_relax(void)
+{
+	asm volatile("yield" ::: "memory");
+}
+#else
+#error "Architecture not supported"
+#endif
+
+#endif
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ