git: 271128b06986 - main - mbuf: Allow clusters to fill an entire jumbo page.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 May 2025 19:00:25 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=271128b0698653294acf0ed3457d5871af5b3ef1
commit 271128b0698653294acf0ed3457d5871af5b3ef1
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-05-07 18:58:48 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-05-07 18:59:09 +0000
mbuf: Allow clusters to fill an entire jumbo page.
The assumption that MCLBYTES == MJUMPAGESIZE can only happen if pages
are small is incorrect: it can also happen if MCLSHIFT is adjusted to
increase the size of clusters. Restore the ability to have clusters
fill a jumbo page, while still disallowing them from exceeding them.
MFC after: 1 week
Fixes: 840327e5ddf3, 9c3ad5ba932b
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Reviewed by: siderop1_netapp.com, kevans, brooks
Differential Revision: https://reviews.freebsd.org/D50242
---
sys/conf/NOTES | 3 ++-
sys/dev/cxgbe/adapter.h | 4 ++++
sys/dev/cxgbe/t4_sge.c | 8 ++++++++
sys/kern/kern_mbuf.c | 4 ++--
sys/sys/mbuf.h | 6 ++++++
5 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index d85980e4e122..e84fdcb30220 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -2057,7 +2057,8 @@ device rtwnfw
# mismatch between the mbuf size assumed by the kernel and the mbuf size
# assumed by a module. The only driver that currently has the ability to
# detect a mismatch is ti(4).
-options MCLSHIFT=11 # mbuf cluster shift in bits, 11 == 2KB
+options MCLSHIFT=12 # mbuf cluster shift in bits, 12 == 4 kB
+ # default is 11 == 2 kB
options MSIZE=256 # mbuf size in bytes
#
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 3bf4f666ce7d..d3820245837a 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -107,7 +107,11 @@ enum {
CTRL_EQ_QSIZE = 1024,
TX_EQ_QSIZE = 1024,
+#if MJUMPAGESIZE != MCLBYTES
SW_ZONE_SIZES = 4, /* cluster, jumbop, jumbo9k, jumbo16k */
+#else
+ SW_ZONE_SIZES = 3, /* cluster, jumbo9k, jumbo16k */
+#endif
CL_METADATA_SIZE = CACHE_LINE_SIZE,
SGE_MAX_WR_NDESC = SGE_MAX_WR_LEN / EQ_ESIZE, /* max WR size in desc */
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index bc81a0251deb..86454bc4fe10 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -570,7 +570,9 @@ t4_sge_modload(void)
}
if (largest_rx_cluster != MCLBYTES &&
+#if MJUMPAGESIZE != MCLBYTES
largest_rx_cluster != MJUMPAGESIZE &&
+#endif
largest_rx_cluster != MJUM9BYTES &&
largest_rx_cluster != MJUM16BYTES) {
printf("Invalid hw.cxgbe.largest_rx_cluster value (%d),"
@@ -579,7 +581,9 @@ t4_sge_modload(void)
}
if (safest_rx_cluster != MCLBYTES &&
+#if MJUMPAGESIZE != MCLBYTES
safest_rx_cluster != MJUMPAGESIZE &&
+#endif
safest_rx_cluster != MJUM9BYTES &&
safest_rx_cluster != MJUM16BYTES) {
printf("Invalid hw.cxgbe.safest_rx_cluster value (%d),"
@@ -718,7 +722,9 @@ t4_tweak_chip_settings(struct adapter *sc)
uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE);
static int sw_buf_sizes[] = {
MCLBYTES,
+#if MJUMPAGESIZE != MCLBYTES
MJUMPAGESIZE,
+#endif
MJUM9BYTES,
MJUM16BYTES
};
@@ -855,7 +861,9 @@ t4_init_rx_buf_info(struct adapter *sc)
int i, j, n;
static int sw_buf_sizes[] = { /* Sorted by size */
MCLBYTES,
+#if MJUMPAGESIZE != MCLBYTES
MJUMPAGESIZE,
+#endif
MJUM9BYTES,
MJUM16BYTES
};
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 48886c1e5b0c..90af03e29dfb 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -61,8 +61,8 @@
#include <vm/uma.h>
#include <vm/uma_dbg.h>
-_Static_assert(MJUMPAGESIZE > MCLBYTES,
- "Cluster must be smaller than a jumbo page");
+_Static_assert(MCLBYTES <= MJUMPAGESIZE,
+ "Cluster must not be larger than a jumbo page");
/*
* In FreeBSD, Mbufs and Mbuf Clusters are allocated from UMA
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 58b7585303bb..c75094aea450 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -885,9 +885,11 @@ m_gettype(int size)
case MCLBYTES:
type = EXT_CLUSTER;
break;
+#if MJUMPAGESIZE != MCLBYTES
case MJUMPAGESIZE:
type = EXT_JUMBOP;
break;
+#endif
case MJUM9BYTES:
type = EXT_JUMBO9;
break;
@@ -933,9 +935,11 @@ m_getzone(int size)
case MCLBYTES:
zone = zone_clust;
break;
+#if MJUMPAGESIZE != MCLBYTES
case MJUMPAGESIZE:
zone = zone_jumbop;
break;
+#endif
case MJUM9BYTES:
zone = zone_jumbo9;
break;
@@ -1055,9 +1059,11 @@ m_cljset(struct mbuf *m, void *cl, int type)
case EXT_CLUSTER:
size = MCLBYTES;
break;
+#if MJUMPAGESIZE != MCLBYTES
case EXT_JUMBOP:
size = MJUMPAGESIZE;
break;
+#endif
case EXT_JUMBO9:
size = MJUM9BYTES;
break;