kern_mbuf.c (154722) | kern_mbuf.c (155051) |
---|---|
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> | 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 154722 2006-01-23 15:49:01Z andre $"); | 29__FBSDID("$FreeBSD: head/sys/kern/kern_mbuf.c 155051 2006-01-30 13:45:15Z glebius $"); |
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> --- 90 unchanged lines hidden (view full) --- 128 */ 129uma_zone_t zone_mbuf; 130uma_zone_t zone_clust; 131uma_zone_t zone_pack; 132uma_zone_t zone_jumbo4; 133uma_zone_t zone_jumbo9; 134uma_zone_t zone_jumbo16; 135uma_zone_t zone_ext_refcnt; | 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> --- 90 unchanged lines hidden (view full) --- 128 */ 129uma_zone_t zone_mbuf; 130uma_zone_t zone_clust; 131uma_zone_t zone_pack; 132uma_zone_t zone_jumbo4; 133uma_zone_t zone_jumbo9; 134uma_zone_t zone_jumbo16; 135uma_zone_t zone_ext_refcnt; |
136uma_zone_t zone_mtag_vlan; |
|
136 137/* 138 * Local prototypes. 139 */ 140static int mb_ctor_mbuf(void *, int, void *, int); 141static int mb_ctor_clust(void *, int, void *, int); 142static int mb_ctor_pack(void *, int, void *, int); 143static void mb_dtor_mbuf(void *, int, void *); 144static void mb_dtor_clust(void *, int, void *); 145static void mb_dtor_pack(void *, int, void *); 146static int mb_zinit_pack(void *, int, int); 147static void mb_zfini_pack(void *, int); | 137 138/* 139 * Local prototypes. 140 */ 141static int mb_ctor_mbuf(void *, int, void *, int); 142static int mb_ctor_clust(void *, int, void *, int); 143static int mb_ctor_pack(void *, int, void *, int); 144static void mb_dtor_mbuf(void *, int, void *); 145static void mb_dtor_clust(void *, int, void *); 146static void mb_dtor_pack(void *, int, void *); 147static int mb_zinit_pack(void *, int, int); 148static void mb_zfini_pack(void *, int); |
149static int mt_zinit_vlan(void *, int, int); |
|
148 149static void mb_reclaim(void *); 150static void mbuf_init(void *); 151 152/* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */ 153CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); 154 155/* --- 64 unchanged lines hidden (view full) --- 220 if (nmbjumbo16 > 0) 221 uma_zone_set_max(zone_jumbo16, nmbjumbo16); 222 223 zone_ext_refcnt = uma_zcreate(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), 224 NULL, NULL, 225 NULL, NULL, 226 UMA_ALIGN_PTR, UMA_ZONE_ZINIT); 227 | 150 151static void mb_reclaim(void *); 152static void mbuf_init(void *); 153 154/* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */ 155CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); 156 157/* --- 64 unchanged lines hidden (view full) --- 222 if (nmbjumbo16 > 0) 223 uma_zone_set_max(zone_jumbo16, nmbjumbo16); 224 225 zone_ext_refcnt = uma_zcreate(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), 226 NULL, NULL, 227 NULL, NULL, 228 UMA_ALIGN_PTR, UMA_ZONE_ZINIT); 229 |
230 zone_mtag_vlan = uma_zcreate("mtag_vlan", 231 sizeof(struct m_tag) + sizeof(u_int), 232 NULL, NULL, 233 mt_zinit_vlan, NULL, 234 UMA_ALIGN_INT, 0); 235 |
|
228 /* uma_prealloc() goes here... */ 229 230 /* 231 * Hook event handler for low-memory situation, used to 232 * drain protocols and push data back to the caches (UMA 233 * later pushes it back to VM). 234 */ 235 EVENTHANDLER_REGISTER(vm_lowmem, mb_reclaim, NULL, --- 270 unchanged lines hidden (view full) --- 506 return (error); 507#endif 508 } 509 /* m_ext is already initialized. */ 510 511 return (0); 512} 513 | 236 /* uma_prealloc() goes here... */ 237 238 /* 239 * Hook event handler for low-memory situation, used to 240 * drain protocols and push data back to the caches (UMA 241 * later pushes it back to VM). 242 */ 243 EVENTHANDLER_REGISTER(vm_lowmem, mb_reclaim, NULL, --- 270 unchanged lines hidden (view full) --- 514 return (error); 515#endif 516 } 517 /* m_ext is already initialized. */ 518 519 return (0); 520} 521 |
522static void 523mt_vlan_free(struct m_tag *mtag) 524{ 525 uma_zfree(zone_mtag_vlan, mtag); 526} 527 528static int 529mt_zinit_vlan(void *mem, int size, int how) 530{ 531 struct m_tag *mtag = (struct m_tag *)mem; 532 533 m_tag_setup(mtag, MTAG_VLAN, MTAG_VLAN_TAG, sizeof(u_int)); 534 mtag->m_tag_free = mt_vlan_free; 535 536 return (0); 537} 538 |
|
514/* 515 * This is the protocol drain routine. 516 * 517 * No locks should be held when this is called. The drain routines have to 518 * presently acquire some locks which raises the possibility of lock order 519 * reversal. 520 */ 521static void --- 13 unchanged lines hidden --- | 539/* 540 * This is the protocol drain routine. 541 * 542 * No locks should be held when this is called. The drain routines have to 543 * presently acquire some locks which raises the possibility of lock order 544 * reversal. 545 */ 546static void --- 13 unchanged lines hidden --- |