Fix header output when -P is specified and (ncpus - 1) != maxid.
Reported by: Hiroaki Shimizu PR: 152738
This commit is contained in:
parent
de2b02fc74
commit
83a15ccf22
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=271410
@ -657,6 +657,8 @@ dovmstat(unsigned int interval, int reps)
|
|||||||
uptime = getuptime();
|
uptime = getuptime();
|
||||||
halfuptime = uptime / 2;
|
halfuptime = uptime / 2;
|
||||||
rate_adj = 1;
|
rate_adj = 1;
|
||||||
|
ncpus = 1;
|
||||||
|
maxid = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the user stops the program (control-Z) and then resumes it,
|
* If the user stops the program (control-Z) and then resumes it,
|
||||||
@ -702,7 +704,7 @@ dovmstat(unsigned int interval, int reps)
|
|||||||
}
|
}
|
||||||
for (hdrcnt = 1;;) {
|
for (hdrcnt = 1;;) {
|
||||||
if (!--hdrcnt)
|
if (!--hdrcnt)
|
||||||
printhdr(ncpus, cpumask);
|
printhdr(maxid, cpumask);
|
||||||
if (kd != NULL) {
|
if (kd != NULL) {
|
||||||
if (kvm_getcptime(kd, cur.cp_time) < 0)
|
if (kvm_getcptime(kd, cur.cp_time) < 0)
|
||||||
errx(1, "kvm_getcptime: %s", kvm_geterr(kd));
|
errx(1, "kvm_getcptime: %s", kvm_geterr(kd));
|
||||||
@ -753,7 +755,7 @@ dovmstat(unsigned int interval, int reps)
|
|||||||
errx(1, "%s", devstat_errbuf);
|
errx(1, "%s", devstat_errbuf);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
printhdr(ncpus, cpumask);
|
printhdr(maxid, cpumask);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -822,7 +824,7 @@ dovmstat(unsigned int interval, int reps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
printhdr(int ncpus, u_long cpumask)
|
printhdr(int maxid, u_long cpumask)
|
||||||
{
|
{
|
||||||
int i, num_shown;
|
int i, num_shown;
|
||||||
|
|
||||||
@ -834,7 +836,7 @@ printhdr(int ncpus, u_long cpumask)
|
|||||||
(void)printf("disk");
|
(void)printf("disk");
|
||||||
(void)printf(" faults ");
|
(void)printf(" faults ");
|
||||||
if (Pflag) {
|
if (Pflag) {
|
||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i <= maxid; i++) {
|
||||||
if (cpumask & (1ul << i))
|
if (cpumask & (1ul << i))
|
||||||
printf("cpu%-2d ", i);
|
printf("cpu%-2d ", i);
|
||||||
}
|
}
|
||||||
@ -850,8 +852,10 @@ printhdr(int ncpus, u_long cpumask)
|
|||||||
dev_select[i].unit_number);
|
dev_select[i].unit_number);
|
||||||
(void)printf(" in sy cs");
|
(void)printf(" in sy cs");
|
||||||
if (Pflag) {
|
if (Pflag) {
|
||||||
for (i = 0; i < ncpus; i++)
|
for (i = 0; i <= maxid; i++) {
|
||||||
printf(" us sy id");
|
if (cpumask & (1ul << i))
|
||||||
|
printf(" us sy id");
|
||||||
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
} else
|
} else
|
||||||
printf(" us sy id\n");
|
printf(" us sy id\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user