From db17c1d99766e8e363022d2083401fc77d932e08 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 5 Jan 2007 19:09:01 +0000 Subject: - Add a new function uma_zone_exhausted() to see if a zone is full. - Add a printf in swp_pager_meta_build() to warn if the swapzone becomes exhausted so that there's at least a warning before a box that runs out of swapzone space before running out of swap space deadlocks. MFC after: 1 week Reviwed by: alc --- sys/vm/swap_pager.c | 2 ++ sys/vm/uma.h | 11 +++++++++++ sys/vm/uma_core.c | 12 ++++++++++++ 3 files changed, 25 insertions(+) (limited to 'sys/vm') diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 7b7e5d1..46f49d2 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1746,6 +1746,8 @@ retry: if (swap == NULL) { mtx_unlock(&swhash_mtx); VM_OBJECT_UNLOCK(object); + if (uma_zone_exhausted(swap_zone)) + printf("swap zone exhausted, increase kern.maxswzone\n"); VM_WAIT; VM_OBJECT_LOCK(object); goto retry; diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 2181ec7..08a55d6 100644 --- a/sys/vm/uma.h +++ b/sys/vm/uma.h @@ -509,6 +509,17 @@ void uma_prealloc(uma_zone_t zone, int itemcnt); u_int32_t *uma_find_refcnt(uma_zone_t zone, void *item); /* + * Used to determine if a fixed-size zone is exhausted. + * + * Arguments: + * zone The zone to check + * + * Returns: + * Non-zero if zone is exhausted. + */ +int uma_zone_exhausted(uma_zone_t zone); + +/* * Exported statistics structures to be used by user space monitoring tools. * Statistics stream consusts of a uma_stream_header, followed by a series of * alternative uma_type_header and uma_type_stat structures. Statistics diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 3e8bb2e..ac3ffc4 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -2681,6 +2681,18 @@ uma_reclaim(void) bucket_zone_drain(); } +/* See uma.h */ +int +uma_zone_exhausted(uma_zone_t zone) +{ + int full; + + ZONE_LOCK(zone); + full = (zone->uz_keg->uk_flags & UMA_ZFLAG_FULL); + ZONE_UNLOCK(zone); + return (full); +} + void * uma_large_malloc(int size, int wait) { -- cgit v1.1