[PATCH v2 5/6] drivers: use branch prediction macros
David Marchand
david.marchand at redhat.com
Fri Oct 25 09:04:22 CEST 2024
Prefer EAL macros over __builtin_ helpers.
Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/bus/fslmc/qbman/include/compat.h | 6 ++----
drivers/net/qede/base/bcm_osal.h | 4 +++-
drivers/net/vmxnet3/base/vmxnet3_osdep.h | 4 +++-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/bus/fslmc/qbman/include/compat.h b/drivers/bus/fslmc/qbman/include/compat.h
index ece5da5906..4ac3254bc7 100644
--- a/drivers/bus/fslmc/qbman/include/compat.h
+++ b/drivers/bus/fslmc/qbman/include/compat.h
@@ -16,7 +16,9 @@
#include <malloc.h>
#include <unistd.h>
#include <linux/types.h>
+
#include <rte_atomic.h>
+#include <rte_branch_prediction.h>
/* The following definitions are primarily to allow the single-source driver
* interfaces to be included by arbitrary program code. Ie. for interfaces that
@@ -24,10 +26,6 @@
* with certain attributes and types used in those interfaces.
*/
-/* Required compiler attributes */
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
/* Required types */
typedef uint64_t dma_addr_t;
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index 7869103c63..357981f63d 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -10,7 +10,9 @@
#include <stdbool.h>
#include <pthread.h>
#include <time.h>
+
#include <rte_bitops.h>
+#include <rte_branch_prediction.h>
#include <rte_byteorder.h>
#include <rte_spinlock.h>
#include <rte_malloc.h>
@@ -442,7 +444,7 @@ u32 qede_osal_log2(u32);
#define OSAL_CACHE_LINE_SIZE RTE_CACHE_LINE_SIZE
#define OSAL_IOMEM volatile
#define OSAL_UNUSED __rte_unused
-#define OSAL_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#define OSAL_UNLIKELY(x) unlikely(x)
#define OSAL_MIN_T(type, __min1, __min2) RTE_MIN_T(__min1, __min2, type)
#define OSAL_MAX_T(type, __max1, __max2) RTE_MAX_T(__max1, __max2, type)
diff --git a/drivers/net/vmxnet3/base/vmxnet3_osdep.h b/drivers/net/vmxnet3/base/vmxnet3_osdep.h
index 381a68db69..b1cd9ed056 100644
--- a/drivers/net/vmxnet3/base/vmxnet3_osdep.h
+++ b/drivers/net/vmxnet3/base/vmxnet3_osdep.h
@@ -7,13 +7,15 @@
#include <stdbool.h>
+#include <rte_branch_prediction.h>
+
typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
#ifndef UNLIKELY
-#define UNLIKELY(x) __builtin_expect((x),0)
+#define UNLIKELY(x) unlikely(x)
#endif /* unlikely */
#endif /* _VMXNET3_OSDEP_H */
--
2.46.2
More information about the dev
mailing list