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 252040 2013-06-20 19:08:12Z 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_padalign 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 struct mtx_padalign uz_lock; /* Lock for the zone */
285 struct mtx_padalign *uz_lockptr;
286 const char *uz_name; /* Text name of the zone */
287
288 LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */
289 LIST_HEAD(,uma_bucket) uz_buckets; /* full buckets */
290
291 LIST_HEAD(,uma_klink) uz_kegs; /* List of kegs. */
292 struct uma_klink uz_klink; /* klink for first keg. */
293
294 uma_slaballoc uz_slab; /* Allocate a slab from the backend. */
--- 35 unchanged lines hidden (view full) ---
330#define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */
331#define UMA_ZFLAG_CACHEONLY 0x80000000 /* Don't ask VM for buckets. */
332
333#define UMA_ZFLAG_INHERIT (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY)
334
335static inline uma_keg_t
336zone_first_keg(uma_zone_t zone)
337{
338 uma_klink_t klink;
339
340 klink = LIST_FIRST(&zone->uz_kegs);
341 return (klink != NULL) ? klink->kl_keg : NULL;
342}
343
344#undef UMA_ALIGN
345
346#ifdef _KERNEL
347/* Internal prototypes */
348static __inline uma_slab_t hash_sfind(struct uma_hash *hash, uint8_t *data);
349void *uma_large_malloc(int size, int wait);
--- 5 unchanged lines hidden (view full) ---
355 do { \
356 if ((lc)) \
357 mtx_init(&(k)->uk_lock, (k)->uk_name, \
358 (k)->uk_name, MTX_DEF | MTX_DUPOK); \
359 else \
360 mtx_init(&(k)->uk_lock, (k)->uk_name, \
361 "UMA zone", MTX_DEF | MTX_DUPOK); \
362 } while (0)
363
364#define KEG_LOCK_FINI(k) mtx_destroy(&(k)->uk_lock)
365#define KEG_LOCK(k) mtx_lock(&(k)->uk_lock)
366#define KEG_UNLOCK(k) mtx_unlock(&(k)->uk_lock)
367
368#define ZONE_LOCK_INIT(z, lc) \
369 do { \
370 if ((lc)) \
371 mtx_init(&(z)->uz_lock, (z)->uz_name, \
372 (z)->uz_name, MTX_DEF | MTX_DUPOK); \
373 else \
374 mtx_init(&(z)->uz_lock, (z)->uz_name, \
375 "UMA zone", MTX_DEF | MTX_DUPOK); \
376 } while (0)
377
378#define ZONE_LOCK(z) mtx_lock((z)->uz_lockptr)
379#define ZONE_TRYLOCK(z) mtx_trylock((z)->uz_lockptr)
380#define ZONE_UNLOCK(z) mtx_unlock((z)->uz_lockptr)
381#define ZONE_LOCK_FINI(z) mtx_destroy(&(z)->uz_lock)
382
383/*
384 * Find a slab within a hash table. This is used for OFFPAGE zones to lookup
385 * the slab structure.
386 *
387 * Arguments:
388 * hash The hash table to search.
389 * data The base page of the item.
390 *
--- 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 252040 2013-06-20 19:08:12Z 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_padalign 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 struct mtx_padalign uz_lock; /* Lock for the zone */
285 struct mtx_padalign *uz_lockptr;
286 const char *uz_name; /* Text name of the zone */
287
288 LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */
289 LIST_HEAD(,uma_bucket) uz_buckets; /* full buckets */
290
291 LIST_HEAD(,uma_klink) uz_kegs; /* List of kegs. */
292 struct uma_klink uz_klink; /* klink for first keg. */
293
294 uma_slaballoc uz_slab; /* Allocate a slab from the backend. */
--- 35 unchanged lines hidden (view full) ---
330#define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */
331#define UMA_ZFLAG_CACHEONLY 0x80000000 /* Don't ask VM for buckets. */
332
333#define UMA_ZFLAG_INHERIT (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY)
334
335static inline uma_keg_t
336zone_first_keg(uma_zone_t zone)
337{
338 uma_klink_t klink;
339
340 klink = LIST_FIRST(&zone->uz_kegs);
341 return (klink != NULL) ? klink->kl_keg : NULL;
342}
343
344#undef UMA_ALIGN
345
346#ifdef _KERNEL
347/* Internal prototypes */
348static __inline uma_slab_t hash_sfind(struct uma_hash *hash, uint8_t *data);
349void *uma_large_malloc(int size, int wait);
--- 5 unchanged lines hidden (view full) ---
355 do { \
356 if ((lc)) \
357 mtx_init(&(k)->uk_lock, (k)->uk_name, \
358 (k)->uk_name, MTX_DEF | MTX_DUPOK); \
359 else \
360 mtx_init(&(k)->uk_lock, (k)->uk_name, \
361 "UMA zone", MTX_DEF | MTX_DUPOK); \
362 } while (0)
363
364#define KEG_LOCK_FINI(k) mtx_destroy(&(k)->uk_lock)
365#define KEG_LOCK(k) mtx_lock(&(k)->uk_lock)
366#define KEG_UNLOCK(k) mtx_unlock(&(k)->uk_lock)
367
368#define ZONE_LOCK_INIT(z, lc) \
369 do { \
370 if ((lc)) \
371 mtx_init(&(z)->uz_lock, (z)->uz_name, \
372 (z)->uz_name, MTX_DEF | MTX_DUPOK); \
373 else \
374 mtx_init(&(z)->uz_lock, (z)->uz_name, \
375 "UMA zone", MTX_DEF | MTX_DUPOK); \
376 } while (0)
377
378#define ZONE_LOCK(z) mtx_lock((z)->uz_lockptr)
379#define ZONE_TRYLOCK(z) mtx_trylock((z)->uz_lockptr)
380#define ZONE_UNLOCK(z) mtx_unlock((z)->uz_lockptr)
381#define ZONE_LOCK_FINI(z) mtx_destroy(&(z)->uz_lock)
382
383/*
384 * Find a slab within a hash table. This is used for OFFPAGE zones to lookup
385 * the slab structure.
386 *
387 * Arguments:
388 * hash The hash table to search.
389 * data The base page of the item.
390 *
--- 63 unchanged lines hidden ---