aboutsummaryrefslogtreecommitdiff
path: root/lib/libmemstat
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2019-02-18 21:27:13 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2019-02-18 21:27:13 +0000
commitaa432983093fc696dcf72c7d3557bbbefee231f9 (patch)
treea7bd9b0a815520252bc0ecc127d87aecf31089f5 /lib/libmemstat
parent63f582e0f5ad0fe006d712e1f680e0be9c532d21 (diff)
With r343051 UMA switched from atomic counts to counter(9) and now kernel
reports snap counts of how much a zone alloced and how much it freed. It may happen that snap values doesn't match, e.g alloced - freed < 0. Workaround that in memstat library. Reported by: pho
Notes
Notes: svn path=/head/; revision=344269
Diffstat (limited to 'lib/libmemstat')
-rw-r--r--lib/libmemstat/memstat_uma.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c
index 87a6b573307b..89b394c151ad 100644
--- a/lib/libmemstat/memstat_uma.c
+++ b/lib/libmemstat/memstat_uma.c
@@ -213,6 +213,15 @@ retry:
mtp->mt_numfrees += upsp->ups_frees;
}
+ /*
+ * Values for uth_allocs and uth_frees frees are snap.
+ * It may happen that kernel reports that number of frees
+ * is greater than number of allocs. See counter(9) for
+ * details.
+ */
+ if (mtp->mt_numallocs < mtp->mt_numfrees)
+ mtp->mt_numallocs = mtp->mt_numfrees;
+
mtp->mt_size = uthp->uth_size;
mtp->mt_rsize = uthp->uth_rsize;
mtp->mt_memalloced = mtp->mt_numallocs * uthp->uth_size;