Lines 157-164
SYSCTL_ULONG(_vm, OID_AUTO, uma_kmem_total, CTLFLAG_RD, &uma_kmem_total, 0,
Link Here
|
157 |
"UMA kernel memory usage"); |
157 |
"UMA kernel memory usage"); |
158 |
|
158 |
|
159 |
/* Is the VM done starting up? */ |
159 |
/* Is the VM done starting up? */ |
160 |
static enum { BOOT_COLD = 0, BOOT_STRAPPED, BOOT_PAGEALLOC, BOOT_BUCKETS, |
160 |
static enum { |
161 |
BOOT_RUNNING } booted = BOOT_COLD; |
161 |
BOOT_COLD, |
|
|
162 |
BOOT_STRAPPED, |
163 |
BOOT_PAGEALLOC, |
164 |
BOOT_BUCKETS, |
165 |
BOOT_RUNNING, |
166 |
BOOT_SHUTDOWN, |
167 |
} booted = BOOT_COLD; |
162 |
|
168 |
|
163 |
/* |
169 |
/* |
164 |
* This is the handle used to schedule events that need to happen |
170 |
* This is the handle used to schedule events that need to happen |
Lines 266-271
static int hash_expand(struct uma_hash *, struct uma_hash *);
Link Here
|
266 |
static void hash_free(struct uma_hash *hash); |
272 |
static void hash_free(struct uma_hash *hash); |
267 |
static void uma_timeout(void *); |
273 |
static void uma_timeout(void *); |
268 |
static void uma_startup3(void); |
274 |
static void uma_startup3(void); |
|
|
275 |
static void uma_shutdown(void); |
269 |
static void *zone_alloc_item(uma_zone_t, void *, int, int); |
276 |
static void *zone_alloc_item(uma_zone_t, void *, int, int); |
270 |
static void *zone_alloc_item_locked(uma_zone_t, void *, int, int); |
277 |
static void *zone_alloc_item_locked(uma_zone_t, void *, int, int); |
271 |
static void zone_free_item(uma_zone_t, void *, void *, enum zfreeskip); |
278 |
static void zone_free_item(uma_zone_t, void *, void *, enum zfreeskip); |
Lines 1254-1261
startup_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *pflag,
Link Here
|
1254 |
case BOOT_PAGEALLOC: |
1261 |
case BOOT_PAGEALLOC: |
1255 |
if (keg->uk_ppera > 1) |
1262 |
if (keg->uk_ppera > 1) |
1256 |
break; |
1263 |
break; |
1257 |
case BOOT_BUCKETS: |
1264 |
default: |
1258 |
case BOOT_RUNNING: |
|
|
1259 |
#ifdef UMA_MD_SMALL_ALLOC |
1265 |
#ifdef UMA_MD_SMALL_ALLOC |
1260 |
keg->uk_allocf = (keg->uk_ppera > 1) ? |
1266 |
keg->uk_allocf = (keg->uk_ppera > 1) ? |
1261 |
page_alloc : uma_small_alloc; |
1267 |
page_alloc : uma_small_alloc; |
Lines 2149-2155
zone_ctor(void *mem, int size, void *udata, int flags)
Link Here
|
2149 |
(UMA_ZONE_INHERIT | UMA_ZFLAG_INHERIT)); |
2155 |
(UMA_ZONE_INHERIT | UMA_ZFLAG_INHERIT)); |
2150 |
|
2156 |
|
2151 |
out: |
2157 |
out: |
2152 |
if (__predict_true(booted == BOOT_RUNNING)) { |
2158 |
if (__predict_true(booted >= BOOT_RUNNING)) { |
2153 |
zone_alloc_counters(zone, NULL); |
2159 |
zone_alloc_counters(zone, NULL); |
2154 |
zone_alloc_sysctl(zone, NULL); |
2160 |
zone_alloc_sysctl(zone, NULL); |
2155 |
} else { |
2161 |
} else { |
Lines 2271-2277
zone_foreach(void (*zfunc)(uma_zone_t, void *arg), void *arg)
Link Here
|
2271 |
* threaded, so locking isn't needed. Startup functions |
2277 |
* threaded, so locking isn't needed. Startup functions |
2272 |
* are allowed to use M_WAITOK. |
2278 |
* are allowed to use M_WAITOK. |
2273 |
*/ |
2279 |
*/ |
2274 |
if (__predict_true(booted == BOOT_RUNNING)) |
2280 |
if (__predict_true(booted >= BOOT_RUNNING)) |
2275 |
rw_rlock(&uma_rwlock); |
2281 |
rw_rlock(&uma_rwlock); |
2276 |
LIST_FOREACH(keg, &uma_kegs, uk_link) { |
2282 |
LIST_FOREACH(keg, &uma_kegs, uk_link) { |
2277 |
LIST_FOREACH(zone, &keg->uk_zones, uz_link) |
2283 |
LIST_FOREACH(zone, &keg->uk_zones, uz_link) |
Lines 2279-2285
zone_foreach(void (*zfunc)(uma_zone_t, void *arg), void *arg)
Link Here
|
2279 |
} |
2285 |
} |
2280 |
LIST_FOREACH(zone, &uma_cachezones, uz_link) |
2286 |
LIST_FOREACH(zone, &uma_cachezones, uz_link) |
2281 |
zfunc(zone, arg); |
2287 |
zfunc(zone, arg); |
2282 |
if (__predict_true(booted == BOOT_RUNNING)) |
2288 |
if (__predict_true(booted >= BOOT_RUNNING)) |
2283 |
rw_runlock(&uma_rwlock); |
2289 |
rw_runlock(&uma_rwlock); |
2284 |
} |
2290 |
} |
2285 |
|
2291 |
|
Lines 2431-2440
uma_startup2(void)
Link Here
|
2431 |
bucket_enable(); |
2437 |
bucket_enable(); |
2432 |
} |
2438 |
} |
2433 |
|
2439 |
|
2434 |
/* |
|
|
2435 |
* Initialize our callout handle |
2436 |
* |
2437 |
*/ |
2438 |
static void |
2440 |
static void |
2439 |
uma_startup3(void) |
2441 |
uma_startup3(void) |
2440 |
{ |
2442 |
{ |
Lines 2449-2454
uma_startup3(void)
Link Here
|
2449 |
callout_init(&uma_callout, 1); |
2451 |
callout_init(&uma_callout, 1); |
2450 |
callout_reset(&uma_callout, UMA_TIMEOUT * hz, uma_timeout, NULL); |
2452 |
callout_reset(&uma_callout, UMA_TIMEOUT * hz, uma_timeout, NULL); |
2451 |
booted = BOOT_RUNNING; |
2453 |
booted = BOOT_RUNNING; |
|
|
2454 |
|
2455 |
EVENTHANDLER_REGISTER(shutdown_post_sync, uma_shutdown, NULL, |
2456 |
EVENTHANDLER_PRI_FIRST); |
2457 |
} |
2458 |
|
2459 |
static void |
2460 |
uma_shutdown(void) |
2461 |
{ |
2462 |
|
2463 |
booted = BOOT_SHUTDOWN; |
2452 |
} |
2464 |
} |
2453 |
|
2465 |
|
2454 |
static uma_keg_t |
2466 |
static uma_keg_t |
Lines 2599-2604
void
Link Here
|
2599 |
uma_zdestroy(uma_zone_t zone) |
2611 |
uma_zdestroy(uma_zone_t zone) |
2600 |
{ |
2612 |
{ |
2601 |
|
2613 |
|
|
|
2614 |
if (booted == BOOT_SHUTDOWN) |
2615 |
return; |
2602 |
sx_slock(&uma_reclaim_lock); |
2616 |
sx_slock(&uma_reclaim_lock); |
2603 |
zone_free_item(zones, zone, NULL, SKIP_NONE); |
2617 |
zone_free_item(zones, zone, NULL, SKIP_NONE); |
2604 |
sx_sunlock(&uma_reclaim_lock); |
2618 |
sx_sunlock(&uma_reclaim_lock); |