From aae9817d5daf60d50046a981c66f2702ee88652c Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 2 Jun 2017 13:12:13 -0700 Subject: [PATCH] ring: use aligned memzone allocation rte_memzone_reserve() provides cache line alignment, but struct rte_ring may require more than cache line alignment: on x86-64, it needs 128-byte alignment due to PROD_ALIGN and CONS_ALIGN, which are 128 bytes, but cache line size is 64 bytes. Fixes runtime warnings with UBSan enabled. Fixes: d9f0d3a1ffd4 ("ring: remove split cacheline build setting") Cc: stable@dpdk.org Signed-off-by: Daniel Verkamp --- lib/librte_ring/rte_ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c index 5f98c33f94..6f58fafe22 100644 --- a/lib/librte_ring/rte_ring.c +++ b/lib/librte_ring/rte_ring.c @@ -189,7 +189,8 @@ rte_ring_create(const char *name, unsigned count, int socket_id, /* reserve a memory zone for this ring. If we can't get rte_config or * we are secondary process, the memzone_reserve function will set * rte_errno for us appropriately - hence no check in this this function */ - mz = rte_memzone_reserve(mz_name, ring_size, socket_id, mz_flags); + mz = rte_memzone_reserve_aligned(mz_name, ring_size, socket_id, + mz_flags, __alignof__(*r)); if (mz != NULL) { r = mz->addr; /* no need to check return value here, we already checked the -- 2.20.1