[PATCH v5 12/22] ipc: fix mp message alignment for malloc
David Marchand
david.marchand at redhat.com
Wed Jul 23 15:31:45 CEST 2025
Content (param[]) of received multiprocess messages are aligned with
a 4 bytes constraint.
Before patch:
struct mp_msg_internal {
int type; /* 0 4 */
struct rte_mp_msg {
char name[64]; /* 4 64 */
/* --- cacheline 1 boundary (64 bytes) was 4 bytes ago --- */
int len_param; /* 68 4 */
int num_fds; /* 72 4 */
/* typedef uint8_t -> __uint8_t */ unsigned char param[256]; /* 76 256 */
/* --- cacheline 5 boundary (320 bytes) was 12 bytes ago --- */
int fds[253]; /* 332 1012 */
} msg; /* 4 1340 */
/* size: 1344, cachelines: 21, members: 2 */
};
This results in many unaligned accesses for multiprocess malloc requests.
Examples:
../lib/eal/common/malloc_mp.c:308:32: runtime error:
member access within misaligned address 0x7f7b35df4684 for type
'const struct malloc_mp_req', which requires 8 byte alignment
../lib/eal/common/malloc_mp.c:158:9: runtime error:
member access within misaligned address 0x7f36a535bb5c for type
'const struct malloc_mp_req', which requires 8 byte alignment
../lib/eal/common/malloc_mp.c:171:8: runtime error:
member access within misaligned address 0x7f4ba65f296c for type
'struct malloc_mp_req', which requires 8 byte alignment
Align param[] to 64 bits to avoid unaligned accesses on structures
passed through this array in mp messages.
Signed-off-by: David Marchand <david.marchand at redhat.com>
---
Changes since v4:
- dropped ABI exception and updated RN,
Changes since v3:
- changed rte_mp_msg struct alignment,
---
doc/guides/rel_notes/release_25_11.rst | 4 +++-
lib/eal/include/rte_eal.h | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/doc/guides/rel_notes/release_25_11.rst b/doc/guides/rel_notes/release_25_11.rst
index aa9211dd60..86cc59b4be 100644
--- a/doc/guides/rel_notes/release_25_11.rst
+++ b/doc/guides/rel_notes/release_25_11.rst
@@ -100,10 +100,12 @@ ABI Changes
Also, make sure to start the actual text at the margin.
=======================================================
+* eal: The structure ``rte_mp_msg`` alignment has been updated to 8 bytes to limit unaligned
+ accesses in messages payload.
+
* stack: The structure ``rte_stack_lf_head`` alignment has been updated to 16 bytes
to avoid unaligned accesses.
-
Known Issues
------------
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index c826e143f1..08977c61d3 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -11,6 +11,7 @@
* EAL Configuration API
*/
+#include <stdalign.h>
#include <stdint.h>
#include <time.h>
@@ -162,7 +163,7 @@ struct rte_mp_msg {
char name[RTE_MP_MAX_NAME_LEN];
int len_param;
int num_fds;
- uint8_t param[RTE_MP_MAX_PARAM_LEN];
+ alignas(8) uint8_t param[RTE_MP_MAX_PARAM_LEN];
int fds[RTE_MP_MAX_FD_NUM];
};
--
2.50.0
More information about the dev
mailing list