From 5dfe609dd12c42754d3a2ee03e036b7ca4d5da07 Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Sun, 2 Mar 2003 18:04:10 +0000 Subject: [PATCH] Add two loader tuneables that allow one to change the maximum number of queue items that can be allocated by netgraph and the number of free queue items that are cached on a private list. Netgraph places an upper limit on the number of queue items it may allocate. When there is a large number of netgraph messages travelling through the system (100k/sec and more) there is a high probability, that messages get queued at the nodes and netgraph runs out of queue items. In this case the data flow through netgraph gets blocked. The tuneable for the number of free items lets one trade memory for performance. The tunables are also available as read-only sysctls. PR: kern/47393 Reviewed by: julian Approved by: jake (mentor) --- sys/boot/forth/loader.conf | 2 ++ sys/netgraph/ng_base.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf index 06a76f6b389..73e42eb789f 100644 --- a/sys/boot/forth/loader.conf +++ b/sys/boot/forth/loader.conf @@ -102,6 +102,8 @@ module_path="/boot/kernel;/boot/modules;/modules" # Set the module search path #debug.ktr.cpumask="0xf" # Bitmask of CPUs to enable KTR on #debug.ktr.mask="0x1200" # Bitmask of KTR events to enable #debug.ktr.verbose="1" # Enable console dump of KTR events +#net.graph.maxalloc="128" # Maximum number of queue items to allocate +#net.graph.ngqfreemax="64" # Maximum number of free queue items to cache ############################################################## diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index eb5a8eb9e11..4c8dde3dba0 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -3017,8 +3017,18 @@ SYSCTL_INT(_net_graph, OID_AUTO, msg_version, CTLFLAG_RD, 0, NG_VERSION, ""); static int allocated; /* number of items malloc'd */ + static int maxalloc = 128; /* limit the damage of a leak */ -static const int ngqfreemax = 64;/* cache at most this many */ +static int ngqfreemax = 64;/* cache at most this many */ + +TUNABLE_INT("net.graph.maxalloc", &maxalloc); +SYSCTL_INT(_net_graph, OID_AUTO, maxalloc, CTLFLAG_RD, &maxalloc, + 0, "Maximum number of queue items to allocate"); + +TUNABLE_INT("net.graph.ngqfreemax", &ngqfreemax); +SYSCTL_INT(_net_graph, OID_AUTO, ngqfreemax, CTLFLAG_RD, &ngqfreemax, + 0, "Maximum number of free queue items to cache"); + static const int ngqfreelow = 4; /* try malloc if free < this */ static volatile int ngqfreesize; /* number of cached entries */ #ifdef NETGRAPH_DEBUG