Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Set a hard limit (rather than an advisory high wate...



details:   https://anonhg.NetBSD.org/src/rev/10b331c3e500
branches:  trunk
changeset: 467912:10b331c3e500
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Mar 31 01:26:40 1999 +0000

description:
Set a hard limit (rather than an advisory high water mark for pages) of
NMBCLUSTERS for the mbuf cluster pool.  On platforms which use direct-mapped
segments for pool pages (MIPS and Alpha), this makes NMBCLUSTERS actually
meaningful (such ports don't even allocate mb_map, as it is not used to
map mbuf cluster pages).

Improve the message logged at a maximum rate of once per second.  The
new message: "WARNING: mclpool limit reached; increase NMBCLUSTERS".

In the back-end pool page allocator, remove the message about mb_map
being full.  The message was not necessarily correct as the allocator
may have been starved for pages, rather than for space in the map.  Also,
the hard limit on the mbuf cluster pool will be reached before the map
fills (the last cluster will always fit into the map), so the message
is redundant.

Add a comment in mbinit() about considering setting low water marks on
the mbuf and mbuf cluster pools.

diffstat:

 sys/kern/uipc_mbuf.c |  39 ++++++++++++++-------------------------
 1 files changed, 14 insertions(+), 25 deletions(-)

diffs (63 lines):

diff -r 4b70706e6cc8 -r 10b331c3e500 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Wed Mar 31 01:14:06 1999 +0000
+++ b/sys/kern/uipc_mbuf.c      Wed Mar 31 01:26:40 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf.c,v 1.38 1999/03/24 05:51:26 mrg Exp $       */
+/*     $NetBSD: uipc_mbuf.c,v 1.39 1999/03/31 01:26:40 thorpej Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1991, 1993
@@ -82,10 +82,18 @@
            mclpool_release, 0);
 
        /*
-        * Set the high water mark on the mclpool to the number of
-        * mbuf clusters the kernel is to support.
+        * Set the hard limit on the mclpool to the number of
+        * mbuf clusters the kernel is to support.  Log the limit
+        * reached message max once a minute.
         */
-       pool_sethiwat(&mclpool, NMBCLUSTERS);
+       pool_sethardlimit(&mclpool, NMBCLUSTERS,
+           "WARNING: mclpool limit reached; increase NMBCLUSTERS", 60);
+       
+       /*
+        * XXX Consider setting a low-water mark here.  That will help
+        * e.g. pagedaemon on diskless systems as it scrambles to clean
+        * pages in memory starvation situations.
+        */
 }
 
 void *
@@ -94,29 +102,10 @@
        int flags;
        int mtype;
 {
-       volatile static struct timeval lastlogged;
-       struct timeval curtime, logdiff;
        boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
-       vaddr_t va;
-       int s;
 
-       va = uvm_km_alloc_poolpage1(mb_map, uvmexp.mb_object, waitok);
-       if (va == 0) {
-               s = splclock();
-               curtime = mono_time;
-               splx(s);
-               timersub(&curtime, &lastlogged, &logdiff);
-               if (logdiff.tv_sec >= 60) {
-                       lastlogged = curtime;
-                       log(LOG_ERR, "mb_map full\n");
-               }
-               /*
-                * Don't need to reclaim here; MCLGET(), which calls
-                * pool_get(), will reclaim and attempt the allocation
-                * again.
-                */
-       }
-       return ((void *)va);
+       return ((void *)uvm_km_alloc_poolpage1(mb_map, uvmexp.mb_object,
+           waitok));
 }
 
 void



Home | Main Index | Thread Index | Old Index