Bug 219829 - "systat -if 1" Peak has wrong display
Summary: "systat -if 1" Peak has wrong display
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
: 160412 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-06-07 02:14 UTC by rezo
Modified: 2021-01-03 16:31 UTC (History)
6 users (show)

See Also:


Attachments
systat if patch (7.37 KB, patch)
2020-07-10 02:16 UTC, ota
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rezo 2017-06-07 02:14:52 UTC
My uname -a:
FreeBSD GIEPHER-PHP 11.0-RELEASE-p4 FreeBSD 11.0-RELEASE-p4 #0 r309666: Thu Dec  8 17:44:40 CST 2016     giepher@GIEPHER-PHP:/usr/obj/usr/src/sys/GIEPHER_PHP_DEBUG  amd64

I use "systat -if 1" last night before I leave my office, today it shows a very large numbers that are impossible just like below:
                    /0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10
     Load Average   ||   

      Interface           Traffic               Peak                Total
       vboxnet0  in      0.000 KB/s          2.868 MB/s          120.139 MB
                 out     0.000 KB/s          0.204 KB/s          782.491 KB

        bridge0  in      0.000 KB/s          0.000 KB/s          450.108 MB
                 out     0.432 KB/s     16777216.000 TB/s          1.078 GB

            lo0  in      0.000 KB/s     16777216.000 TB/s          2.694 MB
                 out     0.000 KB/s     16777216.000 TB/s          2.694 MB

            re0  in      4.678 KB/s     16777216.000 TB/s         10.189 GB
                 out     0.432 KB/s     16777216.000 TB/s          1.226 GB
Comment 1 Fabian Keil 2017-06-07 09:21:28 UTC
systat uses gettimeofday() calls to measure the time difference
between updates.

If the system time jumps, the "elapsed" time can appear to be
less than a second in which case the devisions in fetchifstat()
will result in the devided variables becoming larger.

systat should probably be changed to use clock_gettime()
with a monotonic clock.
Comment 2 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-29 00:20:09 UTC
*** Bug 160412 has been marked as a duplicate of this bug. ***
Comment 3 Mateusz Piotrowski freebsd_committer 2019-06-23 19:22:38 UTC
I get similarly weird Peak information when I have "systat -if 1" running when I restart the netif service:

>                     /0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10
>      Load Average   ||||
> 
>       Interface           Traffic               Peak                Total
>           lagg0  in      3.850 KB/s     16718284.049 TB/s          4.754 KB
>                  out     4.127 KB/s     16718284.049 TB/s          5.292 KB
> 
>           wlan0  in      3.850 KB/s     16718267.389 TB/s          4.754 KB
>                  out     4.127 KB/s     16718267.389 TB/s          5.292 KB
> 
>             lo0  in      0.000 KB/s          0.000 KB/s          317.986 KB
>                  out     0.000 KB/s          0.000 KB/s          317.986 KB

I'm running FreeBSD 13.0-CURRENT r348877 GENERIC-NODEBUG  amd64.
Comment 4 ota 2020-06-11 03:40:49 UTC
I also noticed that I see this happens when I bring down or restart wlan0.

I prepared a fix for this at https://reviews.freebsd.org/D25226 .
If you can try and report your result back, that will be nice.
Comment 5 ota 2020-07-10 02:16:53 UTC
Created attachment 216345 [details]
systat if patch

Same one as https://reviews.freebsd.org/D25226
Comment 6 commit-hook freebsd_committer 2020-07-11 13:56:41 UTC
A commit references this bug:

Author: mr
Date: Sat Jul 11 13:56:37 UTC 2020
New revision: 363095
URL: https://svnweb.freebsd.org/changeset/base/363095

Log:
  Handle device removal and removal+add cases to fix infinity rate.

  PR:		219829
  Submitted by:	ota@j.email.ne.jp
  Reported by:	rezo@live.cn
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D25226

Changes:
  head/usr.bin/systat/ifcmds.c
  head/usr.bin/systat/ifstat.c
  head/usr.bin/systat/systat.1
Comment 7 ota 2020-08-01 04:14:33 UTC
Could you MFC to stable/12, please?
Comment 8 commit-hook freebsd_committer 2020-09-05 17:03:15 UTC
A commit references this bug:

Author: mr
Date: Sat Sep  5 17:02:49 UTC 2020
New revision: 365364
URL: https://svnweb.freebsd.org/changeset/base/365364

Log:
  MFC r363095:
  Handle device removal and removal+add cases to fix infinity rate.

  PR:		219829
  Submitted by:	ota@j.email.ne.jp
  Reported by:	rezo@live.cn
  Differential Revision:	https://reviews.freebsd.org/D25226

Changes:
_U  stable/12/
  stable/12/usr.bin/systat/ifcmds.c
  stable/12/usr.bin/systat/ifstat.c
  stable/12/usr.bin/systat/systat.1
