NetBSD Problem Report #52669
From www@NetBSD.org Sun Oct 29 07:33:18 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id D95957A1CE
for <gnats-bugs@gnats.NetBSD.org>; Sun, 29 Oct 2017 07:33:17 +0000 (UTC)
Message-Id: <20171029073316.E03E07A1E3@mollari.NetBSD.org>
Date: Sun, 29 Oct 2017 07:33:16 +0000 (UTC)
From: eddie@cottongim.org
Reply-To: eddie@cottongim.org
To: gnats-bugs@NetBSD.org
Subject: htop displays wrong used memory
X-Send-Pr-Version: www-1.0
>Number: 52669
>Category: kern
>Synopsis: htop displays wrong used memory
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: analyzed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 29 07:35:00 +0000 2017
>Closed-Date:
>Last-Modified: Fri Nov 24 03:19:21 +0000 2017
>Originator: Eddie Cottongim
>Release: NetBSD 7.0.2 htop-2.0.2
>Organization:
>Environment:
NetBSD ss20.cottongim.org 7.0.2 NetBSD 7.0.2 (ss20) #1: Sat Jan 21 16:19:44 EST 2017 root@ss20.cottongim.org:/usr/src/sys/arch/sparc/compile/ss20 sparc
Note, this is a two processor system and the kernel was compiled with SMP support.
>Description:
htop's memory display shows in use memory as 4TB; actual should be in the 200 MB range. "Bar graph" display looks about right so this may be a problem with printing the value. For example:
Mem[||||||||||||||||||||| 4.00T/293M] Uptime: 01:02:36
Swp[ 0K/144M]
Compare to /proc/meminfo:
ss20$ cat meminfo
total: used: free: shared: buffers: cached:
Mem: 306946048 115740672 191205376 0 53334016 88768512
Swap: 150790144 0 150790144
MemTotal: 299752 kB
MemFree: 186724 kB
MemShared: 0 kB
Buffers: 52084 kB
Cached: 86688 kB
SwapTotal: 147256 kB
SwapFree: 147256 kB
display from "top" looks reasonable: (taken later, values will have changed)
Memory: 75M Act, 32K Inact, 7220K Wired, 11M Exec, 51M File, 184M Free
>How-To-Repeat:
Happens every time htop is invoked.
>Fix:
>Release-Note:
>Audit-Trail:
From: Benny Siegert <bsiegert@gmail.com>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/52669: htop displays wrong used memory
Date: Sun, 29 Oct 2017 11:45:35 +0100
> htop's memory display shows in use memory as 4TB; actual should be in the 200 MB range. "Bar graph" display looks about right so this may be a problem with printing the value. For example:
>
> Mem[||||||||||||||||||||| 4.00T/293M] Uptime: 01:02:36
> Swp[ 0K/144M]
As this is on Sparc, it is likely to be an endianness problem.
Unfortunately, I do not have a Sparc system to test. Could you raise
this upstream, please?
From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/52669: htop displays wrong used memory
Date: Fri, 24 Nov 2017 01:51:36 +0000
This happens because the calculation it uses is, in
linux/Platform.c:Platform_setMemoryValues
long int usedMem = pl->usedMem;
(where usedMem is total - free)
usedMem -= buffersMem + cachedMem;
In netbsd this is a negative number.
for you:
pl->usedMem = total - free = 299752 - 186724 = 113028k
usedMem = pl->usedMem - buffersMem - cachedMem
= 113028k - 53334016 - 88768512
= -29074528
and its bytes -> human unit conversion freaks out at negative numbers.
From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52669 CVS commit: pkgsrc/sysutils/htop
Date: Fri, 24 Nov 2017 02:06:13 +0000
Module Name: pkgsrc
Committed By: maya
Date: Fri Nov 24 02:06:13 UTC 2017
Modified Files:
pkgsrc/sysutils/htop: Makefile distinfo
Added Files:
pkgsrc/sysutils/htop/patches: patch-linux_Platform.c
Log Message:
htop: workaround differences in how linux and netbsd count memory usage
a bogus value is displayed for used memory as usedMem ends up as a negative
quantity. use (total memory - free memory) instead.
PR pkg/52669: htop displays wrong used memory
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 pkgsrc/sysutils/htop/Makefile
cvs rdiff -u -r1.10 -r1.11 pkgsrc/sysutils/htop/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/htop/patches/patch-linux_Platform.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Responsible-Changed-From-To: pkg-manager->kern-bug-people
Responsible-Changed-By: maya@NetBSD.org
Responsible-Changed-When: Fri, 24 Nov 2017 03:19:21 +0000
Responsible-Changed-Why:
Now for why netbsd reports a different value.
State-Changed-From-To: open->analyzed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Fri, 24 Nov 2017 03:19:21 +0000
State-Changed-Why:
This is because the calculation is:
MemTotal - MemFree - buffers - cache
uvmexp.npages - uvmexp.free - uvmexp.filepages - (uvmexp.anonpages + uvmexp.filepages + uvmexp.execpages)
We remove uvmexp.filepages twice, so it can be a negative number.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.