Bug 203917 - [patch] systat -vm to display physical and kernel memory % usage
Summary: [patch] systat -vm to display physical and kernel memory % usage
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Marcelo Araujo
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-10-21 07:48 UTC by ota
Modified: 2016-01-07 04:02 UTC (History)
1 user (show)

See Also:


Attachments
systat -vm phys/kern mem usage (2.20 KB, patch)
2015-10-21 07:48 UTC, ota
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ota 2015-10-21 07:48:20 UTC
Created attachment 162273 [details]
systat -vm phys/kern mem usage

Added 2 new fields at top left memory section.

Before:

Mem:KB    REAL            VIRTUAL            
        Tot   Share      Tot    Share    Free
Act  113596   17720   703456    25104 1672360
All  239340   20096  1371300    36548

After:

Phy: 35%     REAL       VIRTUAL     Kmem: 17%
Mem:    Tot   Share      Tot    Share    Free
Act  503616   16696  1370680    27544 1307516
All  554684   18308  1967904    45132
Comment 1 Marcelo Araujo freebsd_committer freebsd_triage 2015-11-25 02:50:54 UTC
I will take it. Thanks!
Comment 2 Marcelo Araujo freebsd_committer freebsd_triage 2015-11-26 05:37:54 UTC
(In reply to ota from comment #0)

Hi,

I would suggest a different output, something like:

   13 users    Load  0.52  0.36  0.33                  Nov 26 13:36
   Mem usage:  66%Phy 26%Kmem
                                                        VN PAGER   SWAP PAGER
Mem:    Tot   Share      Tot    Share    Free           in   out     in   out
Act 2668744   61628  9277296   110976 2644416  count
All 2697008   70252  9366896   173320          pages
Proc:                                                            Interrupts
  r   p   d   s   w   Csw  Trp  Sys  Int  Sof  Flt        ioflt   687 total
            231      1841 1969 4795  113   41 1262        cow         atkbd0 1
                                                     1260 zfod     14 acpi0 9
 0.6%Sys   0.0%Intr  3.3%User  0.0%Nice 96.1%Idle         ozfod     2 ehci0 23
|    |    |    |    |    |    |    |    |    |           %ozfod   244 cpu0:time
>>                                                        daefr       hdac0 264
                                           dtbuf      381 prcfr    76 xhci0 265
Namei     Name-cache   Dir-cache    208972 desvn     1773 totfr     9 em0 266
   Calls    hits   %    hits   %     26987 numvn          react       hdac1 267
     160     152  95                 23689 frevn          pdwak    12 ahci0 268
                                                      318 pdpgs    70 cpu1:time
Disks  ada0 pass0                                         intrn   100 cpu3:time
KB/t  23.06  0.00                                 2418460 wire    160 cpu2:time
tps      19     0                                  746472 act
MB/s   0.42  0.00                                 1999176 inact
%busy     0     0                                         cache
                                                  2644416 free
                                                          buf 

Note the Mem usage on top.
I changed your patch already, if you have no objection, I will check with other developers what they thing about it.

Best.
Comment 3 ota 2015-12-18 07:17:24 UTC
(In reply to Marcelo Araujo from comment #2)

Sorry for late reply.  I didn't realize there was an update.

I don't have objections about style change.

However, it looks the 2nd line labels, "REAL     VIRTUAL" one is gone.
This label indicates left Tot/Share is for real memory and right one is for virtual memory.  We need to put it back; otherwise, people won't know what they are.

MEMROW begins with 2 and I suppose you've used it.
I think we can start MEMROW from 1 to display %usage and keep the rest as is.
As we have more space, why don't we add % virtual memory usage as well?

Thanks,
Hiro
Comment 4 Marcelo Araujo freebsd_committer freebsd_triage 2015-12-18 07:19:09 UTC
(In reply to ota from comment #3)
I'm aware of it, I believe I did a wrong copy/past here.

Here is the patch and the right output, please, double check it:

https://reviews.freebsd.org/D4281

Best,
Comment 5 ota 2015-12-18 13:00:06 UTC
(In reply to Marcelo Araujo from comment #4)

Yes, that looks like the case.
The page don't seem to allow me to put comments.
So, I will post here:

#1
I'd reverse these 2 lines of line 315 and 316.
 mvprintw(MEMROW, MEMCOL, "Mem: KB REAL VIRTUAL");
 mvprintw(STATROW + 1, STATCOL + 3, "Mem usage: %%Phy %%Kmem");
MEMROW is 2 and STATROW is 0, thus 0+1.
The line 316 is to draw above line 315.

#2
I'm not sure which ROW is the best fit.
I had thought these would belong to MEMROW and tried to stick with it.
I think our options are:
 1. Keep as is and treat %mem as one of STATROW.
 2. Make MEMROW=1 and adjust all MEMROW + n.
 3. Use MEMROW but the new row will do MEMROR - 1.

#3
Given we have more space, we can also add total virtual memory,%%vir, by
        putfloat(100.0 * total.t_avm / total.t_vm,
           MEMROW, MEMCOL + 41, 3, 0, 1);
Comment 6 Marcelo Araujo freebsd_committer freebsd_triage 2015-12-28 02:03:19 UTC
(In reply to ota from comment #5)
I have addressed items #1 and #2, the #3 looks like that is the VM available and not the VM used by the system, on systat we are showing the Mem usage. As suggested by you, the VM used shows 99% in my system, what for me seems not right.


I would like to commit it without adding the Virtual Memory.

And perhaps, we can add it in the future.

Best,
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-12-28 02:08:17 UTC
A commit references this bug:

Author: araujo
Date: Mon Dec 28 02:07:57 UTC 2015
New revision: 292817
URL: https://svnweb.freebsd.org/changeset/base/292817

Log:
  Add on systat -vm the ability to display the physical and kernel memory
  percent usage.

  PR:		bin/203917
  Submitted by:	ota <ota@j.email.ne.jp>
  Approved by:	bapt (mentor)
  Differential Revision:	https://reviews.freebsd.org/D4281

Changes:
  head/usr.bin/systat/vmstat.c
Comment 8 Marcelo Araujo freebsd_committer freebsd_triage 2015-12-28 02:10:34 UTC
Committed without add the Virtual memory usage, will double check it in the future, but feel free to re-send a patch that covers it. If you intend to send a patch, please Cc me.

Best.
Comment 9 ota 2016-01-07 04:02:31 UTC
(In reply to Marcelo Araujo from comment #8)

Thanks for committing.
I will take a look again for vm usage although I expect it will take a while to get to it.