From 9c0918e8992742753c6335002182b699656b7e0e Mon Sep 17 00:00:00 2001 From: pjd Date: Wed, 27 Jul 2005 23:17:31 +0000 Subject: Fix the way how "InUse" column in 'vmstat -m' output works: - increase number of allocations count only on successfull malloc(9), so it doesn't confuse people; - because we need to check if 'size > 0', hide 'mtsp->mts_memalloced += size;' under the check as well, as for size=0 it is of course a no-op; - avoid critical_enter()/critical_exit() in case of failure in malloc_type_allocated() as there will be nothing to do. OK'ed by: rwatson MFC after: 2 days --- sys/kern/kern_malloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/kern/kern_malloc.c') diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 6f8518f..0e3403b 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -213,8 +213,10 @@ malloc_type_zone_allocated(struct malloc_type *mtp, unsigned long size, critical_enter(); mtip = mtp->ks_handle; mtsp = &mtip->mti_stats[curcpu]; - mtsp->mts_memalloced += size; - mtsp->mts_numallocs++; + if (size > 0) { + mtsp->mts_memalloced += size; + mtsp->mts_numallocs++; + } if (zindx != -1) mtsp->mts_size |= 1 << zindx; critical_exit(); @@ -224,7 +226,8 @@ void malloc_type_allocated(struct malloc_type *mtp, unsigned long size) { - malloc_type_zone_allocated(mtp, size, -1); + if (size > 0) + malloc_type_zone_allocated(mtp, size, -1); } /* -- cgit v1.1