Module Name:    src
Committed By:   martin
Date:           Mon Oct 25 15:47:50 UTC 2021

Modified Files:
        src/share/man/man4 [netbsd-9]: options.4
        src/sys/conf [netbsd-9]: files
        src/sys/kern [netbsd-9]: uipc_mbuf.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1368):

        sys/conf/files: revision 1.1288
        sys/kern/uipc_mbuf.c: revision 1.244
        share/man/man4/options.4: revision 1.520

Fix a bug that NMBCLUSTERS(kern.mbuf.nmbclusters) can't be changed by sysctl.

Update the description of the NMBCLUSTERS. Add NMBCLUSTERS_MAX.

defparam NMBCLUSTERS_MAX.


To generate a diff of this commit:
cvs rdiff -u -r1.506.2.1 -r1.506.2.2 src/share/man/man4/options.4
cvs rdiff -u -r1.1237.2.5 -r1.1237.2.6 src/sys/conf/files
cvs rdiff -u -r1.232.4.1 -r1.232.4.2 src/sys/kern/uipc_mbuf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/options.4
diff -u src/share/man/man4/options.4:1.506.2.1 src/share/man/man4/options.4:1.506.2.2
--- src/share/man/man4/options.4:1.506.2.1	Thu Sep  5 09:00:22 2019
+++ src/share/man/man4/options.4	Mon Oct 25 15:47:50 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: options.4,v 1.506.2.1 2019/09/05 09:00:22 martin Exp $
+.\"	$NetBSD: options.4,v 1.506.2.2 2021/10/25 15:47:50 martin Exp $
 .\"
 .\" Copyright (c) 1996
 .\" 	Perry E. Metzger.  All rights reserved.
@@ -2082,15 +2082,20 @@ Mbuf clusters are MCLBYTES in size (usua
 This is used to compute the size of the kernel VM map
 .Em mb_map ,
 which maps mbuf clusters.
-Default on most ports is 1024 (2048 with
-.Dq options GATEWAY
-).
+The default value is calculated from the amount of physical memory.
+Architectures without direct mapping also limit it based on the kmem_map size,
+which is used as backing store.
+Some archs limit the value with
+.Sq NMBCLUSTERS_MAX .
 See
 .Pa /usr/include/machine/param.h
-for exact default information.
+for those archs.
+This value can be accessed via the kern.mbuf.nmbclusters sysctl variable.
 Increase this value if you get
 .Dq mclpool limit reached
 messages.
+.It Cd options NMBCLUSTERS_MAX=value
+The upper limit of NMBCLUSTERS.
 .It Cd options NKMEMPAGES=value
 .It Cd options NKMEMPAGES_MIN=value
 .It Cd options NKMEMPAGES_MAX=value

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1237.2.5 src/sys/conf/files:1.1237.2.6
--- src/sys/conf/files:1.1237.2.5	Sun Mar  8 10:18:04 2020
+++ src/sys/conf/files	Mon Oct 25 15:47:50 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1237.2.5 2020/03/08 10:18:04 martin Exp $
+#	$NetBSD: files,v 1.1237.2.6 2021/10/25 15:47:50 martin Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -285,6 +285,7 @@ defflag opt_pppoe.h		PPPOE_SERVER PPPOE_
 #
 defflag				GATEWAY
 defparam opt_nmbclusters.h	NMBCLUSTERS
+	 			NMBCLUSTERS_MAX
 defparam			SB_MAX
 
 # file system options

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.232.4.1 src/sys/kern/uipc_mbuf.c:1.232.4.2
--- src/sys/kern/uipc_mbuf.c:1.232.4.1	Tue Aug 11 17:14:21 2020
+++ src/sys/kern/uipc_mbuf.c	Mon Oct 25 15:47:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.232.4.1 2020/08/11 17:14:21 martin Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.232.4.2 2021/10/25 15:47:50 martin Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.232.4.1 2020/08/11 17:14:21 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.232.4.2 2021/10/25 15:47:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -165,11 +165,7 @@ nmbclusters_limit(void)
 	max_size = MIN(max_size, NMBCLUSTERS_MAX);
 #endif
 
-#ifdef NMBCLUSTERS
-	return MIN(max_size, NMBCLUSTERS);
-#else
 	return max_size;
-#endif
 }
 
 /*
@@ -199,7 +195,7 @@ mbinit(void)
 	 * Set an arbitrary default limit on the number of mbuf clusters.
 	 */
 #ifdef NMBCLUSTERS
-	nmbclusters = nmbclusters_limit();
+	nmbclusters = MIN(NMBCLUSTERS, nmbclusters_limit());
 #else
 	nmbclusters = MAX(1024,
 	    (vsize_t)physmem * PAGE_SIZE / MCLBYTES / 16);

Reply via email to