1/*- 2 * Copyright (c) 2004, 2005, |
3 * Bosko Milekic |
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 9 * notice unmodified, this list of conditions and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright --- 9 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 243995 2012-12-07 22:19:41Z pjd $"); |
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> --- 33 unchanged lines hidden (view full) --- 71 * m_clget() m_getcl() 72 * | | 73 * | .------------>[(Packet Cache)] m_get(), m_gethdr() 74 * | | [ Packet ] | 75 * [(Cluster Cache)] [ Secondary ] [ (Mbuf Cache) ] 76 * [ Cluster Zone ] [ Zone ] [ Mbuf Master Zone ] 77 * | \________ | 78 * [ Cluster Keg ] \ / |
79 * | [ Mbuf Keg ] |
80 * [ Cluster Slabs ] | 81 * | [ Mbuf Slabs ] 82 * \____________(VM)_________________/ 83 * 84 * 85 * Whenever an object is allocated with uma_zalloc() out of 86 * one of the Zones its _ctor_ function is executed. The same 87 * for any deallocation through uma_zfree() the _dtor_ function --- 55 unchanged lines hidden (view full) --- 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 150 newnmbclusters = nmbclusters; |
151 error = sysctl_handle_int(oidp, &newnmbclusters, 0, req); |
152 if (error == 0 && req->newptr) { 153 if (newnmbclusters > nmbclusters && 154 nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) { 155 nmbclusters = newnmbclusters; 156 uma_zone_set_max(zone_clust, nmbclusters); 157 nmbclusters = uma_zone_get_max(zone_clust); 158 EVENTHANDLER_INVOKE(nmbclusters_change); 159 } else --- 6 unchanged lines hidden (view full) --- 166 "Maximum number of mbuf clusters allowed"); 167 168static int 169sysctl_nmbjumbop(SYSCTL_HANDLER_ARGS) 170{ 171 int error, newnmbjumbop; 172 173 newnmbjumbop = nmbjumbop; |
174 error = sysctl_handle_int(oidp, &newnmbjumbop, 0, req); |
175 if (error == 0 && req->newptr) { 176 if (newnmbjumbop > nmbjumbop && 177 nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) { 178 nmbjumbop = newnmbjumbop; 179 uma_zone_set_max(zone_jumbop, nmbjumbop); 180 nmbjumbop = uma_zone_get_max(zone_jumbop); 181 } else 182 error = EINVAL; 183 } 184 return (error); 185} 186SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbop, CTLTYPE_INT|CTLFLAG_RW, 187&nmbjumbop, 0, sysctl_nmbjumbop, "IU", |
188 "Maximum number of mbuf page size jumbo clusters allowed"); |
189 |
190static int 191sysctl_nmbjumbo9(SYSCTL_HANDLER_ARGS) 192{ 193 int error, newnmbjumbo9; 194 195 newnmbjumbo9 = nmbjumbo9; |
196 error = sysctl_handle_int(oidp, &newnmbjumbo9, 0, req); |
197 if (error == 0 && req->newptr) { 198 if (newnmbjumbo9 > nmbjumbo9&& 199 nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) { 200 nmbjumbo9 = newnmbjumbo9; 201 uma_zone_set_max(zone_jumbo9, nmbjumbo9); 202 nmbjumbo9 = uma_zone_get_max(zone_jumbo9); 203 } else 204 error = EINVAL; 205 } 206 return (error); 207} 208SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbo9, CTLTYPE_INT|CTLFLAG_RW, 209&nmbjumbo9, 0, sysctl_nmbjumbo9, "IU", |
210 "Maximum number of mbuf 9k jumbo clusters allowed"); |
211 212static int 213sysctl_nmbjumbo16(SYSCTL_HANDLER_ARGS) 214{ 215 int error, newnmbjumbo16; 216 217 newnmbjumbo16 = nmbjumbo16; |
218 error = sysctl_handle_int(oidp, &newnmbjumbo16, 0, req); |
219 if (error == 0 && req->newptr) { 220 if (newnmbjumbo16 > nmbjumbo16 && 221 nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) { 222 nmbjumbo16 = newnmbjumbo16; 223 uma_zone_set_max(zone_jumbo16, nmbjumbo16); 224 nmbjumbo16 = uma_zone_get_max(zone_jumbo16); 225 } else 226 error = EINVAL; --- 5 unchanged lines hidden (view full) --- 232 "Maximum number of mbuf 16k jumbo clusters allowed"); 233 234static int 235sysctl_nmbufs(SYSCTL_HANDLER_ARGS) 236{ 237 int error, newnmbufs; 238 239 newnmbufs = nmbufs; |
240 error = sysctl_handle_int(oidp, &newnmbufs, 0, req); |
241 if (error == 0 && req->newptr) { 242 if (newnmbufs > nmbufs) { 243 nmbufs = newnmbufs; 244 uma_zone_set_max(zone_mbuf, nmbufs); 245 nmbufs = uma_zone_get_max(zone_mbuf); 246 EVENTHANDLER_INVOKE(nmbufs_change); 247 } else 248 error = EINVAL; 249 } 250 return (error); 251} 252SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbuf, CTLTYPE_INT|CTLFLAG_RW, 253&nmbufs, 0, sysctl_nmbufs, "IU", 254 "Maximum number of mbufs allowed"); 255 |
256SYSCTL_STRUCT(_kern_ipc, OID_AUTO, mbstat, CTLFLAG_RD, &mbstat, mbstat, 257 "Mbuf general information and statistics"); 258 259/* 260 * Zones from which we allocate. 261 */ 262uma_zone_t zone_mbuf; 263uma_zone_t zone_clust; --- 217 unchanged lines hidden (view full) --- 481 482/* 483 * The Mbuf master zone destructor. 484 */ 485static void 486mb_dtor_mbuf(void *mem, int size, void *arg) 487{ 488 struct mbuf *m; |
489 unsigned long flags; |
490 491 m = (struct mbuf *)mem; 492 flags = (unsigned long)arg; 493 494 if ((flags & MB_NOTAGS) == 0 && (m->m_flags & M_PKTHDR) != 0) 495 m_tag_delete_chain(m, NULL); 496 KASSERT((m->m_flags & M_EXT) == 0, ("%s: M_EXT set", __func__)); 497 KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__)); --- 257 unchanged lines hidden --- |