NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/52639: vmstat -u is broken on some architectures

>Number:         52639
>Category:       kern
>Synopsis:       vmstat -u is broken on some architectures
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 23 01:25:00 +0000 2017
>Originator:     Paul Goyette
>Release:        NetBSD 8.99.3
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
System: NetBSD 8.99.3 NetBSD 8.99.3 (SPEEDY 2017-10-02 09:48:54 UTC) #0: Mon Oct 2 14:15:08 UTC 2017 amd64
Architecture: x86_64
Machine: amd64
Internal kernel "argument" data for xxxHIST entries are stored as unsigned
long.  However, when the data is exported to userland via sysctl, the data
are converted to uint64_t.  This causes problems on some architectures
(notable, arm) when the 64-bit value is passed to printf, with formats that
reference shorter data types.  Thus on these architectures, the "vmstat
-u <history>" command is useless, and one needs to use ddb(4) to dump the
history data.

The following sample program shows what happens in vmstat:

#include <stdio.h>
#include <inttypes.h>

int main(int argc, int *argv)
	uint64_t	v1 = 0xdeadbeef12345678;
	uint64_t	v2 = 0xfeed98765432dada;

	printf("with %%"PRIx64": %"PRIx64", %"PRIx64"\n", v1, v2);
	printf("with %%lx: %lx, %lx\n", v1, v2);

1. Modify the kernel structure to contain "uint64_t" values, rather than
   the current "unsigned long" values.

	- pretty much doubles the size of xxxHIST tables, some of
	  which are already fairly large (hundreds or thousands of
	- adds an additional restriction on format strings, mandating
	  use of only 64-bit formats (we already prohibit using %s)
	- rototill all existing xxxHIST format strings accordingly

2. Modify the sysctl-export structure to contain "unsigned long" values

	- is an "unsigned long" always big enough to hold a pointer?
	- for MIPS, is a "long" the same size in both kernel and


Home | Main Index | Thread Index | Old Index