diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-08-01 21:33:17 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-08-01 21:33:17 +0000 |
commit | 548e1b7d84da57be1fa137cbcbc72582c72944be (patch) | |
tree | d2cdbcd5c9ddf81091c1c2db48cd1dff32819321 /usr.bin | |
parent | 7cdc25bbb96d1e2fa11d9a3ff98dc16b5c893d65 (diff) | |
download | FreeBSD-src-548e1b7d84da57be1fa137cbcbc72582c72944be.zip FreeBSD-src-548e1b7d84da57be1fa137cbcbc72582c72944be.tar.gz |
Teach vmstat's domemstat_zone() to use memstat_kvm_uma() when the kvm
descriptor is non-NULL, restoring vmstat -z support for core dumps and
kmem access. These were broken with the introduction of UMA.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 6e3aaaa..c466000 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -155,7 +155,7 @@ static void domem(void); static void dointr(void); static void dosum(void); static void dovmstat(unsigned int, int); -static void dozmem(void); +static void domemstat_zone(void); static void kread(int, void *, size_t); static void kreado(int, void *, size_t, size_t); static char *kgetstr(const char *); @@ -302,7 +302,7 @@ main(int argc, char *argv[]) if (todo & MEMSTAT) domem(); if (todo & ZMEMSTAT) - dozmem(); + domemstat_zone(); if (todo & SUMSTAT) dosum(); #ifdef notyet @@ -945,16 +945,29 @@ domemstat_zone(void) struct memory_type_list *mtlp; struct memory_type *mtp; char name[MEMTYPE_MAXNAME + 1]; + int error; mtlp = memstat_mtl_alloc(); if (mtlp == NULL) { warn("memstat_mtl_alloc"); return; } - if (memstat_sysctl_uma(mtlp, 0) < 0) { - warnx("memstat_sysctl_uma: %s", - memstat_strerror(memstat_mtl_geterror(mtlp))); - return; + if (kd == NULL) { + if (memstat_sysctl_uma(mtlp, 0) < 0) { + warnx("memstat_sysctl_uma: %s", + memstat_strerror(memstat_mtl_geterror(mtlp))); + return; + } + } else { + if (memstat_kvm_uma(mtlp, kd) < 0) { + error = memstat_mtl_geterror(mtlp); + if (error == MEMSTAT_ERROR_KVM) + warnx("memstat_kvm_uma: %s", + kvm_geterr(kd)); + else + warnx("memstat_kvm_uma: %s", + memstat_strerror(error)); + } } printf("%-15s %-8s %-9s %-7s %-5s %-8s\n\n", "ITEM", "SIZE", "LIMIT", "USED", "FREE", "REQUESTS"); @@ -1060,14 +1073,6 @@ domem(void) } while (type.ks_next != NULL); } -static void -dozmem(void) -{ - if (kd != NULL) - errx(1, "not implemented"); - domemstat_zone(); -} - /* * kread reads something from the kernel, given its nlist index. */ |