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 155780 2006-02-17 14:14:15Z andre $"); |
30 31#include "opt_mac.h" 32#include "opt_param.h" 33 34#include <sys/param.h> 35#include <sys/mac.h> 36#include <sys/malloc.h> 37#include <sys/systm.h> --- 52 unchanged lines hidden (view full) --- 90 * Whenever a object is allocated from the underlying global 91 * memory pool it gets pre-initialized with the _zinit_ functions. 92 * When the Keg's are overfull objects get decomissioned with 93 * _zfini_ functions and free'd back to the global memory pool. 94 * 95 */ 96 97int nmbclusters; /* limits number of mbuf clusters */ |
98int nmbjumbop; /* limits number of page size jumbo clusters */ |
99int nmbjumbo9; /* limits number of 9k jumbo clusters */ 100int nmbjumbo16; /* limits number of 16k jumbo clusters */ 101struct mbstat mbstat; 102 103static void 104tunable_mbinit(void *dummy) 105{ 106 107 /* This has to be done before VM init. */ 108 nmbclusters = 1024 + maxusers * 64; 109 TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters); 110} 111SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_ANY, tunable_mbinit, NULL); 112 113SYSCTL_DECL(_kern_ipc); 114/* XXX: These should be tuneables. Can't change UMA limits on the fly. */ 115SYSCTL_INT(_kern_ipc, OID_AUTO, nmbclusters, CTLFLAG_RW, &nmbclusters, 0, 116 "Maximum number of mbuf clusters allowed"); |
117SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbop, CTLFLAG_RW, &nmbjumbop, 0, 118 "Maximum number of mbuf page size jumbo clusters allowed"); |
119SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo9, CTLFLAG_RW, &nmbjumbo9, 0, 120 "Maximum number of mbuf 9k jumbo clusters allowed"); 121SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo16, CTLFLAG_RW, &nmbjumbo16, 0, 122 "Maximum number of mbuf 16k jumbo clusters allowed"); 123SYSCTL_STRUCT(_kern_ipc, OID_AUTO, mbstat, CTLFLAG_RD, &mbstat, mbstat, 124 "Mbuf general information and statistics"); 125 126/* 127 * Zones from which we allocate. 128 */ 129uma_zone_t zone_mbuf; 130uma_zone_t zone_clust; 131uma_zone_t zone_pack; |
132uma_zone_t zone_jumbop; |
133uma_zone_t zone_jumbo9; 134uma_zone_t zone_jumbo16; 135uma_zone_t zone_ext_refcnt; 136uma_zone_t zone_mtag_vlan; 137 138/* 139 * Local prototypes. 140 */ --- 43 unchanged lines hidden (view full) --- 184 UMA_ALIGN_PTR, UMA_ZONE_REFCNT); 185 if (nmbclusters > 0) 186 uma_zone_set_max(zone_clust, nmbclusters); 187 188 zone_pack = uma_zsecond_create(MBUF_PACKET_MEM_NAME, mb_ctor_pack, 189 mb_dtor_pack, mb_zinit_pack, mb_zfini_pack, zone_mbuf); 190 191 /* Make jumbo frame zone too. 4k, 9k and 16k. */ |
192 zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, |
193 mb_ctor_clust, mb_dtor_clust, 194#ifdef INVARIANTS 195 trash_init, trash_fini, 196#else 197 NULL, NULL, 198#endif 199 UMA_ALIGN_PTR, UMA_ZONE_REFCNT); |
200 if (nmbjumbop > 0) 201 uma_zone_set_max(zone_jumbop, nmbjumbop); |
202 203 zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES, 204 mb_ctor_clust, mb_dtor_clust, 205#ifdef INVARIANTS 206 trash_init, trash_fini, 207#else 208 NULL, NULL, 209#endif --- 148 unchanged lines hidden (view full) --- 358 KASSERT(m->m_ext.ext_type == EXT_PACKET, ("%s: ext_type != EXT_PACKET", __func__)); 359 KASSERT(*m->m_ext.ref_cnt == 1, ("%s: ref_cnt != 1", __func__)); 360#ifdef INVARIANTS 361 trash_dtor(m->m_ext.ext_buf, MCLBYTES, arg); 362#endif 363} 364 365/* |
366 * The Cluster and Jumbo[PAGESIZE|9|16] zone constructor. |
367 * 368 * Here the 'arg' pointer points to the Mbuf which we 369 * are configuring cluster storage for. If 'arg' is 370 * empty we allocate just the cluster without setting 371 * the mbuf to it. See mbuf.h. 372 */ 373static int 374mb_ctor_clust(void *mem, int size, void *arg, int how) --- 6 unchanged lines hidden (view full) --- 381 trash_ctor(mem, size, arg, how); 382#endif 383 m = (struct mbuf *)arg; 384 if (m != NULL) { 385 switch (size) { 386 case MCLBYTES: 387 type = EXT_CLUSTER; 388 break; |
389#if MJUMPAGESIZE != MCLBYTES 390 case MJUMPAGESIZE: 391 type = EXT_JUMBOP; |
392 break; 393#endif 394 case MJUM9BYTES: 395 type = EXT_JUMBO9; 396 break; 397 case MJUM16BYTES: 398 type = EXT_JUMBO16; 399 break; --- 160 unchanged lines hidden --- |