From c11b2785be37178f8fb806b226682e8e6e0795ba Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Mon, 28 Aug 2023 13:16:24 +0300 Subject: [PATCH] linux-dpdk: pool: add checks for internal event header sizes Add compile time checks for implementation internal event header sizes. Detect if a size of an event header expands to a new cache line, as this may have significant performance implications. RTE_CACHE_LINE_SIZE is used instead of ODP_CACHE_LINE_SIZE because in ABI compat mode the values may differ. Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale --- platform/linux-dpdk/include/odp_buffer_internal.h | 3 +++ platform/linux-dpdk/include/odp_event_vector_internal.h | 5 +++++ platform/linux-dpdk/include/odp_packet_internal.h | 3 +++ platform/linux-dpdk/include/odp_timer_internal.h | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/platform/linux-dpdk/include/odp_buffer_internal.h b/platform/linux-dpdk/include/odp_buffer_internal.h index 215f010cd2..dc65fd17dc 100644 --- a/platform/linux-dpdk/include/odp_buffer_internal.h +++ b/platform/linux-dpdk/include/odp_buffer_internal.h @@ -60,6 +60,9 @@ typedef struct ODP_ALIGNED_CACHE odp_buffer_hdr_t { } odp_buffer_hdr_t; +ODP_STATIC_ASSERT(sizeof(odp_buffer_hdr_t) <= 3 * RTE_CACHE_LINE_SIZE, + "Additional cache line required for odp_buffer_hdr_t"); + static inline struct rte_mbuf *_odp_buf_to_mbuf(odp_buffer_t buf) { return (struct rte_mbuf *)(uintptr_t)buf; diff --git a/platform/linux-dpdk/include/odp_event_vector_internal.h b/platform/linux-dpdk/include/odp_event_vector_internal.h index 3bab5e4622..0d4cd90486 100644 --- a/platform/linux-dpdk/include/odp_event_vector_internal.h +++ b/platform/linux-dpdk/include/odp_event_vector_internal.h @@ -21,6 +21,8 @@ #include +#include + #include /** @@ -47,6 +49,9 @@ typedef struct ODP_ALIGNED_CACHE odp_event_vector_hdr_t { } odp_event_vector_hdr_t; +ODP_STATIC_ASSERT(sizeof(odp_event_vector_hdr_t) <= 3 * RTE_CACHE_LINE_SIZE, + "Additional cache line required for odp_event_vector_hdr_t"); + /** * Return the vector header */ diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h index 37729b8f5a..b4d1f5d443 100644 --- a/platform/linux-dpdk/include/odp_packet_internal.h +++ b/platform/linux-dpdk/include/odp_packet_internal.h @@ -184,6 +184,9 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t { uint8_t crypto_aad_buf[PACKET_AAD_MAX]; } odp_packet_hdr_t; +ODP_STATIC_ASSERT(sizeof(odp_packet_hdr_t) <= 6 * RTE_CACHE_LINE_SIZE, + "Additional cache line required for odp_packet_hdr_t"); + /** * Return the packet header */ diff --git a/platform/linux-dpdk/include/odp_timer_internal.h b/platform/linux-dpdk/include/odp_timer_internal.h index d77898e9ae..3cc8ca4691 100644 --- a/platform/linux-dpdk/include/odp_timer_internal.h +++ b/platform/linux-dpdk/include/odp_timer_internal.h @@ -22,6 +22,8 @@ #include #include +#include + /** * Internal Timeout header */ @@ -46,6 +48,9 @@ typedef struct ODP_ALIGNED_CACHE odp_timeout_hdr_t { } odp_timeout_hdr_t; +ODP_STATIC_ASSERT(sizeof(odp_timeout_hdr_t) <= 3 * RTE_CACHE_LINE_SIZE, + "Additional cache line required for odp_timeout_hdr_t"); + /* A larger decrement value should be used after receiving events compared to * an 'empty' call. */ void _odp_timer_run_inline(int dec);