Created attachment 223771 [details] Display per-process swap usage - diff against releng/13.0 and contains extra improvements This is an improvement to "systat -swap" to display high swap space processes in addition to swap process. It uses libprocstat to find swap backed vm entries. It adds each of vm size from the address space minus resident memory to figure out swapped out page size. Some example outputs are pasted below: /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 Load Average | Device/Path Size Used |0% /10 /20 /30 /40 / 60\ 70\ 80\ 90\ 100| ada0s1b 2048M 2034M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX zvol/sys/tempora 1024M 1015M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX zvol/sys/swap 1024M 1014M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Total 4096M 4063M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Pid Username Command Swap/Total Per-Process Per-System 24153 hiro seamonkey 98M / 1G 7% 2% 23677 hiro xfce4-pane 28M / 81M 34% XXX 0% 23629 hiro xfce4-sess 25M / 118M 21% XX 0% 23681 hiro xfdesktop 20M / 58M 34% XXX 0% 23678 hiro thunar 15M / 43M 36% XXX 0% 23658 hiro at-spi-bus 14M / 23M 63% XXXXXX 0% 23660 hiro gvfsd 12M / 21M 56% XXXXX 0% Disks ada0 ada1 ada2 cd0 pass0 pass1 pass2 pass3 KB/t 8.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tps 0 0 0 0 1 0 0 0 MB/s 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 %busy 0 0 0 0 0 0 0 0 /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 Load Average | Device/Path Size Used |0% /10 /20 /30 /40 / 60\ 70\ 80\ 90\ 100| ada0s1b 2048M 1046M XXXXXXXXXXXXXXXXXXXXXXXXX Pid Username Command Swap/Total Per-Process Per-System 12696 hiro java 2G / 3G 62% XXXXXX 85% XXXXXXXX 2201 hiro xfdesktop 21M / 51M 41% XXXX 1% 2217 hiro gvfsd-tras 19M / 31M 61% XXXXXX 0% 2214 hiro gvfs-gphot 17M / 26M 64% XXXXXX 0% 2212 hiro gvfs-hal-v 17M / 25M 64% XXXXXX 0% 2206 hiro gvfsd 16M / 27M 59% XXXXX 0% 2203 hiro xfsettings 15M / 44M 35% XXX 0% 2260 hiro xterm 15M / 24M 64% XXXXXX 0% 2197 hiro xfce4-pane 15M / 45M 33% XXX 0% Disks ada0 da0 cd0 pass0 pass1 pass2 KB/t 13.87 0.00 0.00 0.00 0.00 0.00 tps 14 0 0 1 0 0 MB/s 0.18 0.00 0.00 0.00 0.00 0.00 %busy 1 0 0 0 0 0
Created https://reviews.freebsd.org/D29695.
Just curious, do you consider adding this functionality to top? Its current implementation of -w option is useless.
(In reply to Andriy Gapon from comment #2) We can consider adding to top as well if such demand is popular When I'm interested in swap in/out activities, I'd like to see each of swap device usages and also disk I/O activities. systat -swap shows both and had spaces in the middle. It was more attractive place to add. I have been adding extra displays to systat over years and familiar than top. I had to access all vm page usage via libprocstat to calculate swap usage for each process. Top uses kinfo_proc. We will need to query libprocstat for every process and I wonder how much it weight it adds to top. I think we can do that only when -w is passed, though.
By the way, https://reviews.freebsd.org/D29337, systat: Handle SIGWINCH to properly window resizing and adjust -swap disk stat based on new size., is a separate review that goes very well with this new feature. Before I dived into "systat -swap", I wondered if I could add swap usage to "systat -pigs" and created https://reviews.freebsd.org/D29303 to reduce memory re-allocations. -pigs also uses kinfo_proc like top and wasn't a good place to add/experiment, though.
The patch needs rework.
Work in progress with https://reviews.freebsd.org/D29754
As noted, this work has moved to https://reviews.freebsd.org/D29754