1/* 2 * Copyright (c) 2002, Jeffrey Roberson <jroberson@chesapeake.net> 3 * 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/vm/uma_core.c 92758 2002-03-20 05:28:34Z jeff $ |
27 * 28 */ 29 30/* 31 * uma_core.c Implementation of the Universal Memory allocator 32 * 33 * This allocator is intended to replace the multitude of similar object caches 34 * in the standard FreeBSD kernel. The intent is to be flexible as well as --- 559 unchanged lines hidden (view full) --- 594 uma_slab_t slab; /* Starting slab */ 595 u_int8_t *mem; 596 u_int8_t flags; 597 int i; 598 599#ifdef UMA_DEBUG 600 printf("slab_zalloc: Allocating a new slab for %s\n", zone->uz_name); 601#endif |
602 if (zone->uz_maxpages && 603 zone->uz_pages + zone->uz_ppera > zone->uz_maxpages) 604 return (NULL); |
605 606 if (booted || (zone->uz_flags & UMA_ZFLAG_PRIVALLOC)) { 607 ZONE_UNLOCK(zone); 608 mtx_lock(&Giant); 609 slab = (uma_slab_t )zone->uz_allocf(zone, 610 zone->uz_ppera * UMA_SLAB_SIZE, &flags, wait); 611 mtx_unlock(&Giant); 612 ZONE_LOCK(zone); --- 119 unchanged lines hidden (view full) --- 732static void * 733obj_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) 734{ 735 vm_offset_t zkva; 736 vm_offset_t retkva; 737 vm_page_t p; 738 int pages; 739 |
740 retkva = NULL; 741 pages = zone->uz_pages; 742 743 /* 744 * This looks a little weird since we're getting one page at a time 745 */ 746 while (bytes > 0) { 747 p = vm_page_alloc(zone->uz_obj, pages, --- 488 unchanged lines hidden (view full) --- 1236 1237 if (item && isitem == 0) 1238 goto zalloc_start; 1239 1240 /* 1241 * If isitem is set then we should just return it. The cpu lock 1242 * was unlocked when we couldn't get a bucket. 1243 */ |
1244 return item; 1245} 1246 1247/* 1248 * Allocates an item for an internal zone OR fills a bucket 1249 * 1250 * Arguments 1251 * zone The zone to alloc for. --- 414 unchanged lines hidden (view full) --- 1666 ZONE_UNLOCK(zone); 1667 1668 if (!skip && zone->uz_dtor) 1669 zone->uz_dtor(item, zone->uz_size, udata); 1670} 1671 1672/* See uma.h */ 1673void |
1674uma_zone_set_max(uma_zone_t zone, int nitems) 1675{ 1676 ZONE_LOCK(zone); 1677 if (zone->uz_ppera > 1) 1678 zone->uz_maxpages = nitems / zone->uz_ppera; 1679 else 1680 zone->uz_maxpages = nitems / zone->uz_ipers; 1681 ZONE_UNLOCK(zone); 1682} 1683 1684/* See uma.h */ 1685void |
1686uma_zone_set_freef(uma_zone_t zone, uma_free freef) 1687{ 1688 ZONE_LOCK(zone); 1689 1690 zone->uz_freef = freef; 1691 1692 ZONE_UNLOCK(zone); 1693} --- 212 unchanged lines hidden --- |