Add a simple accessor that returns the bytes of memory consumed by a zone.

This commit is contained in:
jeff 2020-02-17 01:59:55 +00:00
parent 02694321f8
commit 12206c6f43
2 changed files with 26 additions and 0 deletions

View File

@ -670,6 +670,11 @@ void uma_prealloc(uma_zone_t zone, int itemcnt);
*/
int uma_zone_exhausted(uma_zone_t zone);
/*
* Returns the bytes of memory consumed by the zone.
*/
size_t uma_zone_memory(uma_zone_t zone);
/*
* Common UMA_ZONE_PCPU zones.
*/

View File

@ -4681,6 +4681,27 @@ uma_prealloc(uma_zone_t zone, int items)
}
}
/*
* Returns a snapshot of memory consumption in bytes.
*/
size_t
uma_zone_memory(uma_zone_t zone)
{
size_t sz;
int i;
sz = 0;
if (zone->uz_flags & UMA_ZFLAG_CACHE) {
for (i = 0; i < vm_ndomains; i++)
sz += zone->uz_domain[i].uzd_nitems;
return (sz * zone->uz_size);
}
for (i = 0; i < vm_ndomains; i++)
sz += zone->uz_keg->uk_domain[i].ud_pages;
return (sz * PAGE_SIZE);
}
/* See uma.h */
void
uma_reclaim(int req)