summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorsbruno <sbruno@FreeBSD.org>2010-06-15 19:28:37 +0000
committersbruno <sbruno@FreeBSD.org>2010-06-15 19:28:37 +0000
commit3571902304966f5edad4bceddc7fb3170f4ff982 (patch)
treec365e722a1674a60a8186f54209e8934369f70a5 /sys/vm
parent597252854841710d6981f293f5bab6880df163b0 (diff)
downloadFreeBSD-src-3571902304966f5edad4bceddc7fb3170f4ff982.zip
FreeBSD-src-3571902304966f5edad4bceddc7fb3170f4ff982.tar.gz
Add a new column to the output of vmstat -z to indicate the number
of times the system was forced to sleep when requesting a new allocation. Expand the debugger hook, db_show_uma, to display these results as well. This has proven to be very useful in out of memory situations when it is not known why systems have become sluggish or fail in odd ways. Reviewed by: rwatson alc Approved by: scottl (mentor) peter Obtained from: Yahoo Inc.
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/uma.h3
-rw-r--r--sys/vm/uma_core.c25
-rw-r--r--sys/vm/uma_int.h1
3 files changed, 19 insertions, 10 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index c044824..2076d3b 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -600,7 +600,8 @@ struct uma_type_header {
u_int64_t uth_allocs; /* Zone: number of allocations. */
u_int64_t uth_frees; /* Zone: number of frees. */
u_int64_t uth_fails; /* Zone: number of alloc failures. */
- u_int64_t _uth_reserved1[3]; /* Reserved. */
+ u_int64_t uth_sleeps; /* Zone: number of alloc sleeps. */
+ u_int64_t _uth_reserved1[2]; /* Reserved. */
};
struct uma_percpu_stat {
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index a3855ca..2dcd14f 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1396,6 +1396,7 @@ zone_ctor(void *mem, int size, void *udata, int flags)
zone->uz_allocs = 0;
zone->uz_frees = 0;
zone->uz_fails = 0;
+ zone->uz_sleeps = 0;
zone->uz_fills = zone->uz_count = 0;
zone->uz_flags = 0;
keg = arg->keg;
@@ -2283,6 +2284,7 @@ zone_fetch_slab_multi(uma_zone_t zone, uma_keg_t last, int rflags)
*/
if (full && !empty) {
zone->uz_flags |= UMA_ZFLAG_FULL;
+ zone->uz_sleeps++;
msleep(zone, zone->uz_lock, PVM, "zonelimit", hz/100);
zone->uz_flags &= ~UMA_ZFLAG_FULL;
continue;
@@ -3094,13 +3096,13 @@ uma_print_zone(uma_zone_t zone)
*/
static void
uma_zone_sumstat(uma_zone_t z, int *cachefreep, u_int64_t *allocsp,
- u_int64_t *freesp)
+ u_int64_t *freesp, u_int64_t *sleepsp)
{
uma_cache_t cache;
- u_int64_t allocs, frees;
+ u_int64_t allocs, frees, sleeps;
int cachefree, cpu;
- allocs = frees = 0;
+ allocs = frees = sleeps = 0;
cachefree = 0;
CPU_FOREACH(cpu) {
cache = &z->uz_cpu[cpu];
@@ -3113,12 +3115,15 @@ uma_zone_sumstat(uma_zone_t z, int *cachefreep, u_int64_t *allocsp,
}
allocs += z->uz_allocs;
frees += z->uz_frees;
+ sleeps += z->uz_sleeps;
if (cachefreep != NULL)
*cachefreep = cachefree;
if (allocsp != NULL)
*allocsp = allocs;
if (freesp != NULL)
*freesp = frees;
+ if (sleepsp != NULL)
+ *sleepsp = sleeps;
}
#endif /* DDB */
@@ -3226,6 +3231,7 @@ restart:
uth.uth_allocs = z->uz_allocs;
uth.uth_frees = z->uz_frees;
uth.uth_fails = z->uz_fails;
+ uth.uth_sleeps = z->uz_sleeps;
if (sbuf_bcat(&sbuf, &uth, sizeof(uth)) < 0) {
ZONE_UNLOCK(z);
mtx_unlock(&uma_mtx);
@@ -3277,32 +3283,33 @@ out:
#ifdef DDB
DB_SHOW_COMMAND(uma, db_show_uma)
{
- u_int64_t allocs, frees;
+ u_int64_t allocs, frees, sleeps;
uma_bucket_t bucket;
uma_keg_t kz;
uma_zone_t z;
int cachefree;
- db_printf("%18s %8s %8s %8s %12s\n", "Zone", "Size", "Used", "Free",
- "Requests");
+ db_printf("%18s %8s %8s %8s %12s %8s\n", "Zone", "Size", "Used", "Free",
+ "Requests", "Sleeps");
LIST_FOREACH(kz, &uma_kegs, uk_link) {
LIST_FOREACH(z, &kz->uk_zones, uz_link) {
if (kz->uk_flags & UMA_ZFLAG_INTERNAL) {
allocs = z->uz_allocs;
frees = z->uz_frees;
+ sleeps = z->uz_sleeps;
cachefree = 0;
} else
uma_zone_sumstat(z, &cachefree, &allocs,
- &frees);
+ &frees, &sleeps);
if (!((z->uz_flags & UMA_ZONE_SECONDARY) &&
(LIST_FIRST(&kz->uk_zones) != z)))
cachefree += kz->uk_free;
LIST_FOREACH(bucket, &z->uz_full_bucket, ub_link)
cachefree += bucket->ub_cnt;
- db_printf("%18s %8ju %8jd %8d %12ju\n", z->uz_name,
+ db_printf("%18s %8ju %8jd %8d %12ju %8ju\n", z->uz_name,
(uintmax_t)kz->uk_size,
(intmax_t)(allocs - frees), cachefree,
- (uintmax_t)allocs);
+ (uintmax_t)allocs, sleeps);
}
}
}
diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h
index 27396ea..7713593 100644
--- a/sys/vm/uma_int.h
+++ b/sys/vm/uma_int.h
@@ -327,6 +327,7 @@ struct uma_zone {
u_int64_t uz_allocs UMA_ALIGN; /* Total number of allocations */
u_int64_t uz_frees; /* Total number of frees */
u_int64_t uz_fails; /* Total number of alloc failures */
+ u_int64_t uz_sleeps; /* Total number of alloc sleeps */
uint16_t uz_fills; /* Outstanding bucket fills */
uint16_t uz_count; /* Highest value ub_ptr can have */
OpenPOWER on IntegriCloud