On Wed, 27 Feb 2002, Warner Losh wrote:

> In message <[EMAIL PROTECTED]> Matthew Dillon writes:
> :     Sometimes features in early boot can be adjusted by breaking into DDB
> :     and w/l changing the sysctl variable, but perhaps not in this case.
>
> I think this is an excellent idea.  I have many of these tunables in
> the cardbus/oldcard code and it has helped me to diagnose many
> problems.  All my stuff runs after SI_SUB_TUNABLES, so that's not an
> issue.  Of course, not much happens before SUB_TUNABLES, but Peter's
> changes look like they might be one of them.

Some older changes by Peter actually broke this feature.  I ran into this
for nbuf.  I set nbuf in ddb early (using a de-rotted version of db_elf.c
from the Attic to find nbuf since db_kld.c is too broken to work early),
but init_param.c undid the change.

The patch initializes nbuf (and many other things) statically again.
The only losses are slight bloat of the data section and the ability
to use non-constant expressions for certain macros if you #define them.
E.g., in -current you can #define NBUF in terms of maxusers although
that would be silly (I think physmem is not in scope so more sensible
definitions don't work).  However, the patch retains the ability to
set MAXFILES using a funky expression.  Most variables aren't ifdefed
uglyly enough to support this complication.  E.g., the expression for
NPROC in terms of maxusers is fixed.  The patch uses this expression
directly.

%%%
Index: subr_param.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/subr_param.c,v
retrieving revision 1.52
diff -u -2 -r1.52 subr_param.c
--- subr_param.c        6 Feb 2002 01:19:19 -0000       1.52
+++ subr_param.c        23 Feb 2002 07:44:45 -0000
@@ -56,31 +56,27 @@
 #define        HZ 100
 #endif
-#define        NPROC (20 + 16 * maxusers)
 #ifndef NBUF
-#define NBUF 0
-#endif
-#ifndef MAXFILES
-#define        MAXFILES (maxproc * 2)
+#define        NBUF 0
 #endif

-int    hz;
+int    hz = HZ;
 int    tick;
-int    tickadj;                         /* can adjust 30ms in 60s */
-int    maxusers;                       /* base tunable */
-int    maxproc;                        /* maximum # of processes */
-int    maxprocperuid;                  /* max # of procs per user */
-int    maxfiles;                       /* sys. wide open files limit */
-int    maxfilesperproc;                /* per-proc open files limit */
-int    ncallout;                       /* maximum # of timer events */
-int    nbuf;
+int    tickadj;
+int    maxusers = MAXUSERS;            /* base tunable */
+int    maxproc;                        /* maximum number of processes */
+int    maxprocperuid;                  /* max number of procs per user */
+int    maxfiles;                       /* system wide limit on open files */
+int    maxfilesperproc;                /* per-process limit on open files */
+int    ncallout;                       /* maximum number of timer events */
+int    nbuf = NBUF;
 int    nswbuf;
-int    maxswzone;                      /* max swmeta KVA storage */
-int    maxbcache;                      /* max buffer cache KVA storage */
-u_quad_t       maxtsiz;                        /* max text size */
-u_quad_t       dfldsiz;                        /* initial data size limit */
-u_quad_t       maxdsiz;                        /* max data size */
-u_quad_t       dflssiz;                        /* initial stack size limit */
-u_quad_t       maxssiz;                        /* max stack size */
-u_quad_t       sgrowsiz;                       /* amount to grow stack */
+int    maxswzone = VM_SWZONE_SIZE_MAX; /* max swmeta KVA storage */
+int    maxbcache = VM_BCACHE_SIZE_MAX; /* max buffer cache KVA storage */
+u_quad_t maxtsiz = MAXTSIZ;            /* max text size */
+u_quad_t dfldsiz = DFLDSIZ;            /* initial data size limit */
+u_quad_t maxdsiz = MAXDSIZ;            /* max data size */
+u_quad_t dflssiz = DFLSSIZ;            /* initial stack size limit */
+u_quad_t maxssiz = MAXSSIZ;            /* max stack size */
+u_quad_t sgrowsiz = SGROWSIZ;          /* amount to grow stack */

 /*
@@ -92,5 +88,5 @@

 /*
- * Boot time overrides that are not scaled against main memory
+ * Boot time overrides that are not scaled against main memory.
  */
 void
@@ -98,34 +94,21 @@
 {

-       hz = HZ;
        TUNABLE_INT_FETCH("kern.hz", &hz);
        tick = 1000000 / hz;
        tickadj = howmany(30000, 60 * hz);      /* can adjust 30ms in 60s */

-#ifdef VM_SWZONE_SIZE_MAX
-       maxswzone = VM_SWZONE_SIZE_MAX;
-#endif
        TUNABLE_INT_FETCH("kern.maxswzone", &maxswzone);
-#ifdef VM_BCACHE_SIZE_MAX
-       maxbcache = VM_BCACHE_SIZE_MAX;
-#endif
        TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache);

-       maxtsiz = MAXTSIZ;
        TUNABLE_QUAD_FETCH("kern.maxtsiz", &maxtsiz);
-       dfldsiz = DFLDSIZ;
        TUNABLE_QUAD_FETCH("kern.dfldsiz", &dfldsiz);
-       maxdsiz = MAXDSIZ;
        TUNABLE_QUAD_FETCH("kern.maxdsiz", &maxdsiz);
-       dflssiz = DFLSSIZ;
        TUNABLE_QUAD_FETCH("kern.dflssiz", &dflssiz);
-       maxssiz = MAXSSIZ;
        TUNABLE_QUAD_FETCH("kern.maxssiz", &maxssiz);
-       sgrowsiz = SGROWSIZ;
        TUNABLE_QUAD_FETCH("kern.sgrowsiz", &sgrowsiz);
 }

 /*
- * Boot time overrides that are scaled against main memory
+ * Boot time overrides that are scaled against main memory.
  */
 void
@@ -133,6 +116,5 @@
 {

-       /* Base parameters */
-       maxusers = MAXUSERS;
+       /* Base parameters. */
        TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
        if (maxusers == 0) {
@@ -146,19 +128,21 @@
        /*
         * The following can be overridden after boot via sysctl.  Note:
-        * unless overriden, these macros are ultimately based on maxusers.
+        * unless overriden, these vaules are ultimately based on maxusers.
         */
-       maxproc = NPROC;
+       maxproc = 20 + 16 * maxusers;
        TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
+       maxprocperuid = (maxproc * 9) / 10;
+#ifdef MAXFILES
        maxfiles = MAXFILES;
+#else
+       maxfiles = maxproc * 2;
+#endif
        TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
-       maxprocperuid = (maxproc * 9) / 10;
        maxfilesperproc = (maxfiles * 9) / 10;

        /*
-        * Cannot be changed after boot.
+        * The following can not be changed after boot.
         */
-       nbuf = NBUF;
        TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
-
        ncallout = 16 + maxproc + maxfiles;
        TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
%%%

Bruce


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to