Date: Sun, 23 Jun 2002 02:15:07 +0200 (CEST) From: Cyrille Lefevre <cyrille.lefevre@laposte.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/39681: hidden kernel boot tunables added to sysctl as read-only mib Message-ID: <200206230015.g5N0F71B008233@gits.gits.dyndns.org>
next in thread | raw e-mail | index | archive | help
>Number: 39681
>Category: kern
>Synopsis: hidden kernel boot tunables added to sysctl as read-only mib
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Jun 22 17:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Cyrille Lefevre
>Release: FreeBSD 4.6-RC i386
>Organization:
ACME
>Environment:
System: FreeBSD gits 4.6-RC FreeBSD 4.6-RC #11: Sun Jun 9 19:48:37 CEST 2002 root@gits:/disk2/freebsd/src/sys/compile/CUSTOM i386
>Description:
some kernel boot tunables aren't well documented nor viewabled
using sysctl. this patch set add them to the sysctl tree
as read-only mib and document them in loader.conf. this
may help to tune them when necessary by knowing their current
auto-configured values.
sys/boot/forth/loader.conf
hidden kernel boot tunables added.
sys/sys/sysctl.h
sys/kern/kern_sysctl.c
sysctl quad handlers added.
sys/kern/kern_malloc.c
kern.vm.kmem.size mib added.
sys/kern/subr_param.c
kern.hz, kern.maxswzone, kern.maxbcache, kern.maxtsiz,
kern.dfldsiz, kern.maxdsiz, kern.dflssiz, kern.maxssiz,
kern.sgrowsiz, kern.nbuf, kern.ncallout and kern.ipc.nsfbufs
mibs added.
>How-To-Repeat:
# sysctl kern.maxdsiz
sysctl: unknown oid 'kern.maxdsiz'
>Fix:
Index: sys/boot/forth/loader.conf
===================================================================
RCS file: /home/ncvs/src/sys/boot/forth/loader.conf,v
retrieving revision 1.25.2.18
diff -u -r1.25.2.18 loader.conf
--- forth/loader.conf 28 Apr 2002 22:49:54 -0000 1.25.2.18
+++ forth/loader.conf 22 Jun 2002 23:30:17 -0000
@@ -71,9 +71,32 @@
### Kernel tunables ########################################
##############################################################
+#kern.hz="100" # Granularity of operation
+#kern.maxswzone="73400320" # Max swmeta KVA storage
+#kern.maxbcache="209715200" # Max buffer cache KVA storage
+#kern.maxtsiz="134217728" # Max text size
+#kern.dfldsiz="134217728" # Initial max data size
+#kern.maxdsiz="536870912" # Max data size
+#kern.dflssiz="8388608" # Initial max stack size
+#kern.maxssiz="67108864" # Max stack size
+#kern.sgrowsiz="131072" # Amount to grow stack
#kern.maxusers="32" # Set size of various static tables
-#kern.ipc.nmbclusters="" # Set the number of mbuf clusters
+ # defaulted to: physpages/2*1024*1024/PAGE_SIZE
+#kern.maxproc="560" # Max # of procs per user
+ # defaulted to: 16+20*maxusers
+#kern.maxfiles="1120" # System wide open files limit
+ # defaulted to: maxproc*2
+#kern.ipc.nsfbufs="1024" # Max # of sendfile(2) zero-copy virtual buffers
+ # defaulted to: 512+maxusers*16
+#kern.nbuf="0" # Number of buffer cache KVM reservation
+#kern.ncallout="1696" # Max # of timer events
+ # defaulted to: 16+maxproc+maxfiles
#kern.vm.kmem.size="" # Sets the size of kernel memory (bytes)
+ # defaulted to: v_page_count*PAGE_SIZE/3
+#kern.ipc.nmbclusters="262144" # Set the number of mbuf clusters
+ # defaulted to: 512+maxusers*16
+#kern.ipc.nmbufs="" # Maximum number of mbufs available
+ # defaulted to: nmbclusters*4
#machdep.pccard.pcic_irq="0" # Assigns PCCARD controller IRQ (0=polled)
#net.inet.tcp.tcbhashsize="" # Set the value of TCBHASHSIZE
#vfs.root.mountfrom="" # Specify root partition in a way the
Index: sys/sys/sysctl.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/sysctl.h,v
retrieving revision 1.81.2.8
diff -u -r1.81.2.8 sysctl.h
--- sysctl.h 17 Mar 2002 11:08:38 -0000 1.81.2.8
+++ sysctl.h 18 Jun 2002 00:07:22 -0000
@@ -76,6 +76,7 @@
#define CTLTYPE_UINT 6 /* name describes an unsigned integer */
#define CTLTYPE_LONG 7 /* name describes a long */
#define CTLTYPE_ULONG 8 /* name describes an unsigned long */
+#define CTLTYPE_UQUAD 9 /* name describes a 64-bit unsigned number */
#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
@@ -140,6 +141,7 @@
int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
+int sysctl_handle_quad(SYSCTL_HANDLER_ARGS);
int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS);
int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
@@ -235,6 +237,24 @@
#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|access, \
ptr, 0, sysctl_handle_long, "LU", descr);
+
+/* Oid for a quad. The pointer must be non NULL. */
+#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \
+ ptr, val, sysctl_handle_quad, "Q", descr)
+
+#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \
+ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|access, \
+ ptr, 0, sysctl_handle_quad, "Q", descr);
+
+/* Oid for a quad. The pointer must be non NULL. */
+#define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_UQUAD|access, \
+ ptr, val, sysctl_handle_quad, "QU", descr)
+
+#define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr) \
+ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UQUAD|access, \
+ ptr, 0, sysctl_handle_quad, "QU", descr);
/* Oid for an opaque object. Specified by a pointer and a length. */
#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
Index: sys/kern/kern_malloc.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_malloc.c,v
retrieving revision 1.64.2.5
diff -u -r1.64.2.5 kern_malloc.c
--- kern_malloc.c 16 Mar 2002 02:19:51 -0000 1.64.2.5
+++ kern_malloc.c 18 Jun 2002 00:06:50 -0000
@@ -38,6 +38,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@@ -84,6 +85,11 @@
static char *kmemlimit;
u_int vm_kmem_size;
+
+SYSCTL_NODE(_kern, OID_AUTO, vm, CTLFLAG_RD, 0, "");
+SYSCTL_NODE(_kern_vm, OID_AUTO, kmem, CTLFLAG_RD, 0, "");
+SYSCTL_UINT(_kern_vm_kmem, OID_AUTO, size, CTLFLAG_RD,
+ &vm_kmem_size, 0, "Kernel VM size");
#ifdef INVARIANTS
/*
Index: sys/kern/kern_sysctl.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.92.2.7
diff -u -r1.92.2.7 kern_sysctl.c
--- kern_sysctl.c 6 Mar 2002 05:43:51 -0000 1.92.2.7
+++ kern_sysctl.c 7 Jun 2002 09:10:28 -0000
@@ -771,6 +771,26 @@
}
/*
+ * Handle a quad, signed or unsigned. arg1 points to it.
+ */
+
+int
+sysctl_handle_quad(SYSCTL_HANDLER_ARGS)
+{
+ int error = 0;
+
+ if (!arg1)
+ return (EINVAL);
+ error = SYSCTL_OUT(req, arg1, sizeof(quad_t));
+
+ if (error || !req->newptr)
+ return (error);
+
+ error = SYSCTL_IN(req, arg1, sizeof(quad_t));
+ return (error);
+}
+
+/*
* Handle our generic '\0' terminated 'C' string.
* Two cases:
* a variable string: point arg1 at it, arg2 is max length.
Index: sys/kern/subr_param.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/subr_param.c,v
retrieving revision 1.42.2.10
diff -u -r1.42.2.10 subr_param.c
--- subr_param.c 9 Mar 2002 21:05:47 -0000 1.42.2.10
+++ subr_param.c 18 Jun 2002 00:06:24 -0000
@@ -44,6 +44,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <machine/vmparam.h>
@@ -76,7 +77,7 @@
int maxfilesperproc; /* per-proc open files limit */
int ncallout; /* maximum # of timer events */
int mbuf_wait = 32; /* mbuf sleep time in ticks */
-int nbuf;
+int nbuf; /* number of buffer cache KVM reservation */
int nswbuf;
int maxswzone; /* max swmeta KVA storage */
int maxbcache; /* max buffer cache KVA storage */
@@ -89,6 +90,33 @@
/* maximum # of sf_bufs (sendfile(2) zero-copy virtual buffers) */
int nsfbufs;
+
+SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RD,
+ &hz, 0, "Granularity of operation");
+SYSCTL_INT(_kern, OID_AUTO, maxswzone, CTLFLAG_RD,
+ &maxswzone, 0, "Max swmeta KVA storage");
+SYSCTL_INT(_kern, OID_AUTO, maxbcache, CTLFLAG_RD,
+ &maxbcache, 0, "Max buffer cache KVA storage");
+SYSCTL_QUAD(_kern, OID_AUTO, maxtsiz, CTLFLAG_RD,
+ &maxtsiz, 0, "Max text size");
+SYSCTL_QUAD(_kern, OID_AUTO, dfldsiz, CTLFLAG_RD,
+ &dfldsiz, 0, "Initial max data size");
+SYSCTL_QUAD(_kern, OID_AUTO, maxdsiz, CTLFLAG_RD,
+ &maxdsiz, 0, "Max data size");
+SYSCTL_QUAD(_kern, OID_AUTO, dflssiz, CTLFLAG_RD,
+ &dflssiz, 0, "Initial max stack size");
+SYSCTL_QUAD(_kern, OID_AUTO, maxssiz, CTLFLAG_RD,
+ &maxssiz, 0, "Max stack size");
+SYSCTL_QUAD(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RD,
+ &sgrowsiz, 0, "Amount to grow stack");
+SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RD,
+ &nbuf, 0, "Number of buffer cache KVM reservation");
+SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RD,
+ &ncallout, 0, "Max # of timer events");
+
+SYSCTL_DECL(_kern_ipc);
+SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufs, CTLFLAG_RD,
+ &nsfbufs, 0, "Max # of sendfile(2) zero-copy virtual buffers");
/*
* These have to be allocated somewhere; allocating
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206230015.g5N0F71B008233>
