patch 'dmadev: fix structure alignment' has been queued to stable release 22.11.6

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Jul 15 17:25:42 CEST 2024


Hi,

FYI, your patch has been queued to stable release 22.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/17/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/e35ccc8804b944595fa531f69b48c5f240dad59e

Thanks.

Luca Boccassi

---
>From e35ccc8804b944595fa531f69b48c5f240dad59e Mon Sep 17 00:00:00 2001
From: Wenwu Ma <wenwux.ma at intel.com>
Date: Wed, 20 Mar 2024 15:23:32 +0800
Subject: [PATCH] dmadev: fix structure alignment

[ upstream commit c15902587b538ff02cfb0fbb4dd481f1503d936b ]

The structure rte_dma_dev needs to be aligned to the cache line, but
the return value of malloc may not be aligned to the cache line. When
we use memset to clear the rte_dma_dev object, it may cause a segmentation
fault in clang-x86-platform.

This is because clang uses the "vmovaps" assembly instruction for
memset, which requires that the operands (rte_dma_dev objects) must
aligned on a 16-byte boundary or a general-protection exception (#GP)
is generated.

Therefore, either additional memory is applied for re-alignment, or the
rte_dma_dev object does not require cache line alignment. The patch
chooses the former option to fix the issue.

Fixes: b36970f2e13e ("dmadev: introduce DMA device library")

Signed-off-by: Wenwu Ma <wenwux.ma at intel.com>
Reviewed-by: Chengwen Feng <fengchengwen at huawei.com>
---
 lib/dmadev/rte_dmadev.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index b48b915edc..d94f85ea9a 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -157,15 +157,24 @@ static int
 dma_dev_data_prepare(void)
 {
 	size_t size;
+	void *ptr;
 
 	if (rte_dma_devices != NULL)
 		return 0;
 
-	size = dma_devices_max * sizeof(struct rte_dma_dev);
-	rte_dma_devices = malloc(size);
-	if (rte_dma_devices == NULL)
+	/* The DMA device object is expected to align cacheline,
+	 * but the return value of malloc may not be aligned to the cache line.
+	 * Therefore, extra memory is applied for realignment.
+	 * Note: posix_memalign/aligned_alloc are not used
+	 * because not always available, depending on libc.
+	 */
+	size = dma_devices_max * sizeof(struct rte_dma_dev) + RTE_CACHE_LINE_SIZE;
+	ptr = malloc(size);
+	if (ptr == NULL)
 		return -ENOMEM;
-	memset(rte_dma_devices, 0, size);
+	memset(ptr, 0, size);
+
+	rte_dma_devices = RTE_PTR_ALIGN(ptr, RTE_CACHE_LINE_SIZE);
 
 	return 0;
 }
-- 
2.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-07-15 16:19:34.992740818 +0100
+++ 0004-dmadev-fix-structure-alignment.patch	2024-07-15 16:19:34.440203731 +0100
@@ -1 +1 @@
-From c15902587b538ff02cfb0fbb4dd481f1503d936b Mon Sep 17 00:00:00 2001
+From e35ccc8804b944595fa531f69b48c5f240dad59e Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit c15902587b538ff02cfb0fbb4dd481f1503d936b ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org
@@ -30 +31 @@
-index e64b279bac..845727210f 100644
+index b48b915edc..d94f85ea9a 100644
@@ -33 +34 @@
-@@ -159,15 +159,24 @@ static int
+@@ -157,15 +157,24 @@ static int


More information about the stable mailing list