1/*-
2 * Copyright (c) 2002-2005, 2009, 2013 Jeffrey Roberson <jeff@FreeBSD.org>
3 * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
--- 10 unchanged lines hidden (view full) ---
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/vm/uma_int.h 251894 2013-06-18 04:50:20Z jeff $
28 *
29 */
30
31/*
32 * This file includes definitions, structures, prototypes, and inlines that
33 * should not be used outside of the actual implementation of UMA.
34 */
35
--- 148 unchanged lines hidden (view full) ---
184
185/*
186 * Keg management structure
187 *
188 * TODO: Optimize for cache line size
189 *
190 */
191struct uma_keg {
192 struct mtx uk_lock; /* Lock for the keg */
193 struct uma_hash uk_hash;
194
195 LIST_HEAD(,uma_zone) uk_zones; /* Keg's zones */
196 LIST_HEAD(,uma_slab) uk_part_slab; /* partially allocated slabs */
197 LIST_HEAD(,uma_slab) uk_free_slab; /* empty slab list */
198 LIST_HEAD(,uma_slab) uk_full_slab; /* full slabs */
199
200 uint32_t uk_align; /* Alignment mask */
--- 75 unchanged lines hidden (view full) ---
276
277/*
278 * Zone management structure
279 *
280 * TODO: Optimize for cache line size
281 *
282 */
283struct uma_zone {
284 const char *uz_name; /* Text name of the zone */
285 struct mtx *uz_lock; /* Lock for the zone (keg's lock) */
286
287 LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */
288 LIST_HEAD(,uma_bucket) uz_buckets; /* full buckets */
289
290 LIST_HEAD(,uma_klink) uz_kegs; /* List of kegs. */
291 struct uma_klink uz_klink; /* klink for first keg. */
292
293 uma_slaballoc uz_slab; /* Allocate a slab from the backend. */
--- 35 unchanged lines hidden (view full) ---
329#define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */
330#define UMA_ZFLAG_CACHEONLY 0x80000000 /* Don't ask VM for buckets. */
331
332#define UMA_ZFLAG_INHERIT (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY)
333
334static inline uma_keg_t
335zone_first_keg(uma_zone_t zone)
336{
337
338 return (LIST_FIRST(&zone->uz_kegs)->kl_keg);
339}
340
341#undef UMA_ALIGN
342
343#ifdef _KERNEL
344/* Internal prototypes */
345static __inline uma_slab_t hash_sfind(struct uma_hash *hash, uint8_t *data);
346void *uma_large_malloc(int size, int wait);
--- 5 unchanged lines hidden (view full) ---
352 do { \
353 if ((lc)) \
354 mtx_init(&(k)->uk_lock, (k)->uk_name, \
355 (k)->uk_name, MTX_DEF | MTX_DUPOK); \
356 else \
357 mtx_init(&(k)->uk_lock, (k)->uk_name, \
358 "UMA zone", MTX_DEF | MTX_DUPOK); \
359 } while (0)
360
361#define KEG_LOCK_FINI(k) mtx_destroy(&(k)->uk_lock)
362#define KEG_LOCK(k) mtx_lock(&(k)->uk_lock)
363#define KEG_UNLOCK(k) mtx_unlock(&(k)->uk_lock)
364#define ZONE_LOCK(z) mtx_lock((z)->uz_lock)
365#define ZONE_TRYLOCK(z) mtx_trylock((z)->uz_lock)
366#define ZONE_UNLOCK(z) mtx_unlock((z)->uz_lock)
367
368/*
369 * Find a slab within a hash table. This is used for OFFPAGE zones to lookup
370 * the slab structure.
371 *
372 * Arguments:
373 * hash The hash table to search.
374 * data The base page of the item.
375 *
--- 63 unchanged lines hidden ---
2 * Copyright (c) 2002-2005, 2009, 2013 Jeffrey Roberson <jeff@FreeBSD.org>
3 * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
--- 10 unchanged lines hidden (view full) ---
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/vm/uma_int.h 251894 2013-06-18 04:50:20Z jeff $
28 *
29 */
30
31/*
32 * This file includes definitions, structures, prototypes, and inlines that
33 * should not be used outside of the actual implementation of UMA.
34 */
35
--- 148 unchanged lines hidden (view full) ---
184
185/*
186 * Keg management structure
187 *
188 * TODO: Optimize for cache line size
189 *
190 */
191struct uma_keg {
192 struct mtx uk_lock; /* Lock for the keg */
193 struct uma_hash uk_hash;
194
195 LIST_HEAD(,uma_zone) uk_zones; /* Keg's zones */
196 LIST_HEAD(,uma_slab) uk_part_slab; /* partially allocated slabs */
197 LIST_HEAD(,uma_slab) uk_free_slab; /* empty slab list */
198 LIST_HEAD(,uma_slab) uk_full_slab; /* full slabs */
199
200 uint32_t uk_align; /* Alignment mask */
--- 75 unchanged lines hidden (view full) ---
276
277/*
278 * Zone management structure
279 *
280 * TODO: Optimize for cache line size
281 *
282 */
283struct uma_zone {
284 const char *uz_name; /* Text name of the zone */
285 struct mtx *uz_lock; /* Lock for the zone (keg's lock) */
286
287 LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */
288 LIST_HEAD(,uma_bucket) uz_buckets; /* full buckets */
289
290 LIST_HEAD(,uma_klink) uz_kegs; /* List of kegs. */
291 struct uma_klink uz_klink; /* klink for first keg. */
292
293 uma_slaballoc uz_slab; /* Allocate a slab from the backend. */
--- 35 unchanged lines hidden (view full) ---
329#define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */
330#define UMA_ZFLAG_CACHEONLY 0x80000000 /* Don't ask VM for buckets. */
331
332#define UMA_ZFLAG_INHERIT (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY)
333
334static inline uma_keg_t
335zone_first_keg(uma_zone_t zone)
336{
337
338 return (LIST_FIRST(&zone->uz_kegs)->kl_keg);
339}
340
341#undef UMA_ALIGN
342
343#ifdef _KERNEL
344/* Internal prototypes */
345static __inline uma_slab_t hash_sfind(struct uma_hash *hash, uint8_t *data);
346void *uma_large_malloc(int size, int wait);
--- 5 unchanged lines hidden (view full) ---
352 do { \
353 if ((lc)) \
354 mtx_init(&(k)->uk_lock, (k)->uk_name, \
355 (k)->uk_name, MTX_DEF | MTX_DUPOK); \
356 else \
357 mtx_init(&(k)->uk_lock, (k)->uk_name, \
358 "UMA zone", MTX_DEF | MTX_DUPOK); \
359 } while (0)
360
361#define KEG_LOCK_FINI(k) mtx_destroy(&(k)->uk_lock)
362#define KEG_LOCK(k) mtx_lock(&(k)->uk_lock)
363#define KEG_UNLOCK(k) mtx_unlock(&(k)->uk_lock)
364#define ZONE_LOCK(z) mtx_lock((z)->uz_lock)
365#define ZONE_TRYLOCK(z) mtx_trylock((z)->uz_lock)
366#define ZONE_UNLOCK(z) mtx_unlock((z)->uz_lock)
367
368/*
369 * Find a slab within a hash table. This is used for OFFPAGE zones to lookup
370 * the slab structure.
371 *
372 * Arguments:
373 * hash The hash table to search.
374 * data The base page of the item.
375 *
--- 63 unchanged lines hidden ---