diff options
author | kstailey <kstailey@cvs.openbsd.org> | 1997-02-22 17:20:31 +0000 |
---|---|---|
committer | kstailey <kstailey@cvs.openbsd.org> | 1997-02-22 17:20:31 +0000 |
commit | e994feae4493428e79356de8c03bf2f330e22aa6 (patch) | |
tree | aec071707aec27ed3c2f988e9449ee04bf3dc8e2 | |
parent | df9b0ebadb8f4baa6c238adda33ec7c20091c08f (diff) |
if sys/kern/malloc.c does not #define KMEMSTATS (and DIAGNOSTIC is also
not #defined) then vmstat should not try to print kernel memory stats.
Fixes NetBSD PR #3187.
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 9c4d5f7c2e2..60c35d3d4c6 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,5 @@ /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ -/* $OpenBSD: vmstat.c,v 1.17 1997/02/13 20:17:16 kstailey Exp $ */ +/* $OpenBSD: vmstat.c,v 1.18 1997/02/22 17:20:30 kstailey Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -843,12 +843,16 @@ domem() struct kmembuckets buckets[MINBUCKET + 16]; kread(X_KMEMBUCKETS, buckets, sizeof(buckets)); - (void)printf("Memory statistics by bucket size\n"); - (void)printf( - " Size In Use Free Requests HighWater Couldfree\n"); - for (i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16; i++, kp++) { + for (first = 1, i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16; + i++, kp++) { if (kp->kb_calls == 0) continue; + if (first) { + (void)printf("Memory statistics by bucket size\n"); + (void)printf( + " Size In Use Free Requests HighWater Couldfree\n"); + first = 0; + } size = 1 << i; (void)printf("%8d %8ld %6ld %10ld %7ld %10ld\n", size, kp->kb_total - kp->kb_totalfree, @@ -857,6 +861,16 @@ domem() totfree += size * kp->kb_totalfree; } + /* + * If kmem statistics are not being gathered by the kernel, + * first will still be 1. + */ + if (first) { + printf( + "Kmem statistics are not being gathered by the kernel.\n"); + return; + } + kread(X_KMEMSTAT, kmemstats, sizeof(kmemstats)); (void)printf("\nMemory usage type by bucket size\n"); (void)printf(" Size Type(s)\n"); |