Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/vmstat Pull up following revision(s) (requested b...
details: https://anonhg.NetBSD.org/src/rev/9c90e9cc9228
branches: netbsd-9
changeset: 1002095:9c90e9cc9228
user: martin <martin%NetBSD.org@localhost>
date: Fri Dec 18 12:23:16 2020 +0000
description:
Pull up following revision(s) (requested by mrg in ticket #1153):
usr.bin/vmstat/vmstat.c: revision 1.232 (patch)
move the time nlist fetches into their own namelist and only
fetch them when necessary. allow for fallback uses of older
time sources if others are not present.
this stops vmstat from exiting if it can't get the addresses
of these time values it often doesn't need (eg, running kernels
use the sysctl method), which has cropped up recently wit the
removal of boottime variable.
a slighly modified version of this patch (modified to handle
the old boottime variable over the new one) works against a
netbsd-9 vmstat in -current too.
XXX: pullup
diffstat:
usr.bin/vmstat/vmstat.c | 63 ++++++++++++++++++++++++++++--------------------
1 files changed, 37 insertions(+), 26 deletions(-)
diffs (116 lines):
diff -r 1df852767380 -r 9c90e9cc9228 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Mon Dec 14 17:30:35 2020 +0000
+++ b/usr.bin/vmstat/vmstat.c Fri Dec 18 12:23:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.227 2019/05/09 08:01:07 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.227.2.1 2020/12/18 12:23:16 martin Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
#else
-__RCSID("$NetBSD: vmstat.c,v 1.227 2019/05/09 08:01:07 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.227.2.1 2020/12/18 12:23:16 martin Exp $");
#endif
#endif /* not lint */
@@ -147,27 +147,36 @@
*/
struct nlist namelist[] =
{
+#define X_HZ 0
+ { .n_name = "_hz" },
+#define X_STATHZ 1
+ { .n_name = "_stathz" },
+#define X_NCHSTATS 2
+ { .n_name = "_nchstats" },
+#define X_ALLEVENTS 3
+ { .n_name = "_allevents" },
+#define X_POOLHEAD 4
+ { .n_name = "_pool_head" },
+#define X_UVMEXP 5
+ { .n_name = "_uvmexp" },
+#define X_CPU_INFOS 6
+ { .n_name = "_cpu_infos" },
+#define X_NL_SIZE 7
+ { .n_name = NULL },
+};
+
+/*
+ * Namelist for time data.
+ */
+struct nlist timenl[] =
+{
#define X_BOOTTIME 0
{ .n_name = "_boottime" },
-#define X_HZ 1
- { .n_name = "_hz" },
-#define X_STATHZ 2
- { .n_name = "_stathz" },
-#define X_NCHSTATS 3
- { .n_name = "_nchstats" },
-#define X_ALLEVENTS 4
- { .n_name = "_allevents" },
-#define X_POOLHEAD 5
- { .n_name = "_pool_head" },
-#define X_UVMEXP 6
- { .n_name = "_uvmexp" },
-#define X_TIME_SECOND 7
+#define X_TIME_SECOND 1
{ .n_name = "_time_second" },
-#define X_TIME 8
+#define X_TIME 2
{ .n_name = "_time" },
-#define X_CPU_INFOS 9
- { .n_name = "_cpu_infos" },
-#define X_NL_SIZE 10
+#define X_TIMENL_SIZE 3
{ .n_name = NULL },
};
@@ -552,9 +561,7 @@
errx(1, "kvm_nlist: %s %s",
"namelist", kvm_geterr(kd));
for (i = 0; i < __arraycount(namelist)-1; i++)
- if (namelist[i].n_type == 0 &&
- i != X_TIME_SECOND &&
- i != X_TIME) {
+ if (namelist[i].n_type == 0) {
if (doexit++ == 0)
(void)fprintf(stderr,
"%s: undefined symbols:",
@@ -568,6 +575,11 @@
}
}
}
+ if ((todo & (VMSTAT|INTRSTAT)) && !(done & (VMSTAT))) {
+ done |= VMSTAT;
+ if ((c = kvm_nlist(kd, timenl)) == -1 || c == X_TIMENL_SIZE)
+ errx(1, "kvm_nlist: %s %s", "timenl", kvm_geterr(kd));
+ }
if ((todo & (SUMSTAT|INTRSTAT)) && !(done & (SUMSTAT|INTRSTAT))) {
done |= SUMSTAT|INTRSTAT;
(void) kvm_nlist(kd, intrnl);
@@ -636,9 +648,8 @@
clock_gettime(CLOCK_REALTIME, &now);
} else {
if (boottime.tv_sec == 0)
- kread(namelist, X_BOOTTIME, &boottime,
- sizeof(boottime));
- if (kreadc(namelist, X_TIME_SECOND, &nowsec, sizeof(nowsec))) {
+ kread(timenl, X_BOOTTIME, &boottime, sizeof(boottime));
+ if (kreadc(timenl, X_TIME_SECOND, &nowsec, sizeof(nowsec))) {
/*
* XXX this assignment dance can be removed once
* timeval tv_sec is SUS mandated time_t
@@ -646,7 +657,7 @@
now.tv_sec = nowsec;
now.tv_nsec = 0;
} else {
- kread(namelist, X_TIME, &now, sizeof(now));
+ kread(timenl, X_TIME, &now, sizeof(now));
}
}
uptime = now.tv_sec - boottime.tv_sec;
Home |
Main Index |
Thread Index |
Old Index