aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorJonathan T. Looney <jtl@FreeBSD.org>2015-12-20 02:05:33 +0000
committerJonathan T. Looney <jtl@FreeBSD.org>2015-12-20 02:05:33 +0000
commit54503a13d8711f183ffedbf6a994ae79108b791b (patch)
tree35edbedbe3247ad76258a68a02cbebe4e0c54cb1 /share
parent25a2de5e7ec77115381e2637173e9c0b2ed38293 (diff)
downloadsrc-54503a13d8711f183ffedbf6a994ae79108b791b.tar.gz
src-54503a13d8711f183ffedbf6a994ae79108b791b.zip
Add a safety net to reclaim mbufs when one of the mbuf zones become
exhausted. It is possible for a bug in the code (or, theoretically, even unusual network conditions) to exhaust all possible mbufs or mbuf clusters. When this occurs, things can grind to a halt fairly quickly. However, we currently do not call mb_reclaim() unless the entire system is experiencing a low-memory condition. While it is best to try to prevent exhaustion of one of the mbuf zones, it would also be useful to have a mechanism to attempt to recover from these situations by freeing "expendable" mbufs. This patch makes two changes: a) The patch adds a generic API to the UMA zone allocator to set a function that should be called when an allocation fails because the zone limit has been reached. Because of the way this function can be called, it really should do minimal work. b) The patch uses this API to try to free mbufs when an allocation fails from one of the mbuf zones because the zone limit has been reached. The function schedules a callout to run mb_reclaim(). Differential Revision: https://reviews.freebsd.org/D3864 Reviewed by: gnn Comments by: rrs, glebius MFC after: 2 weeks Sponsored by: Juniper Networks
Notes
Notes: svn path=/head/; revision=292484
Diffstat (limited to 'share')
-rw-r--r--share/man/man9/Makefile3
-rw-r--r--share/man/man9/zone.917
2 files changed, 16 insertions, 4 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 30cb5035efcf..c1399a32b84b 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1911,6 +1911,7 @@ MLINKS+=zone.9 uma.9 \
zone.9 uma_zone_get_cur.9 \
zone.9 uma_zone_get_max.9 \
zone.9 uma_zone_set_max.9 \
- zone.9 uma_zone_set_warning.9
+ zone.9 uma_zone_set_warning.9 \
+ zone.9 uma_zone_set_maxaction.9
.include <bsd.prog.mk>
diff --git a/share/man/man9/zone.9 b/share/man/man9/zone.9
index 2df14b022eea..12226d1d2780 100644
--- a/share/man/man9/zone.9
+++ b/share/man/man9/zone.9
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 7, 2014
+.Dd December 20, 2015
.Dt ZONE 9
.Os
.Sh NAME
@@ -39,7 +39,8 @@
.Nm uma_zone_set_max,
.Nm uma_zone_get_max,
.Nm uma_zone_get_cur,
-.Nm uma_zone_set_warning
+.Nm uma_zone_set_warning,
+.Nm uma_zone_set_maxaction
.Nd zone allocator
.Sh SYNOPSIS
.In sys/param.h
@@ -71,6 +72,8 @@
.Fn uma_zone_get_cur "uma_zone_t zone"
.Ft void
.Fn uma_zone_set_warning "uma_zone_t zone" "const char *warning"
+.Ft void
+.Fn uma_zone_set_maxaction "uma_zone_t zone" "void (*maxaction)(uma_zone_t)"
.In sys/sysctl.h
.Fn SYSCTL_UMA_MAX parent nbr name access zone descr
.Fn SYSCTL_ADD_UMA_MAX ctx parent nbr name access zone descr
@@ -307,13 +310,21 @@ The
.Fn uma_zone_set_warning
function sets a warning that will be printed on the system console when the
given zone becomes full and fails to allocate an item.
-The warning will be printed not often than every five minutes.
+The warning will be printed no more often than every five minutes.
Warnings can be turned off globally by setting the
.Va vm.zone_warnings
sysctl tunable to
.Va 0 .
.Pp
The
+.Fn uma_zone_set_maxaction
+function sets a function that will be called when the given zone becomes full
+and fails to allocate an item.
+The function will be called with the zone locked. Also, the function
+that called the allocation function may have held additional locks. Therefore,
+this function should do very little work (similar to a signal handler).
+.Pp
+The
.Fn SYSCTL_UMA_MAX parent nbr name access zone descr
macro declares a static
.Xr sysctl