Deleted Added
full compact
uma_core.c (92654) uma_core.c (92758)
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 *
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 92654 2002-03-19 09:11:49Z jeff $
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
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);
602
603 if (booted || (zone->uz_flags & UMA_ZFLAG_PRIVALLOC)) {
604 ZONE_UNLOCK(zone);
605 mtx_lock(&Giant);
606 slab = (uma_slab_t )zone->uz_allocf(zone,
607 zone->uz_ppera * UMA_SLAB_SIZE, &flags, wait);
608 mtx_unlock(&Giant);
609 ZONE_LOCK(zone);

--- 119 unchanged lines hidden (view full) ---

729static void *
730obj_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
731{
732 vm_offset_t zkva;
733 vm_offset_t retkva;
734 vm_page_t p;
735 int pages;
736
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
737
738 if (zone->uz_pages + zone->uz_ppera > zone->uz_maxpages)
739 return (NULL);
740
741 retkva = NULL;
742 pages = zone->uz_pages;
743
744 /*
745 * This looks a little weird since we're getting one page at a time
746 */
747 while (bytes > 0) {
748 p = vm_page_alloc(zone->uz_obj, pages,

--- 488 unchanged lines hidden (view full) ---

1237
1238 if (item && isitem == 0)
1239 goto zalloc_start;
1240
1241 /*
1242 * If isitem is set then we should just return it. The cpu lock
1243 * was unlocked when we couldn't get a bucket.
1244 */
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 */
1245
1246#ifdef INVARIANTS
1247 if (wait == M_WAITOK)
1248 KASSERT(item != NULL,
1249 ("uma_zalloc: WAITOK set but we're returning NULL"));
1250#endif
1251 return item;
1252}
1253
1254/*
1255 * Allocates an item for an internal zone OR fills a bucket
1256 *
1257 * Arguments
1258 * zone The zone to alloc for.

--- 414 unchanged lines hidden (view full) ---

1673 ZONE_UNLOCK(zone);
1674
1675 if (!skip && zone->uz_dtor)
1676 zone->uz_dtor(item, zone->uz_size, udata);
1677}
1678
1679/* See uma.h */
1680void
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
1681uma_zone_set_freef(uma_zone_t zone, uma_free freef)
1682{
1683 ZONE_LOCK(zone);
1684
1685 zone->uz_freef = freef;
1686
1687 ZONE_UNLOCK(zone);
1688}

--- 212 unchanged lines hidden ---
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 ---