Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/uma_core.c
Show First 20 Lines • Show All 425 Lines • ▼ Show 20 Lines | zone_log_warning(uma_zone_t zone) | ||||
if (!zone_warnings || zone->uz_warning == NULL) | if (!zone_warnings || zone->uz_warning == NULL) | ||||
return; | return; | ||||
if (ratecheck(&zone->uz_ratecheck, &warninterval)) | if (ratecheck(&zone->uz_ratecheck, &warninterval)) | ||||
printf("[zone: %s] %s\n", zone->uz_name, zone->uz_warning); | printf("[zone: %s] %s\n", zone->uz_name, zone->uz_warning); | ||||
} | } | ||||
static inline void | |||||
zone_maxaction(uma_zone_t zone) | |||||
{ | |||||
if (zone->uz_maxaction) | |||||
(*zone->uz_maxaction)(zone); | |||||
} | |||||
static void | static void | ||||
zone_foreach_keg(uma_zone_t zone, void (*kegfn)(uma_keg_t)) | zone_foreach_keg(uma_zone_t zone, void (*kegfn)(uma_keg_t)) | ||||
{ | { | ||||
uma_klink_t klink; | uma_klink_t klink; | ||||
LIST_FOREACH(klink, &zone->uz_kegs, kl_link) | LIST_FOREACH(klink, &zone->uz_kegs, kl_link) | ||||
kegfn(klink->kl_keg); | kegfn(klink->kl_keg); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,131 Lines • ▼ Show 20 Lines | zone_ctor(void *mem, int size, void *udata, int flags) | ||||
zone->uz_frees = 0; | zone->uz_frees = 0; | ||||
zone->uz_fails = 0; | zone->uz_fails = 0; | ||||
zone->uz_sleeps = 0; | zone->uz_sleeps = 0; | ||||
zone->uz_count = 0; | zone->uz_count = 0; | ||||
zone->uz_count_min = 0; | zone->uz_count_min = 0; | ||||
zone->uz_flags = 0; | zone->uz_flags = 0; | ||||
zone->uz_warning = NULL; | zone->uz_warning = NULL; | ||||
timevalclear(&zone->uz_ratecheck); | timevalclear(&zone->uz_ratecheck); | ||||
zone->uz_maxaction = NULL; | |||||
keg = arg->keg; | keg = arg->keg; | ||||
ZONE_LOCK_INIT(zone, (arg->flags & UMA_ZONE_MTXCLASS)); | ZONE_LOCK_INIT(zone, (arg->flags & UMA_ZONE_MTXCLASS)); | ||||
/* | /* | ||||
* This is a pure cache zone, no kegs. | * This is a pure cache zone, no kegs. | ||||
*/ | */ | ||||
if (arg->import) { | if (arg->import) { | ||||
▲ Show 20 Lines • Show All 788 Lines • ▼ Show 20 Lines | if (keg->uk_maxpages && keg->uk_pages >= keg->uk_maxpages) { | ||||
keg->uk_flags |= UMA_ZFLAG_FULL; | keg->uk_flags |= UMA_ZFLAG_FULL; | ||||
/* | /* | ||||
* If this is not a multi-zone, set the FULL bit. | * If this is not a multi-zone, set the FULL bit. | ||||
* Otherwise slab_multi() takes care of it. | * Otherwise slab_multi() takes care of it. | ||||
*/ | */ | ||||
if ((zone->uz_flags & UMA_ZFLAG_MULTI) == 0) { | if ((zone->uz_flags & UMA_ZFLAG_MULTI) == 0) { | ||||
zone->uz_flags |= UMA_ZFLAG_FULL; | zone->uz_flags |= UMA_ZFLAG_FULL; | ||||
zone_log_warning(zone); | zone_log_warning(zone); | ||||
zone_maxaction(zone); | |||||
} | } | ||||
if (flags & M_NOWAIT) | if (flags & M_NOWAIT) | ||||
break; | break; | ||||
zone->uz_sleeps++; | zone->uz_sleeps++; | ||||
msleep(keg, &keg->uk_lock, PVM, "keglimit", 0); | msleep(keg, &keg->uk_lock, PVM, "keglimit", 0); | ||||
continue; | continue; | ||||
} | } | ||||
slab = keg_alloc_slab(keg, zone, flags); | slab = keg_alloc_slab(keg, zone, flags); | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | for (;;) { | ||||
* All kegs are full. XXX We can't atomically check all kegs | * All kegs are full. XXX We can't atomically check all kegs | ||||
* and sleep so just sleep for a short period and retry. | * and sleep so just sleep for a short period and retry. | ||||
*/ | */ | ||||
if (full && !empty) { | if (full && !empty) { | ||||
ZONE_LOCK(zone); | ZONE_LOCK(zone); | ||||
zone->uz_flags |= UMA_ZFLAG_FULL; | zone->uz_flags |= UMA_ZFLAG_FULL; | ||||
zone->uz_sleeps++; | zone->uz_sleeps++; | ||||
zone_log_warning(zone); | zone_log_warning(zone); | ||||
zone_maxaction(zone); | |||||
msleep(zone, zone->uz_lockptr, PVM, | msleep(zone, zone->uz_lockptr, PVM, | ||||
"zonelimit", hz/100); | "zonelimit", hz/100); | ||||
zone->uz_flags &= ~UMA_ZFLAG_FULL; | zone->uz_flags &= ~UMA_ZFLAG_FULL; | ||||
ZONE_UNLOCK(zone); | ZONE_UNLOCK(zone); | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
▲ Show 20 Lines • Show All 486 Lines • ▼ Show 20 Lines | |||||
/* See uma.h */ | /* See uma.h */ | ||||
void | void | ||||
uma_zone_set_warning(uma_zone_t zone, const char *warning) | uma_zone_set_warning(uma_zone_t zone, const char *warning) | ||||
{ | { | ||||
ZONE_LOCK(zone); | ZONE_LOCK(zone); | ||||
zone->uz_warning = warning; | zone->uz_warning = warning; | ||||
ZONE_UNLOCK(zone); | |||||
} | |||||
/* See uma.h */ | |||||
void | |||||
uma_zone_set_maxaction(uma_zone_t zone, uma_maxaction_t maxaction) | |||||
{ | |||||
ZONE_LOCK(zone); | |||||
zone->uz_maxaction = maxaction; | |||||
ZONE_UNLOCK(zone); | ZONE_UNLOCK(zone); | ||||
} | } | ||||
/* See uma.h */ | /* See uma.h */ | ||||
int | int | ||||
uma_zone_get_cur(uma_zone_t zone) | uma_zone_get_cur(uma_zone_t zone) | ||||
{ | { | ||||
int64_t nitems; | int64_t nitems; | ||||
▲ Show 20 Lines • Show All 634 Lines • Show Last 20 Lines |