patch 'dmadev: fix structure alignment' has been queued to stable release 23.11.2
Xueming Li
xuemingl at nvidia.com
Mon Aug 12 14:48:04 CEST 2024
Hi,
FYI, your patch has been queued to stable release 23.11.2
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 08/14/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=583796e298412568ee7f2e1d9b13fc891a11b7d3
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From 583796e298412568ee7f2e1d9b13fc891a11b7d3 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
Cc: Xueming Li <xuemingl at nvidia.com>
[ 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 31a268cfdb..5093c6e38b 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -158,15 +158,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.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-08-12 20:44:02.871464447 +0800
+++ 0007-dmadev-fix-structure-alignment.patch 2024-08-12 20:44:01.895069255 +0800
@@ -1 +1 @@
-From c15902587b538ff02cfb0fbb4dd481f1503d936b Mon Sep 17 00:00:00 2001
+From 583796e298412568ee7f2e1d9b13fc891a11b7d3 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit c15902587b538ff02cfb0fbb4dd481f1503d936b ]
@@ -21 +23,0 @@
-Cc: stable at dpdk.org
@@ -30 +32 @@
-index e64b279bac..845727210f 100644
+index 31a268cfdb..5093c6e38b 100644
@@ -33 +35 @@
-@@ -159,15 +159,24 @@ static int
+@@ -158,15 +158,24 @@ static int
More information about the stable
mailing list