aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-11-02 17:38:08 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-11-02 17:38:08 +0000
commit828afdda17cae119594b21cac689bbe681b5aa58 (patch)
treea135e30ccd5f0290c88ce4b2da6eead7f604b4d8 /usr.bin
parent26c29e743bbdbb82762540f72d4bc449bae2e092 (diff)
downloadsrc-828afdda17cae119594b21cac689bbe681b5aa58.tar.gz
src-828afdda17cae119594b21cac689bbe681b5aa58.zip
malloc: export kernel zones instead of relying on them being power-of-2
Reviewed by: markj (previous version) Differential Revision: https://reviews.freebsd.org/D27026
Notes
Notes: svn path=/head/; revision=367274
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vmstat/vmstat.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index f59ea3281b65..757904546d29 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1407,7 +1407,8 @@ domemstat_malloc(void)
{
struct memory_type_list *mtlp;
struct memory_type *mtp;
- int error, first, i;
+ size_t i, zones;
+ int error, first;
mtlp = memstat_mtl_alloc();
if (mtlp == NULL) {
@@ -1435,6 +1436,7 @@ domemstat_malloc(void)
xo_emit("{T:/%13s} {T:/%5s} {T:/%6s} {T:/%7s} {T:/%8s} {T:Size(s)}\n",
"Type", "InUse", "MemUse", "HighUse", "Requests");
xo_open_list("memory");
+ zones = memstat_malloc_zone_get_count();
for (mtp = memstat_mtl_first(mtlp); mtp != NULL;
mtp = memstat_mtl_next(mtp)) {
if (memstat_get_numallocs(mtp) == 0 &&
@@ -1449,11 +1451,11 @@ domemstat_malloc(void)
(uintmax_t)memstat_get_numallocs(mtp));
first = 1;
xo_open_list("size");
- for (i = 0; i < 32; i++) {
- if (memstat_get_sizemask(mtp) & (1 << i)) {
+ for (i = 0; i < zones; i++) {
+ if (memstat_malloc_zone_used(mtp, i)) {
if (!first)
xo_emit(",");
- xo_emit("{l:size/%d}", 1 << (i + 4));
+ xo_emit("{l:size/%d}", memstat_malloc_zone_get_size(i));
first = 0;
}
}