Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/uma_core.c
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | static enum { | ||||
BOOT_RUNNING, | BOOT_RUNNING, | ||||
BOOT_SHUTDOWN, | BOOT_SHUTDOWN, | ||||
} booted = BOOT_COLD; | } booted = BOOT_COLD; | ||||
/* | /* | ||||
* This is the handle used to schedule events that need to happen | * This is the handle used to schedule events that need to happen | ||||
* outside of the allocation fast path. | * outside of the allocation fast path. | ||||
*/ | */ | ||||
static struct callout uma_callout; | static struct timeout_task uma_timeout_task; | ||||
#define UMA_TIMEOUT 20 /* Seconds for callout interval. */ | #define UMA_TIMEOUT 20 /* Seconds for callout interval. */ | ||||
/* | /* | ||||
* This structure is passed as the zone ctor arg so that I don't have to create | * This structure is passed as the zone ctor arg so that I don't have to create | ||||
* a special allocation function just for zones. | * a special allocation function just for zones. | ||||
*/ | */ | ||||
struct uma_zctor_args { | struct uma_zctor_args { | ||||
const char *name; | const char *name; | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
static void zone_free_bucket(uma_zone_t zone, uma_bucket_t bucket, void *udata, | static void zone_free_bucket(uma_zone_t zone, uma_bucket_t bucket, void *udata, | ||||
int itemdomain, bool ws); | int itemdomain, bool ws); | ||||
static void zone_foreach(void (*zfunc)(uma_zone_t, void *), void *); | static void zone_foreach(void (*zfunc)(uma_zone_t, void *), void *); | ||||
static void zone_foreach_unlocked(void (*zfunc)(uma_zone_t, void *), void *); | static void zone_foreach_unlocked(void (*zfunc)(uma_zone_t, void *), void *); | ||||
static void zone_timeout(uma_zone_t zone, void *); | static void zone_timeout(uma_zone_t zone, void *); | ||||
static int hash_alloc(struct uma_hash *, u_int); | static int hash_alloc(struct uma_hash *, u_int); | ||||
static int hash_expand(struct uma_hash *, struct uma_hash *); | static int hash_expand(struct uma_hash *, struct uma_hash *); | ||||
static void hash_free(struct uma_hash *hash); | static void hash_free(struct uma_hash *hash); | ||||
static void uma_timeout(void *); | static void uma_timeout(void *, int); | ||||
static void uma_shutdown(void); | static void uma_shutdown(void); | ||||
static void *zone_alloc_item(uma_zone_t, void *, int, int); | static void *zone_alloc_item(uma_zone_t, void *, int, int); | ||||
static void zone_free_item(uma_zone_t, void *, void *, enum zfreeskip); | static void zone_free_item(uma_zone_t, void *, void *, enum zfreeskip); | ||||
static int zone_alloc_limit(uma_zone_t zone, int count, int flags); | static int zone_alloc_limit(uma_zone_t zone, int count, int flags); | ||||
static void zone_free_limit(uma_zone_t zone, int count); | static void zone_free_limit(uma_zone_t zone, int count); | ||||
static void bucket_enable(void); | static void bucket_enable(void); | ||||
static void bucket_init(void); | static void bucket_init(void); | ||||
static uma_bucket_t bucket_alloc(uma_zone_t zone, void *, int); | static uma_bucket_t bucket_alloc(uma_zone_t zone, void *, int); | ||||
▲ Show 20 Lines • Show All 779 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* Arguments: | * Arguments: | ||||
* arg Unused | * arg Unused | ||||
* | * | ||||
* Returns: | * Returns: | ||||
* Nothing | * Nothing | ||||
*/ | */ | ||||
static void | static void | ||||
uma_timeout(void *unused) | uma_timeout(void *unused __unused, int pending __unused) | ||||
rlibby: Since both arguments are unused, maybe `void *context __unused ` reads better for the first… | |||||
{ | { | ||||
bucket_enable(); | bucket_enable(); | ||||
zone_foreach(zone_timeout, NULL); | zone_foreach(zone_timeout, NULL); | ||||
/* Reschedule this event */ | /* Reschedule this event */ | ||||
callout_reset(&uma_callout, UMA_TIMEOUT * hz, uma_timeout, NULL); | taskqueue_enqueue_timeout(taskqueue_thread, &uma_timeout_task, | ||||
UMA_TIMEOUT * hz); | |||||
} | } | ||||
/* | /* | ||||
* Update the working set size estimates for the zone's bucket cache. | * Update the working set size estimates for the zone's bucket cache. | ||||
* The constants chosen here are somewhat arbitrary. | * The constants chosen here are somewhat arbitrary. | ||||
*/ | */ | ||||
static void | static void | ||||
zone_domain_update_wss(uma_zone_domain_t zdom) | zone_domain_update_wss(uma_zone_domain_t zdom) | ||||
▲ Show 20 Lines • Show All 2,078 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
TUNABLE_INT_FETCH("vm.debug.divisor", &dbg_divisor); | TUNABLE_INT_FETCH("vm.debug.divisor", &dbg_divisor); | ||||
uma_dbg_cnt = counter_u64_alloc(M_WAITOK); | uma_dbg_cnt = counter_u64_alloc(M_WAITOK); | ||||
uma_skip_cnt = counter_u64_alloc(M_WAITOK); | uma_skip_cnt = counter_u64_alloc(M_WAITOK); | ||||
#endif | #endif | ||||
zone_foreach_unlocked(zone_alloc_sysctl, NULL); | zone_foreach_unlocked(zone_alloc_sysctl, NULL); | ||||
callout_init(&uma_callout, 1); | |||||
callout_reset(&uma_callout, UMA_TIMEOUT * hz, uma_timeout, NULL); | |||||
booted = BOOT_RUNNING; | booted = BOOT_RUNNING; | ||||
EVENTHANDLER_REGISTER(shutdown_post_sync, uma_shutdown, NULL, | EVENTHANDLER_REGISTER(shutdown_post_sync, uma_shutdown, NULL, | ||||
EVENTHANDLER_PRI_FIRST); | EVENTHANDLER_PRI_FIRST); | ||||
} | } | ||||
SYSINIT(uma_startup3, SI_SUB_VM_CONF, SI_ORDER_SECOND, uma_startup3, NULL); | SYSINIT(uma_startup3, SI_SUB_VM_CONF, SI_ORDER_SECOND, uma_startup3, NULL); | ||||
static void | |||||
uma_startup4(void *arg __unused) | |||||
{ | |||||
TIMEOUT_TASK_INIT(taskqueue_thread, &uma_timeout_task, 0, uma_timeout, | |||||
NULL); | |||||
taskqueue_enqueue_timeout(taskqueue_thread, &uma_timeout_task, | |||||
UMA_TIMEOUT * hz); | |||||
} | |||||
SYSINIT(uma_startup4, SI_SUB_TASKQ, SI_ORDER_ANY, uma_startup4, NULL); | |||||
static void | static void | ||||
uma_shutdown(void) | uma_shutdown(void) | ||||
{ | { | ||||
booted = BOOT_SHUTDOWN; | booted = BOOT_SHUTDOWN; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,684 Lines • Show Last 20 Lines |
Since both arguments are unused, maybe void *context __unused reads better for the first argument?