From 5140eb165f0f16a79c9022e4770d170d0b8b68f8 Mon Sep 17 00:00:00 2001 From: Intel Date: Wed, 18 Sep 2013 12:00:00 +0200 Subject: [PATCH] eal: use pause only with SSE2 The pause instruction is part of SSE2 extensions. Note that some compilers define _mm_pause as "rep; nop" instead of "pause". For compatible processors, they are equivalent. http://www.intel.com/Assets/PDF/manual/325383.pdf: " When executing a spin-wait loop, a Pentium 4 or Intel Xeon processor suffers a severe performance penalty when exiting the loop because it detects a possible memory order violation. The PAUSE instruction provides a hint to the processor that the code sequence is a spin-wait loop. The processor uses this hint to avoid the memory order violation in most situations, which greatly improves processor performance. " Signed-off-by: Intel --- lib/librte_eal/common/include/rte_common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index ca7e3aa4f9..236f98a91a 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -49,7 +49,6 @@ extern "C" { #include #include #include -#include /*********** Macros to eliminate unused variable warnings ********/ @@ -250,6 +249,8 @@ rte_align32pow2(uint32_t x) /*********** Other general functions / macros ********/ +#ifdef __SSE2__ +#include /** * PAUSE instruction for tight loops (avoid busy waiting) */ @@ -258,6 +259,10 @@ rte_pause (void) { _mm_pause(); } +#else +static inline void +rte_pause(void) {} +#endif /** * Searches the input parameter for the least significant set bit -- 2.20.1