summaryrefslogtreecommitdiffstats
path: root/lib/libmemstat
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 /lib/libmemstat
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 'lib/libmemstat')
-rw-r--r--lib/libmemstat/memstat.c8
-rw-r--r--lib/libmemstat/memstat.h1
-rw-r--r--lib/libmemstat/memstat_internal.h1
-rw-r--r--lib/libmemstat/memstat_uma.c2
4 files changed, 12 insertions, 0 deletions
diff --git a/lib/libmemstat/memstat.c b/lib/libmemstat/memstat.c
index 28e4813..1a08d3f 100644
--- a/lib/libmemstat/memstat.c
+++ b/lib/libmemstat/memstat.c
@@ -188,6 +188,7 @@ _memstat_mt_reset_stats(struct memory_type *mtp)
mtp->mt_count = 0;
mtp->mt_free = 0;
mtp->mt_failures = 0;
+ mtp->mt_sleeps = 0;
mtp->mt_zonefree = 0;
mtp->mt_kegfree = 0;
@@ -304,6 +305,13 @@ memstat_get_failures(const struct memory_type *mtp)
return (mtp->mt_failures);
}
+uint64_t
+memstat_get_sleeps(const struct memory_type *mtp)
+{
+
+ return (mtp->mt_sleeps);
+}
+
void *
memstat_get_caller_pointer(const struct memory_type *mtp, int index)
{
diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h
index aaa85702..e973f1a 100644
--- a/lib/libmemstat/memstat.h
+++ b/lib/libmemstat/memstat.h
@@ -139,6 +139,7 @@ uint64_t memstat_get_bytes(const struct memory_type *mtp);
uint64_t memstat_get_count(const struct memory_type *mtp);
uint64_t memstat_get_free(const struct memory_type *mtp);
uint64_t memstat_get_failures(const struct memory_type *mtp);
+uint64_t memstat_get_sleeps(const struct memory_type *mtp);
void *memstat_get_caller_pointer(const struct memory_type *mtp,
int index);
void memstat_set_caller_pointer(struct memory_type *mtp,
diff --git a/lib/libmemstat/memstat_internal.h b/lib/libmemstat/memstat_internal.h
index 7123518..b7fdd71 100644
--- a/lib/libmemstat/memstat_internal.h
+++ b/lib/libmemstat/memstat_internal.h
@@ -65,6 +65,7 @@ struct memory_type {
uint64_t mt_count; /* Number of current allocations. */
uint64_t mt_free; /* Number of cached free items. */
uint64_t mt_failures; /* Number of allocation failures. */
+ uint64_t mt_sleeps; /* Number of allocation sleeps. */
/*
* Caller-owned memory.
diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c
index b24721f..4aae61a 100644
--- a/lib/libmemstat/memstat_uma.c
+++ b/lib/libmemstat/memstat_uma.c
@@ -208,6 +208,7 @@ retry:
mtp->mt_numallocs = uthp->uth_allocs;
mtp->mt_numfrees = uthp->uth_frees;
mtp->mt_failures = uthp->uth_fails;
+ mtp->mt_sleeps = uthp->uth_sleeps;
for (j = 0; j < maxcpus; j++) {
upsp = (struct uma_percpu_stat *)p;
@@ -402,6 +403,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle)
mtp->mt_numallocs = uz.uz_allocs;
mtp->mt_numfrees = uz.uz_frees;
mtp->mt_failures = uz.uz_fails;
+ mtp->mt_sleeps = uz.uz_sleeps;
if (kz.uk_flags & UMA_ZFLAG_INTERNAL)
goto skip_percpu;
for (i = 0; i < mp_maxid + 1; i++) {
OpenPOWER on IntegriCloud