Table of Contents

Swap on Linux Performance (free, sar)



Swap on /proc/meminfo

root@ubuntu20:~# cat /proc/meminfo |grep -i swap
SwapCached:         5488 kB
SwapTotal:       2097148 kB
SwapFree:        1969404 kB
root@ubuntu20:~#


Linux Command for Swap

free -m

root@ubuntu20:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            981         186         147          64         646         550
Swap:          2047         124        1923
root@ubuntu20:~#


sar -W for Swap In/Out

root@ubuntu20:~# sar -W 1
Linux 5.4.0-65-generic (ubuntu20)       03/04/2021      _x86_64_        (2 CPU)

08:59:42 AM  pswpin/s pswpout/s
08:59:43 AM      0.00      0.00
08:59:44 AM      0.00      0.00
08:59:45 AM      0.00      0.00
08:59:46 AM      0.00      0.00
08:59:47 AM      0.00      0.00
08:59:48 AM      0.00      0.00
08:59:49 AM      0.00      0.00
08:59:50 AM      0.00      0.00
08:59:51 AM      0.00      0.00
^C

Average:         0.00      0.00
root@ubuntu20:~#


How to check the process using swap

[root@centos7 ~]# grep VmSwap /proc/*/status | sort -k 2 -nr |head
/proc/664/status:VmSwap:           12468 kB
/proc/720/status:VmSwap:           12424 kB
/proc/947/status:VmSwap:           10140 kB
/proc/663/status:VmSwap:            8252 kB
/proc/8483/status:VmSwap:           7848 kB
/proc/8484/status:VmSwap:           7784 kB
/proc/19894/status:VmSwap:          5372 kB
/proc/17595/status:VmSwap:          5232 kB
/proc/21585/status:VmSwap:          5008 kB
/proc/2984/status:VmSwap:           4344 kB
[root@centos7 ~]#




Related Pages