The sysutils/htop port reads /compat/linux/proc/meminfo to calculate the amount of memory used. The code that generates this file resides in sys/compat/linprocfs/linprocfs.c. Here, the amount of available memory is intentionally misreported: /* * The correct thing here would be: * memfree = cnt.v_free_count * PAGE_SIZE; memused = memtotal - memfree; * * but it might mislead linux binaries into thinking there * is very little memory left, so we cheat and tell them that * all memory that isn't wired down is free. */ memused = cnt.v_wire_count * PAGE_SIZE; memfree = memtotal - memused; Fix: The attached patch uses sysctl to read the actual amount of available memory, just as top does. Patch attached with submission follows: How-To-Repeat: Run top and htop simultaneously. Notice that htop reports very low memory usage while top reports the correct value.
Responsible Changed From-To: freebsd-ports-bugs->yzlin Over to maintainer (via the GNATS Auto Assign Tool)
Here is my rewritten patch. It uses sysctl and llibkvm for memory info, without linux proc. I think that there is a need to include it to sysutils/htop and bump portversion.
2011/7/24 Sayetsky Anton <jason@linux.lg.ua>: > Here is my rewritten patch. It uses sysctl and llibkvm for memory > info, without linux proc. > I think that there is a need to include it to sysutils/htop and bump > portversion. > Sorry, there is a small difference (about 40 mbytes) between used mem that reports top and htop with previous patch. I've attached a new version of ProcessList.c patch. Also, may we need to add special counter for inactive memory?
Responsible Changed From-To: yzlin->pav Maintainer was changed
State Changed From-To: open->feedback Is this still valid for 0.9? If yes, can you contact the new maintainer about it?
Yes, htop-0.9 still has bug with memory calculation. I will write a patch for new version as soon as possible.
Here is a patch for htop-0.9, with it htop calculates all memory usage correctly ("used mem" in htop means freebsd's active memory). Please, bump portrevision and commit.
State Changed From-To: feedback->closed Committed, thanks!
pav 2011-08-12 08:30:34 UTC FreeBSD ports repository Modified files: sysutils/htop Makefile sysutils/htop/files patch-configure.ac Added files: sysutils/htop/files patch-ProcessList.c Log: - Fix calculation of available memory PR: ports/157195 Submitted by: Sayetsky Anton <jason@linux.lg.ua> Approved by: Hung-Yi Chen <gaod@hychen.org> (maintainer) Revision Changes Path 1.21 +1 -0 ports/sysutils/htop/Makefile 1.5 +87 -0 ports/sysutils/htop/files/patch-ProcessList.c (new) 1.4 +11 -3 ports/sysutils/htop/files/patch-configure.ac _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"