Comment 9 ota 2020-12-27 00:33:10 UTC
Do you plan merging to 11/stable, too?
The bug is fixed in 12/stable and current; we can mark this fixed.
Comment 10 Michael Reifenberger freebsd_committer 2020-12-27 17:37:35 UTC
(In reply to ota from comment #9)
Hi,
I'm not sure since I have limited possibilities to test under RELENG_11.
I'll try it while improving my git capabilities :-)

greetings
---
Michael
Comment 11 commit-hook freebsd_committer 2021-01-03 16:31:23 UTC
A commit in branch stable/11 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=72b42d209ff5b37c615048fb251d7bf9eb276381

commit 72b42d209ff5b37c615048fb251d7bf9eb276381
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2018-11-15 17:25:32 +0000
Commit:     Michael Reifenberger <mr@FreeBSD.org>
CommitDate: 2021-01-03 16:29:50 +0000

    MFC r340361:

    Fix printing of 64-bit counters on 32-bit ppc platforms.

    Several statistic counters are uint64_t values and are printed by systat
    using %lu. This results in displaying wrong numbers. Use PRIu64 instead.
    While there, print variables of size_t using %zd.

    Approved by:            re (gjb@)
    Differential Revision:  https://reviews.freebsd.org/D17838

    (cherry picked from commit 45e9405ea4b05926b22a743237cbfe918206db50)

    systat: use and correctly display 64bit counters.

    Following struct vmtotal changes, make systat use and correctly
    display 64-bit counters.  Switch to humanize_number(3) to overcome
    homegrown arithmetics limits in pretty printing large numbers.  Use
    1024 as a divisor for memory fields to make it consistent with other
    tools and users expectations.

    Submitted by:   Pawel Biernacki <pawel.biernacki@gmail.com>
    Sponsored by:   Mysterious Code Ltd.
    PR:     2137
    Differential revision:  https://reviews.freebsd.org/D13105

    (cherry picked from commit 90dd3e79cc4d721b17c473fdaf3ba3d6d912b138)

    Order declarations alphabetically.
    Match signess of the format and the value.

    Noted by:       bde
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit 1b7a3d1f5ffe700203f12654cd01a08a84551b4a)

    MFC r340361, r345804: catch up on systat in head/

    [Neither of these originally mine, but the latter commit referenced
    fixes an -fno-common issue and the former is a bugfix]

    r340361:
    Fix printing of 64-bit counters on 32-bit ppc platforms.

    Several statistic counters are uint64_t values and are printed by systat
    using %lu. This results in displaying wrong numbers. Use PRIu64 instead.
    While there, print variables of size_t using %zd.

    r345804:
    systat -zarc to display disk activities like -vm

    PR:             213310
    (cherry picked from commit a70af2507f720c2d7f56f51a18d358123b4770a5)

    MFC r360919,r360929,r361084:

    Patch systat -zarc to display cumulative rate and round down large numbers by SI units

    Introduce sysputpage() to display large page size with human readable format.
      Using UI units allows to fit larger numbers in columns.
      Stop calling v_page_size - this is a value that doesn't change at runtime.
      Renamed WINDOW *wnd to *wd to avoid conflict with global *wnd variable.
      Use bit-shift to convert page size to byte.

    PR:             237664, 246458
    Submitted by:   ota@j.email.ne.jp

    (cherry picked from commit 65d1fd13ac2182f7ca0c223bb723fba6d780740f)

    MFC r363095:
    Handle device removal and removal+add cases to fix infinity rate.

    PR:             219829
    Submitted by:   ota@j.email.ne.jp
    Reported by:    rezo@live.cn
    Differential Revision:  https://reviews.freebsd.org/D25226

    (cherry picked from commit 7a446028cedb13a0d2004cf6f584291a976392da)

    PR:             219829, 237664, 246458, 213310, 2137

 usr.bin/systat/Makefile       |   4 +-
 usr.bin/systat/devs.c         | 126 ++++++++++++++++++++++--
 usr.bin/systat/devs.h         |  16 ++-
 usr.bin/systat/extern.h       |   7 +-
 usr.bin/systat/fetch.c        |   9 +-
 usr.bin/systat/icmp6.c        |   9 +-
 usr.bin/systat/ifcmds.c       |   2 +
 usr.bin/systat/ifstat.c       | 118 +++++++++++++---------
 usr.bin/systat/iostat.c       |  46 ++++-----
 usr.bin/systat/ip.c           |   7 +-
 usr.bin/systat/ip6.c          |   7 +-
 usr.bin/systat/main.c         |  13 +--
 usr.bin/systat/swap.c         |  17 +++-
 usr.bin/systat/sysput.c (new) | 118 ++++++++++++++++++++++
 usr.bin/systat/systat.1       |   1 +
 usr.bin/systat/systat.h       |   4 +
 usr.bin/systat/tcp.c          |   3 +-
 usr.bin/systat/vmstat.c       | 221 +++++++++++++++---------------------------
 usr.bin/systat/zarc.c         | 124 +++++++++++++++---------
 19 files changed, 548 insertions(+), 304 deletions(-)
