diff options
author | pjd <pjd@FreeBSD.org> | 2005-07-27 23:17:31 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2005-07-27 23:17:31 +0000 |
commit | 9c0918e8992742753c6335002182b699656b7e0e (patch) | |
tree | 0f97e9d7167b3d6cb532fced4a57c45db549e7b7 | |
parent | 8ecb9be842ecf042f25c94f45ffc6abd0a830d79 (diff) | |
download | FreeBSD-src-9c0918e8992742753c6335002182b699656b7e0e.zip FreeBSD-src-9c0918e8992742753c6335002182b699656b7e0e.tar.gz |
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
-rw-r--r-- | sys/kern/kern_malloc.c | 9 |
1 files changed, 6 insertions, 3 deletions
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); } /* |