vmstat with -P option under multi-CPU environment doesn't display the header correctly if it has a cpu unavailable. the reason is below: in the function "printhdr()", ncpus is the number of CPUs available, not the number of all CPUs. so it might have the case that printf() is not called enough times for the number of all CPUs. 842: for (i = 0; i < ncpus; i++) { 843: if (cpumask & (1ul << i)) 844: printf("cpu%-2d ", i); 845: } on the other hand, "pcpustats()", which display the state of multiple CPUs, this works fine, using maxid which is the number of all CPUs. 1122: for (i = 0; i <= maxid; i++) { 1123: if ((cpumask & (1ul << i)) == 0) 1124: continue; 1125: for (state = 0; state < CPUSTATES; ++state) { 1126: tmp = cur_cp_times[i * CPUSTATES + state]; 1127: cur_cp_times[i * CPUSTATES + state] -= last_cp_times[i * CPUSTATES + state]; 1128: last_cp_times[i * CPUSTATES + state] = tmp; 1129: } 1130: } Fix: this is a patch for vmstat.c at revision 1.109 http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/usr.bin/vmstat/vmstat.c How-To-Repeat: did the code inspection and haven't actually run the problem. don't have multi-cpu machine for the first place lol.
A commit references this bug: Author: hrs Date: Wed Sep 10 22:34:08 UTC 2014 New revision: 271410 URL: http://svnweb.freebsd.org/changeset/base/271410 Log: Fix header output when -P is specified and (ncpus - 1) != maxid. Reported by: Hiroaki Shimizu PR: 152738 Changes: head/usr.bin/vmstat/vmstat.c
Committed with a minor modification. Thank you for your report.