mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Use kvm_getcptime(3) to fetch the global CPU time stats from a crashdump
since the 'cp_time' symbol doesn't exist in recent kernels. This fixes iostat and vmstat on crash dumps. MFC after: 1 week
This commit is contained in:
parent
f110b23b7d
commit
32c9e3bd01
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181881
|
@ -81,29 +81,27 @@ __FBSDID("$FreeBSD$");
|
|||
static char da[] = "da";
|
||||
|
||||
static struct nlist namelist[] = {
|
||||
#define X_CPTIME 0
|
||||
{ "_cp_time" },
|
||||
#define X_SUM 1
|
||||
#define X_SUM 0
|
||||
{ "_cnt" },
|
||||
#define X_BOOTTIME 2
|
||||
#define X_BOOTTIME 1
|
||||
{ "_boottime" },
|
||||
#define X_HZ 3
|
||||
#define X_HZ 2
|
||||
{ "_hz" },
|
||||
#define X_STATHZ 4
|
||||
#define X_STATHZ 3
|
||||
{ "_stathz" },
|
||||
#define X_NCHSTATS 5
|
||||
#define X_NCHSTATS 4
|
||||
{ "_nchstats" },
|
||||
#define X_INTRNAMES 6
|
||||
#define X_INTRNAMES 5
|
||||
{ "_intrnames" },
|
||||
#define X_EINTRNAMES 7
|
||||
#define X_EINTRNAMES 6
|
||||
{ "_eintrnames" },
|
||||
#define X_INTRCNT 8
|
||||
#define X_INTRCNT 7
|
||||
{ "_intrcnt" },
|
||||
#define X_EINTRCNT 9
|
||||
#define X_EINTRCNT 8
|
||||
{ "_eintrcnt" },
|
||||
#define X_KMEMSTATS 10
|
||||
#define X_KMEMSTATS 9
|
||||
{ "_kmemstatistics" },
|
||||
#define X_KMEMZONES 11
|
||||
#define X_KMEMZONES 10
|
||||
{ "_kmemzones" },
|
||||
#ifdef notyet
|
||||
#define X_DEFICIT XXX
|
||||
|
@ -116,7 +114,7 @@ static struct nlist namelist[] = {
|
|||
{ "_xstats" },
|
||||
#define X_END XXX
|
||||
#else
|
||||
#define X_END 12
|
||||
#define X_END 11
|
||||
#endif
|
||||
{ "" },
|
||||
};
|
||||
|
@ -610,7 +608,8 @@ dovmstat(unsigned int interval, int reps)
|
|||
if (!--hdrcnt)
|
||||
printhdr(ncpus, cpumask);
|
||||
if (kd != NULL) {
|
||||
kread(X_CPTIME, cur.cp_time, sizeof(cur.cp_time));
|
||||
if (kvm_getcptime(kd, cur.cp_time) < 0)
|
||||
errx(1, "kvm_getcptime: %s", kvm_geterr(kd));
|
||||
} else {
|
||||
size = sizeof(cur.cp_time);
|
||||
mysysctl("kern.cp_time", &cur.cp_time, &size, NULL, 0);
|
||||
|
|
|
@ -124,11 +124,9 @@ struct nlist namelist[] = {
|
|||
{ "_tk_nin" },
|
||||
#define X_TK_NOUT 1
|
||||
{ "_tk_nout" },
|
||||
#define X_CP_TIME 2
|
||||
{ "_cp_time" },
|
||||
#define X_BOOTTIME 3
|
||||
#define X_BOOTTIME 2
|
||||
{ "_boottime" },
|
||||
#define X_END 3
|
||||
#define X_END 2
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
@ -463,11 +461,19 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (Cflag > 0) {
|
||||
if (readvar(kd, "kern.cp_time", X_CP_TIME,
|
||||
&cur.cp_time, sizeof(cur.cp_time)) != 0) {
|
||||
Cflag = 0;
|
||||
warnx("disabling CPU time statistics");
|
||||
if (kd == NULL) {
|
||||
if (readvar(kd, "kern.cp_time", 0,
|
||||
&cur.cp_time, sizeof(cur.cp_time)) != 0)
|
||||
Cflag = 0;
|
||||
} else {
|
||||
if (kvm_getcptime(kd, cur.cp_time) < 0) {
|
||||
warnx("kvm_getcptime: %s",
|
||||
kvm_geterr(kd));
|
||||
Cflag = 0;
|
||||
}
|
||||
}
|
||||
if (Cflag == 0)
|
||||
warnx("disabling CPU time statistics");
|
||||
}
|
||||
|
||||
if (!--headercount) {
|
||||
|
|
Loading…
Reference in a new issue