git: cbc3efab49aa - stable/14 - mbuf: Allow clusters to fill an entire jumbo page.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 14 May 2025 09:09:17 UTC
The branch stable/14 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=cbc3efab49aaa69acd3ac1701bc11095a4373d0a
commit cbc3efab49aaa69acd3ac1701bc11095a4373d0a
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-14 09:08:41 +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
(cherry picked from commit 271128b0698653294acf0ed3457d5871af5b3ef1)
---
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 6de8eab73027..55c1798bbffc 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -2047,7 +2047,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 cc927f27d318..7591db6cd833 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 a740c31789a1..69d82086c7a5 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 c17fc9dec9a4..65a328cb52a1 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -886,9 +886,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;
@@ -934,9 +936,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;
@@ -1056,9 +1060,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;