From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Feb 21 13:50:10 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B96AD1065670 for ; Tue, 21 Feb 2012 13:50:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8E8E38FC12 for ; Tue, 21 Feb 2012 13:50:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q1LDoAsw000562 for ; Tue, 21 Feb 2012 13:50:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q1LDoAiV000561; Tue, 21 Feb 2012 13:50:10 GMT (envelope-from gnats) Resent-Date: Tue, 21 Feb 2012 13:50:10 GMT Resent-Message-Id: <201202211350.q1LDoAiV000561@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Volodymyr Kostyrko Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 605851065672 for ; Tue, 21 Feb 2012 13:48:11 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 4F1C48FC08 for ; Tue, 21 Feb 2012 13:48:11 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q1LDmBfU024256 for ; Tue, 21 Feb 2012 13:48:11 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q1LDmBjR024255; Tue, 21 Feb 2012 13:48:11 GMT (envelope-from nobody) Message-Id: <201202211348.q1LDmBjR024255@red.freebsd.org> Date: Tue, 21 Feb 2012 13:48:11 GMT From: Volodymyr Kostyrko To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/165361: x11-wm/e17-module-mem counts memory incorrectly X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Feb 2012 13:50:10 -0000 >Number: 165361 >Category: ports >Synopsis: x11-wm/e17-module-mem counts memory incorrectly >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 21 13:50:10 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Volodymyr Kostyrko >Release: RELENG_9 >Organization: None >Environment: FreeBSD green.tandem.local 9.0-STABLE FreeBSD 9.0-STABLE #0 r231929: Mon Feb 20 12:00:55 EET 2012 arcade@green.tandem.local:/usr/obj/usr/src/sys/MINIMAL_4BSD amd64 >Description: Enlightenment indeed has very small footprint, but when I have big swap or memory (bigger then signed int) this modules draws junk. I composed a small patch which changes how the module sees things. I don't think it's final because for me it's just works. While we can settle on a more simple way of dealing with things without counting just any single byte, like: #define PAGES_PER_MEG (1024 * 1024) / getpagesize() int xM; xM = some_page_count() / PAGES_PER_MEG; This way we would count distinct megabytes and not bother with bytes. We could also skip all '>> 10' and '/ 1024' in module source. If it's 0k I can try to rewrite the sources this way. My patch changes _only_ freebsd part of module, the linux one still needs to be cleaned up. >How-To-Repeat: >Fix: Patch attached with submission follows: diff -ur src/e_mod_main.c src.new/e_mod_main.c --- src/e_mod_main.c 2010-11-13 17:56:21.000000000 +0200 +++ src.new/e_mod_main.c 2012-02-21 15:33:01.000000000 +0200 @@ -415,7 +415,7 @@ { Instance *inst; Edje_Message_Float msg; - int real, swap, total_real, total_swap; + long long real, swap, total_real, total_swap; char real_str[100]; char swap_str[100]; @@ -424,10 +424,10 @@ if (!inst->ci->show_percent) { - snprintf (real_str, sizeof (real_str), "Real: %d/%d MB", (real / 1024), + snprintf (real_str, sizeof (real_str), "Real: %lld/%lld MB", (real / 1024), (total_real / 1024)); if ( total_swap ) - snprintf (swap_str, sizeof (swap_str), "Swap: %d/%d MB", (swap / 1024), + snprintf (swap_str, sizeof (swap_str), "Swap: %lld/%lld MB", (swap / 1024), (total_swap / 1024)); } else diff -ur src/e_mod_main.h src.new/e_mod_main.h --- src/e_mod_main.h 2010-11-13 17:56:21.000000000 +0200 +++ src.new/e_mod_main.h 2012-02-21 09:39:04.000000000 +0200 @@ -34,7 +34,7 @@ void _mem_config_updated(Config_Item *ci); void _config_mem_module(Config_Item *ci); -void _mem_get_values(Config_Item *ci, int *real, int *swap, int *total_real, int *total_swap); +void _mem_get_values(Config_Item *ci, long long *real, long long *swap, long long *total_real, long long *total_swap); extern Config *mem_config; #endif diff -ur src/machdep_freebsd.c src.new/machdep_freebsd.c --- src/machdep_freebsd.c 2010-11-13 17:56:21.000000000 +0200 +++ src.new/machdep_freebsd.c 2012-02-21 15:33:23.000000000 +0200 @@ -30,13 +30,13 @@ } static int -swapinfo (int *total, int *used) +swapinfo (long long *total, long long *used) { int pagesize = getpagesize (); size_t mibsize, size; struct xswdev xsw; int mib[16], n; - int tmp_total, tmp_used; + long long tmp_total, tmp_used; *total = 0; *used = 0; @@ -63,8 +63,8 @@ tmp_total = (long long) xsw.xsw_nblks * pagesize; tmp_used = (long long) xsw.xsw_used * pagesize; - *total += tmp_total; - *used += tmp_used; + *total += tmp_total >> 10; + *used += tmp_used >> 10; } if (errno != ENOENT) warn ("sysctl()"); @@ -75,10 +75,10 @@ void _mem_get_values (ci, phys_used, sw_used, phys_total, sw_total) Config_Item *ci; - int *phys_used; - int *sw_used; - int *phys_total; - int *sw_total; + long long *phys_used; + long long *sw_used; + long long *phys_total; + long long *sw_total; { int total_pages, inactive_pages, free_pages; @@ -102,8 +102,8 @@ return; } - *phys_total = (total_pages * pagesize) >> 10; - *phys_used = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10; + *phys_total = ((long long)total_pages * pagesize) >> 10; + *phys_used = (((long long)total_pages - free_pages - inactive_pages) * pagesize) >> 10; if ((swapinfo (sw_total, sw_used)) != 0) { >Release-Note: >Audit-Trail: >Unformatted: