aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/uma.h
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 /sys/vm/uma.h
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 'sys/vm/uma.h')
-rw-r--r--sys/vm/uma.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index d3e0658aef15..d218e60886dc 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -521,6 +521,19 @@ int uma_zone_get_max(uma_zone_t zone);
void uma_zone_set_warning(uma_zone_t zone, const char *warning);
/*
+ * Sets a function to run when limit is reached
+ *
+ * Arguments:
+ * zone The zone to which this applies
+ * fx The function ro run
+ *
+ * Returns:
+ * Nothing
+ */
+typedef void (*uma_maxaction_t)(uma_zone_t);
+void uma_zone_set_maxaction(uma_zone_t zone, uma_maxaction_t);
+
+/*
* Obtains the approximate current number of items allocated from a zone
*
* Arguments: