1/*- 2 * Copyright (c) 2004, 2005, 3 * Bosko Milekic <bmilekic@FreeBSD.org>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/kern/kern_mbuf.c 243639 2012-11-27 23:16:56Z andre $"); |
30 31#include "opt_param.h" 32 33#include <sys/param.h> 34#include <sys/malloc.h> 35#include <sys/systm.h> 36#include <sys/mbuf.h> 37#include <sys/domain.h> --- 64 unchanged lines hidden (view full) --- 102int nmbjumbo9; /* limits number of 9k jumbo clusters */ 103int nmbjumbo16; /* limits number of 16k jumbo clusters */ 104struct mbstat mbstat; 105 106/* 107 * tunable_mbinit() has to be run before init_maxsockets() thus 108 * the SYSINIT order below is SI_ORDER_MIDDLE while init_maxsockets() 109 * runs at SI_ORDER_ANY. |
110 * 111 * NB: This has to be done before VM init. |
112 */ 113static void 114tunable_mbinit(void *dummy) 115{ 116 |
117 TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters); |
118 if (nmbclusters == 0) 119 nmbclusters = maxmbufmem / MCLBYTES / 4; |
120 121 TUNABLE_INT_FETCH("kern.ipc.nmbjumbop", &nmbjumbop); 122 if (nmbjumbop == 0) |
123 nmbjumbop = maxmbufmem / MJUMPAGESIZE / 4; |
124 125 TUNABLE_INT_FETCH("kern.ipc.nmbjumbo9", &nmbjumbo9); 126 if (nmbjumbo9 == 0) |
127 nmbjumbo9 = maxmbufmem / MJUM9BYTES / 6; |
128 129 TUNABLE_INT_FETCH("kern.ipc.nmbjumbo16", &nmbjumbo16); 130 if (nmbjumbo16 == 0) |
131 nmbjumbo16 = maxmbufmem / MJUM16BYTES / 6; 132 133 /* 134 * We need at least as many mbufs as we have clusters of 135 * the various types added together. 136 */ 137 TUNABLE_INT_FETCH("kern.ipc.nmbufs", &nmbufs); 138 if (nmbufs < nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) 139 nmbufs = lmax(maxmbufmem / MSIZE / 5, 140 nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16); 141 |
142} 143SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_mbinit, NULL); 144 145static int 146sysctl_nmbclusters(SYSCTL_HANDLER_ARGS) 147{ 148 int error, newnmbclusters; 149 --- 88 unchanged lines hidden (view full) --- 238 int error, newnmbufs; 239 240 newnmbufs = nmbufs; 241 error = sysctl_handle_int(oidp, &newnmbufs, 0, req); 242 if (error == 0 && req->newptr) { 243 if (newnmbufs > nmbufs) { 244 nmbufs = newnmbufs; 245 uma_zone_set_max(zone_mbuf, nmbufs); |
246 nmbufs = uma_zone_get_max(zone_mbuf); |
247 EVENTHANDLER_INVOKE(nmbufs_change); 248 } else 249 error = EINVAL; 250 } 251 return (error); 252} 253SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbuf, CTLTYPE_INT|CTLFLAG_RW, 254&nmbufs, 0, sysctl_nmbufs, "IU", --- 502 unchanged lines hidden --- |