From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A801042937; Thu, 13 Apr 2023 23:26:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C13141138; Thu, 13 Apr 2023 23:26:07 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9D73A410F9 for ; Thu, 13 Apr 2023 23:26:05 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id E77622179268; Thu, 13 Apr 2023 14:26:04 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E77622179268 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1681421164; bh=O5hiIXhRzjksf2MgniKIdh+Pdoydf6xE/rYxi0V3rb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hh3iljKsTyAQfrOaiUVDuMdescKnwyiBj3F+CjwtlrFIIm2o8txOBVNC21dcOOafr BXkXpeqWXzX+3ARzYBQt4MebZStsAck31yuWa5jw942Hr2LDnPVcoVqTda08FtAh/B Z0NptZHkO25CJumFhyco2YELV0r918Nngsq8dtW8= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, konstantin.ananyev@huawei.com, Tyler Retzlaff Subject: [PATCH v5 02/14] eal: use rtm and xtest intrinsics Date: Thu, 13 Apr 2023 14:25:51 -0700 Message-Id: <1681421163-18578-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1681421163-18578-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> <1681421163-18578-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Inline assembly is not supported for MSVC x64. Convert code to use _xend, _xabort and _xtest intrinsics. Signed-off-by: Tyler Retzlaff Acked-by: Bruce Richardson Acked-by: Konstantin Ananyev --- config/x86/meson.build | 6 ++++++ lib/eal/x86/include/rte_rtm.h | 18 +++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/config/x86/meson.build b/config/x86/meson.build index 54345c4..4c0b06c 100644 --- a/config/x86/meson.build +++ b/config/x86/meson.build @@ -30,6 +30,12 @@ if cc.get_define('__SSE4_2__', args: machine_args) == '' machine_args += '-msse4' endif +# enable restricted transactional memory intrinsics +# https://gcc.gnu.org/onlinedocs/gcc/x86-transactional-memory-intrinsics.html +if cc.get_id() != 'msvc' + machine_args += '-mrtm' +endif + base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2'] foreach f:base_flags compile_time_cpuflags += ['RTE_CPUFLAG_' + f] diff --git a/lib/eal/x86/include/rte_rtm.h b/lib/eal/x86/include/rte_rtm.h index 36bf498..b84e58e 100644 --- a/lib/eal/x86/include/rte_rtm.h +++ b/lib/eal/x86/include/rte_rtm.h @@ -5,6 +5,7 @@ #ifndef _RTE_RTM_H_ #define _RTE_RTM_H_ 1 +#include /* Official RTM intrinsics interface matching gcc/icc, but works on older gcc compatible compilers and binutils. */ @@ -28,31 +29,22 @@ static __rte_always_inline unsigned int rte_xbegin(void) { - unsigned int ret = RTE_XBEGIN_STARTED; - - asm volatile(".byte 0xc7,0xf8 ; .long 0" : "+a" (ret) :: "memory"); - return ret; + return _xbegin(); } static __rte_always_inline void rte_xend(void) { - asm volatile(".byte 0x0f,0x01,0xd5" ::: "memory"); + _xend(); } /* not an inline function to workaround a clang bug with -O0 */ -#define rte_xabort(status) do { \ - asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory"); \ -} while (0) +#define rte_xabort(status) _xabort(status) static __rte_always_inline int rte_xtest(void) { - unsigned char out; - - asm volatile(".byte 0x0f,0x01,0xd6 ; setnz %0" : - "=r" (out) :: "memory"); - return out; + return _xtest(); } #ifdef __cplusplus -- 1.8.3.1