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
This commit is contained in:
Pawel Jakub Dawidek 2005-07-27 23:17:31 +00:00
parent ea35a2ec3a
commit 73864adbd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=148461

View File

@ -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);
}
/*