[PATCH v4 12/22] ipc: fix mp message alignment for malloc

David Marchand david.marchand at redhat.com
Wed Jul 16 15:01:59 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.

This change breaks ABI, put a suppression rule for now (this will be
removed when merging the series in v25.11).

Signed-off-by: David Marchand <david.marchand at redhat.com>
---
Changes since v3:
- changed rte_mp_msg struct alignment,

---
 devtools/libabigail.abignore | 4 ++++
 lib/eal/include/rte_eal.h    | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore
index c65bea2b51..ceb2d24a1f 100644
--- a/devtools/libabigail.abignore
+++ b/devtools/libabigail.abignore
@@ -55,3 +55,7 @@
 [suppress_type]
 	name = rte_stack_lf_list
 	has_size_change = yes
+
+[suppress_type]
+	name = rte_mp_msg
+	has_size_change = yes
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