From 760c98b7bfa650361e9c1549f2c2ca264052787a Mon Sep 17 00:00:00 2001 From: tedu Date: Wed, 27 Jul 2016 14:44:59 +0000 Subject: [PATCH] increase the size of forkstat fields to accomodate large values --- sbin/sysctl/sysctl.c | 18 +++++++++--------- sys/sys/vmmeter.h | 18 +++++++++--------- usr.bin/vmstat/vmstat.c | 10 +++++----- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 9132c587745..6e0d630b852 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.215 2016/06/18 10:36:13 vgross Exp $ */ +/* $OpenBSD: sysctl.c,v 1.216 2016/07/27 14:44:59 tedu Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -1732,28 +1732,28 @@ sysctl_forkstat(char *string, char **bufpp, int mib[], int flags, int *typep) (void)printf("%s%s", string, equ); switch (indx) { case KERN_FORKSTAT_FORK: - (void)printf("%d\n", fks.cntfork); + (void)printf("%u\n", fks.cntfork); break; case KERN_FORKSTAT_VFORK: - (void)printf("%d\n", fks.cntvfork); + (void)printf("%u\n", fks.cntvfork); break; case KERN_FORKSTAT_TFORK: - (void)printf("%d\n", fks.cnttfork); + (void)printf("%u\n", fks.cnttfork); break; case KERN_FORKSTAT_KTHREAD: - (void)printf("%d\n", fks.cntkthread); + (void)printf("%u\n", fks.cntkthread); break; case KERN_FORKSTAT_SIZFORK: - (void)printf("%d\n", fks.sizfork); + (void)printf("%llu\n", fks.sizfork); break; case KERN_FORKSTAT_SIZVFORK: - (void)printf("%d\n", fks.sizvfork); + (void)printf("%llu\n", fks.sizvfork); break; case KERN_FORKSTAT_SIZTFORK: - (void)printf("%d\n", fks.siztfork); + (void)printf("%llu\n", fks.siztfork); break; case KERN_FORKSTAT_SIZKTHREAD: - (void)printf("%d\n", fks.sizkthread); + (void)printf("%llu\n", fks.sizkthread); break; } return (-1); diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h index 1e5cb6696c3..2da08364251 100644 --- a/sys/sys/vmmeter.h +++ b/sys/sys/vmmeter.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmeter.h,v 1.14 2012/04/12 14:25:57 deraadt Exp $ */ +/* $OpenBSD: vmmeter.h,v 1.15 2016/07/27 14:44:59 tedu Exp $ */ /* $NetBSD: vmmeter.h,v 1.9 1995/03/26 20:25:04 jtc Exp $ */ /*- @@ -62,14 +62,14 @@ struct vmtotal { * Fork/vfork/__tfork accounting. */ struct forkstat { - int cntfork; /* number of fork() calls */ - int cntvfork; /* number of vfork() calls */ - int cnttfork; /* number of __tfork() calls */ - int cntkthread; /* number of kernel threads created */ - int sizfork; /* VM pages affected by fork() */ - int sizvfork; /* VM pages affected by vfork() */ - int siztfork; /* VM pages affected by __tfork() */ - int sizkthread; /* VM pages affected by kernel threads */ + uint32_t cntfork; /* number of fork() calls */ + uint32_t cntvfork; /* number of vfork() calls */ + uint32_t cnttfork; /* number of __tfork() calls */ + uint32_t cntkthread; /* number of kernel threads created */ + uint64_t sizfork; /* VM pages affected by fork() */ + uint64_t sizvfork; /* VM pages affected by vfork() */ + uint64_t siztfork; /* VM pages affected by __tfork() */ + uint64_t sizkthread; /* VM pages affected by kernel threads */ }; /* These sysctl names are only really used by sysctl(8) */ diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 536610bfdc4..71246fb85fb 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,5 @@ /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ -/* $OpenBSD: vmstat.c,v 1.139 2015/12/24 03:25:08 mmcc Exp $ */ +/* $OpenBSD: vmstat.c,v 1.140 2016/07/27 14:44:59 tedu Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -605,15 +605,15 @@ doforkst(void) kread(X_FORKSTAT, &fks, sizeof(struct forkstat)); } - (void)printf("%d forks, %d pages, average %.2f\n", + (void)printf("%u forks, %llu pages, average %.2f\n", fks.cntfork, fks.sizfork, (double)fks.sizfork / fks.cntfork); - (void)printf("%d vforks, %d pages, average %.2f\n", + (void)printf("%u vforks, %llu pages, average %.2f\n", fks.cntvfork, fks.sizvfork, (double)fks.sizvfork / (fks.cntvfork ? fks.cntvfork : 1)); - (void)printf("%d __tforks, %d pages, average %.2f\n", + (void)printf("%u __tforks, %llu pages, average %.2f\n", fks.cnttfork, fks.siztfork, (double)fks.siztfork / (fks.cnttfork ? fks.cnttfork : 1)); - (void)printf("%d kthread creations, %d pages, average %.2f\n", + (void)printf("%u kthread creations, %llu pages, average %.2f\n", fks.cntkthread, fks.sizkthread, (double)fks.sizkthread / (fks.cntkthread ? fks.cntkthread : 1)); } -- 2.20.1