diff options
author | andre <andre@FreeBSD.org> | 2004-08-11 17:26:56 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2004-08-11 17:26:56 +0000 |
commit | 3dc2f7c66183e56bc9673fd0b559e8e0a60c67b8 (patch) | |
tree | 718a7c47c3e4dbd15c93c657ea370e79649f2815 /sys/net | |
parent | 5e29f016e37bb52cb85f2679d9d7d1058f9f3148 (diff) | |
download | FreeBSD-src-3dc2f7c66183e56bc9673fd0b559e8e0a60c67b8.zip FreeBSD-src-3dc2f7c66183e56bc9673fd0b559e8e0a60c67b8.tar.gz |
Convert the routing table to use an UMA zone for rtentries. The zone is
called "rtentry".
This saves a considerable amount of kernel memory. R_Zmalloc previously
used 256 byte blocks (plus kmalloc overhead) whereas UMA only needs 132
bytes.
Idea from: OpenBSD
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/route.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 5cd1f0d..c6c8b57 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -47,6 +47,8 @@ #include <netinet/in.h> #include <netinet/ip_mroute.h> +#include <vm/uma.h> + static struct rtstat rtstat; struct radix_node_head *rt_tables[AF_MAX+1]; @@ -81,9 +83,13 @@ rtable_init(void **table) dom->dom_rtoffset); } +static uma_zone_t rtzone; /* Routing table UMA zone. */ + static void route_init(void) { + rtzone = uma_zcreate("rtentry", sizeof(struct rtentry), NULL, NULL, + NULL, NULL, UMA_ALIGN_PTR, 0); rn_init(); /* initialize all zeroes, all ones, mask table */ rtable_init((void **)rt_tables); } @@ -292,7 +298,7 @@ rtfree(struct rtentry *rt) * and the rtentry itself of course */ RT_LOCK_DESTROY(rt); - Free(rt); + uma_zfree(rtzone, rt); return; } done: @@ -738,7 +744,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) ifa = info->rti_ifa; makeroute: - R_Zalloc(rt, struct rtentry *, sizeof(*rt)); + rt = uma_zalloc(rtzone, M_NOWAIT | M_ZERO); if (rt == NULL) senderr(ENOBUFS); RT_LOCK_INIT(rt); @@ -750,7 +756,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) RT_LOCK(rt); if ((error = rt_setgate(rt, dst, gateway)) != 0) { RT_LOCK_DESTROY(rt); - Free(rt); + uma_zfree(rtzone, rt); senderr(error); } @@ -810,7 +816,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) IFAFREE(rt->rt_ifa); Free(rt_key(rt)); RT_LOCK_DESTROY(rt); - Free(rt); + uma_zfree(rtzone, rt); senderr(EEXIST); } |