vm/vm_kern.c: rate limit (to once per second) diagnostic printf when

you run out of mbuf address space.

kern/subr_mbuf.c: print a warning message when mb_alloc fails, again
	rate-limited to at most once per second. This covers other
	cases of mbuf allocation failures. Probably it also overlaps the
	one handled in vm/vm_kern.c, so maybe the latter should go away.

This warning will let us gradually remove the printf that are scattered
across most network drivers to report mbuf allocation failures.
Those are potentially dangerous, in that they are not rate-limited and
can easily cause systems to panic.

Unless there is disagreement (which does not seem to be the case
judging from the discussion on -net so far), and because this is
sort of a safety bugfix, I plan to commit a similar change to STABLE
during the weekend (it affects kern/uipc_mbuf.c there).

Discussed-with: jlemon, silby and -net
This commit is contained in:
Luigi Rizzo 2001-12-01 00:21:30 +00:00
parent 33cc94ddaf
commit 60363fb9f7
2 changed files with 22 additions and 3 deletions

View File

@ -621,9 +621,22 @@ mb_alloc(struct mb_lstmngr *mb_list, int how, short type)
* steal from other lists.
*/
m = mb_alloc_wait(mb_list, type);
} else
} else {
/*
* no way to indent this code decently
* with 8-space tabs.
*/
static int last_report;
/* XXX: No consistency. */
mbstat.m_drops++;
if (ticks < last_report ||
(ticks - last_report) >= hz) {
last_report = ticks;
printf(
"mb_alloc for type %d failed, consider increase mbuf value.\n", type);
}
}
}
}
}

View File

@ -70,6 +70,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h> /* for ticks and hz */
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@ -331,8 +332,13 @@ kmem_malloc(map, size, flags)
if (vm_map_findspace(map, vm_map_min(map), size, &addr)) {
vm_map_unlock(map);
if (map != kmem_map) {
static int last_report; /* when we did it (in ticks) */
if (ticks < last_report ||
(ticks - last_report) >= hz) {
last_report = ticks;
printf("Out of mbuf address space!\n");
printf("Consider increasing NMBCLUSTERS\n");
}
goto bad;
}
if ((flags & M_NOWAIT) == 0)