NetBSD Problem Report #60440

From he@smistad.uninett.no  Sat Jul 11 13:26:11 2026
Return-Path: <he@smistad.uninett.no>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "YR2" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5D3891A923F
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 11 Jul 2026 13:26:11 +0000 (UTC)
Message-Id: <20260711132607.3FB8143FA48@smistad.uninett.no>
Date: Sat, 11 Jul 2026 15:26:07 +0200 (CEST)
From: he@NetBSD.org
Reply-To: he@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: systat vmstat SysCal field can overflow
X-Send-Pr-Version: 3.95
X-From4GNATS: "he@NetBSD.org via gnats" <gnats-admin@NetBSD.org>

>Number:         60440
>Category:       bin
>Synopsis:       systat vmstat SysCal field can overflow
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 11 13:30:01 +0000 2026
>Last-Modified:  Sat Jul 11 20:40:01 +0000 2026
>Originator:     Havard Eidnes
>Release:        NetBSD 10.1
>Organization:
	I try...
>Environment:
System: NetBSD castor.urc.uninett.no 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	The display of number of syscalls (per second?) in "systat
	vm" output can overflow, resulting in a display containing e.g.

Proc:r  d  s        Csw  Traps SysCal  Intr   Soft  Fault     PAGING   SWAPPING
    11  2 20        623   1637 ******   269    457   1637     in  out   in  out

	I would much prefer that the value is shown, scaled, e.g.

Proc:r  d  s        Csw  Traps SysCal  Intr   Soft  Fault     PAGING   SWAPPING
    10  2 16        654    210  3804K    63    453    210     in  out   in  out

>How-To-Repeat:
	Run "systat vm" on a reasonably high-end amd64 system, loaded
	with activity (e.g. a rust build with high MAKE_JOBS setting).
	This is especially visible during periods when rust-installer is run.
>Fix:
	It turns out this is fixable by removing code.

	Why the "time-based" values are not scaled?  Don't know,
	but it looks like the code was made this way conciously.

	Is this a reasonable change?

Index: vmstat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.92
diff -u -r1.92 vmstat.c
--- vmstat.c    28 Mar 2023 00:00:30 -0000      1.92
+++ vmstat.c    11 Jul 2026 13:14:24 -0000
@@ -783,10 +783,7 @@
        }
        (void)snprintf(b, sizeof b, "%*d", w, n);
        if ((int)strlen(b) > w) {
-               if (display_mode == TIME)
-                       hline('*', w);
-               else
-                       puthumanint(n, l, c, w);
+               puthumanint(n, l, c, w);
                return;
        }
        addstr(b);

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60440 CVS commit: src/usr.bin/systat
Date: Sat, 11 Jul 2026 12:14:13 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sat Jul 11 16:14:13 UTC 2026

 Modified Files:
 	src/usr.bin/systat: vmstat.c

 Log Message:
 PR/60440: Havard Eidnes: avoid systat vmstat SysCal field overflow by scaling


 To generate a diff of this commit:
 cvs rdiff -u -r1.92 -r1.93 src/usr.bin/systat/vmstat.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: he@netbsd.org
Subject: Re: bin/60440: systat vmstat SysCal field can overflow
Date: Sun, 12 Jul 2026 03:33:03 +0700

     Date:        Sat, 11 Jul 2026 13:30:01 +0000 (UTC)
     From:        "he@NetBSD.org via gnats" <gnats-admin@NetBSD.org>
     Message-ID:  <20260711133001.9EA061A9244@mollari.NetBSD.org>


   | 	Why the "time-based" values are not scaled?  Don't know,
   | 	but it looks like the code was made this way conciously.

 My guess would be that someone believed (and perhaps it is even true
 in some cases) that TIME meant duration - absolutely no-one wants to
 see durations in units of 16:40 (mm:ss), or even worse 17:04 if the
 scaling is using binary K's (Ki's) rather than decimal for that.

 That could be another reason, when I see your 3804K syscall/second,
 I assume that would mean ~3804000 (decimal scaling), and not ~3895000.
 If it doesn't (if systat is always using binary scaling for this) then
 that could be another reason.

   | 	Is this a reasonable change?

 Looks like it to me (for HEAD, I doubt this is important enough to
 pull up anywhere).

 But I would also redo the layout of that section a little, the Traps
 SysCal and Fault sections could all do with having 1 extra column, which
 would also allow "SysCal" to turn into "SysCall" and prevent anyone
 believing it is related to the system calendar...

 The Proc:r d s could do with an xtra column for 's', which could just
 be allocated, or perhaps better, rearranged to be "s d r" so the "s"
 could slide under "Proc" for as many columns as it actually needs (if
 we end up with 99999 processes in short term sleeps, we have bigger
 problems than misalignment there - or add scaling if that happens, again,
 decimal scaling).

 I'd also like to see the long column of disks sorted, and by an algorithm
 that places all dkN's after everything else .. even on the tallest window
 I can make with a reasonable font size to read (140 lines) all my possible
 disk units don't fit as they are.  ":ignore dk*" helps, but that's not
 always what is wanted.

 If you'd like to just make the fix you suggested, I am willing to do
 the rest of it, or if you'd prefer to have a go at moving this relic from
 the 1980's to suit modern systems, have at it.   (The "systat vm" page was
 a merge into systat of a separate standalone prog I gave CSRG sometime in
 that period - which is why that page looks so different from all the others,
 it wasn't designed to be part of systat originally.)

 kre

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/60440: systat vmstat SysCal field can overflow
Date: Sun, 12 Jul 2026 03:36:06 +0700

 Oh, I see Christos already committed that change, but for the
 rest of it ...

 kre

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.