Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/vmstat when picking which 2 disks to show in the 'vm...
details: https://anonhg.NetBSD.org/src/rev/1e49fcf573df
branches: trunk
changeset: 359940:1e49fcf573df
user: mrg <mrg%NetBSD.org@localhost>
date: Tue Feb 01 09:18:07 2022 +0000
description:
when picking which 2 disks to show in the 'vmstat' default output
and they haven't been specified on the command line, pick the two
devices that have had the largest read+write IO bytes count.
diffstat:
usr.bin/vmstat/vmstat.c | 33 ++++++++++++++++++++++++++-------
1 files changed, 26 insertions(+), 7 deletions(-)
diffs (62 lines):
diff -r 3fef8746abe5 -r 1e49fcf573df usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Tue Feb 01 08:58:25 2022 +0000
+++ b/usr.bin/vmstat/vmstat.c Tue Feb 01 09:18:07 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.248 2021/11/27 22:16:42 rillig Exp $ */
+/* $NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
#else
-__RCSID("$NetBSD: vmstat.c,v 1.248 2021/11/27 22:16:42 rillig Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $");
#endif
#endif /* not lint */
@@ -569,7 +569,7 @@
char **
choosedrives(char **argv)
{
- size_t i;
+ size_t i, j, k;
/*
* Choose drives to be displayed. Priority goes to (in order) drives
@@ -591,11 +591,30 @@
break;
}
}
+
+ /*
+ * Pick the most active drives. Must read the stats once before
+ * sorting so that there is current IO data, before selecting
+ * just the first two drives.
+ */
+ drvreadstats();
for (i = 0; i < ndrive && ndrives < 2; i++) {
- if (drv_select[i])
- continue;
- drv_select[i] = 1;
- ++ndrives;
+ uint64_t high_bytes = 0, bytes;
+
+ k = ndrive;
+ for (j = 0; j < ndrive; j++) {
+ if (drv_select[j])
+ continue;
+ bytes = cur.rbytes[j] + cur.wbytes[j];
+ if (bytes > high_bytes) {
+ high_bytes = bytes;
+ k = j;
+ }
+ }
+ if (k != ndrive) {
+ drv_select[k] = 1;
+ ++ndrives;
+ }
}
return (argv);
Home |
Main Index |
Thread Index |
Old Index