Comment 12 commit-hook freebsd_committer 2021-01-03 16:31:25 UTC
A commit in branch stable/11 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=72b42d209ff5b37c615048fb251d7bf9eb276381

commit 72b42d209ff5b37c615048fb251d7bf9eb276381
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2018-11-15 17:25:32 +0000
Commit:     Michael Reifenberger <mr@FreeBSD.org>
CommitDate: 2021-01-03 16:29:50 +0000

    MFC r340361:

    Fix printing of 64-bit counters on 32-bit ppc platforms.

    Several statistic counters are uint64_t values and are printed by systat
    using %lu. This results in displaying wrong numbers. Use PRIu64 instead.
    While there, print variables of size_t using %zd.

    Approved by:            re (gjb@)
    Differential Revision:  https://reviews.freebsd.org/D17838

    (cherry picked from commit 45e9405ea4b05926b22a743237cbfe918206db50)

    systat: use and correctly display 64bit counters.

    Following struct vmtotal changes, make systat use and correctly
    display 64-bit counters.  Switch to humanize_number(3) to overcome
    homegrown arithmetics limits in pretty printing large numbers.  Use
    1024 as a divisor for memory fields to make it consistent with other
    tools and users expectations.

    Submitted by:   Pawel Biernacki <pawel.biernacki@gmail.com>
    Sponsored by:   Mysterious Code Ltd.
    PR:     2137
    Differential revision:  https://reviews.freebsd.org/D13105

    (cherry picked from commit 90dd3e79cc4d721b17c473fdaf3ba3d6d912b138)

    Order declarations alphabetically.
    Match signess of the format and the value.

    Noted by:       bde
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit 1b7a3d1f5ffe700203f12654cd01a08a84551b4a)

    MFC r340361, r345804: catch up on systat in head/

    [Neither of these originally mine, but the latter commit referenced
    fixes an -fno-common issue and the former is a bugfix]

    r340361:
    Fix printing of 64-bit counters on 32-bit ppc platforms.

    Several statistic counters are uint64_t values and are printed by systat
    using %lu. This results in displaying wrong numbers. Use PRIu64 instead.
    While there, print variables of size_t using %zd.

    r345804:
    systat -zarc to display disk activities like -vm

    PR:             213310
    (cherry picked from commit a70af2507f720c2d7f56f51a18d358123b4770a5)

    MFC r360919,r360929,r361084:

    Patch systat -zarc to display cumulative rate and round down large numbers by SI units

    Introduce sysputpage() to display large page size with human readable format.
      Using UI units allows to fit larger numbers in columns.
      Stop calling v_page_size - this is a value that doesn't change at runtime.
      Renamed WINDOW *wnd to *wd to avoid conflict with global *wnd variable.
      Use bit-shift to convert page size to byte.

    PR:             237664, 246458
    Submitted by:   ota@j.email.ne.jp

    (cherry picked from commit 65d1fd13ac2182f7ca0c223bb723fba6d780740f)

    MFC r363095:
    Handle device removal and removal+add cases to fix infinity rate.

    PR:             219829
    Submitted by:   ota@j.email.ne.jp
    Reported by:    rezo@live.cn
    Differential Revision:  https://reviews.freebsd.org/D25226

    (cherry picked from commit 7a446028cedb13a0d2004cf6f584291a976392da)

    PR:             219829, 237664, 246458, 213310, 2137

 usr.bin/systat/Makefile       |   4 +-
 usr.bin/systat/devs.c         | 126 ++++++++++++++++++++++--
 usr.bin/systat/devs.h         |  16 ++-
 usr.bin/systat/extern.h       |   7 +-
 usr.bin/systat/fetch.c        |   9 +-
 usr.bin/systat/icmp6.c        |   9 +-
 usr.bin/systat/ifcmds.c       |   2 +
 usr.bin/systat/ifstat.c       | 118 +++++++++++++---------
 usr.bin/systat/iostat.c       |  46 ++++-----
 usr.bin/systat/ip.c           |   7 +-
 usr.bin/systat/ip6.c          |   7 +-
 usr.bin/systat/main.c         |  13 +--
 usr.bin/systat/swap.c         |  17 +++-
 usr.bin/systat/sysput.c (new) | 118 ++++++++++++++++++++++
 usr.bin/systat/systat.1       |   1 +
 usr.bin/systat/systat.h       |   4 +
 usr.bin/systat/tcp.c          |   3 +-
 usr.bin/systat/vmstat.c       | 221 +++++++++++++++---------------------------
 usr.bin/systat/zarc.c         | 124 +++++++++++++++---------
 19 files changed, 548 insertions(+), 304 deletions(-)