uma: report leaks more accurately

Previously UMA had some false negatives in the leak report at keg
destruction time, where it only reported leaks if there were free items
in the slab layer (rather than allocated items), which notably would not
be true for single-item slabs (large items).  Now, report a leak if
there are any allocated pages, and calculate and report the number of
allocated items rather than free items.

Reviewed by:	jeff, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23275
This commit is contained in:
Ryan Libby 2020-01-23 04:56:34 +00:00
parent 91e31c3c08
commit 7e2406774e

View File

@ -2440,11 +2440,11 @@ keg_dtor(void *arg, int size, void *udata)
pages += keg->uk_domain[i].ud_pages;
KEG_LOCK_FINI(keg, i);
}
if (free != 0)
if (pages != 0)
printf("Freed UMA keg (%s) was not empty (%u items). "
" Lost %u pages of memory.\n",
keg->uk_name ? keg->uk_name : "",
free, pages);
pages / keg->uk_ppera * keg->uk_ipers - free, pages);
hash_free(&keg->uk_hash);
}