git: b8394039dc25 - main - mbuf(9): Fix size of mbuf for all 32-bit platforms (i386, ARM, PowerPC and RISCV)

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Tue, 07 Jun 2022 20:14:20 UTC
The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=b8394039dc252698711ded30045af20481db79e0

commit b8394039dc252698711ded30045af20481db79e0
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-06-07 19:55:01 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-07 20:09:10 +0000

    mbuf(9): Fix size of mbuf for all 32-bit platforms (i386, ARM, PowerPC and RISCV)
    
    Do this by reducing the size of the MBUF_PEXT_MAX_PGS, causing "struct mbuf" to
    be bigger than M_SIZE, and also add a missing padding field to ensure 64-bit
    alignment.
    
    Reviewed by:    gallatin@
    Reported by:    Elliott Mitchell
    Differential revision:  https://reviews.freebsd.org/D35339
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 sys/kern/uipc_mbuf.c | 6 +++---
 sys/sys/mbuf.h       | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 4a5bb45e9573..02a9a120b970 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -184,12 +184,12 @@ CTASSERT(sizeof(struct pkthdr) == 64);
 CTASSERT(sizeof(struct m_ext) == 160);
 #else
 CTASSERT(offsetof(struct mbuf, m_dat) == 24);
-CTASSERT(sizeof(struct pkthdr) == 52);
+CTASSERT(sizeof(struct pkthdr) == 56);
 #if defined(__powerpc__) && defined(BOOKE)
 /* PowerPC booke has 64-bit physical pointers. */
-CTASSERT(sizeof(struct m_ext) == 184);
+CTASSERT(sizeof(struct m_ext) == 176);
 #else
-CTASSERT(sizeof(struct m_ext) == 180);
+CTASSERT(sizeof(struct m_ext) == 172);
 #endif
 #endif
 
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index c9b3df075105..dc32a1e23c38 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -180,6 +180,9 @@ struct pkthdr {
 	uint16_t	 fibnum;	/* this packet should use this fib */
 	uint8_t		 numa_domain;	/* NUMA domain of recvd pkt */
 	uint8_t		 rsstype;	/* hash type */
+#if !defined(__LP64__)
+	uint32_t	 pad;		/* pad for 64bit alignment */
+#endif
 	union {
 		uint64_t	rcv_tstmp;	/* timestamp in ns */
 		struct {
@@ -245,7 +248,7 @@ struct pkthdr {
 #if defined(__LP64__)
 #define MBUF_PEXT_MAX_PGS (40 / sizeof(vm_paddr_t))
 #else
-#define MBUF_PEXT_MAX_PGS (72 / sizeof(vm_paddr_t))
+#define MBUF_PEXT_MAX_PGS (64 / sizeof(vm_paddr_t))
 #endif
 
 #define	MBUF_PEXT_MAX_BYTES						\