Does a swap usage of 100% indicates swapping despite low memory usage?
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Does a swap usage of 100% indicates swapping despite low memory usage?
Dear all,
I've the following output
Code:
[oracle@camden-db ~]$ date
Fri Dec 7 14:59:34 CET 2018
[oracle@camden-db ~]$ swapon -s
Filename Type Size Used Priority
/dev/dm-0 partition 2097148 2043464 -1
[oracle@camden-db ~]$ free
total used free shared buff/cache available
Mem: 32782584 4856440 238444 7808012 27687700 19788028
Swap: 2097148 2043464 53684
[oracle@camden-db ~]$ date
Fri Dec 7 14:59:44 CET 2018
In either of the above, look for the used space, compared to the total size. If a large percentage of the swap space is used, then one of two actions may be warranted: you may want to either add an additional swap disk to increase the available swap space, or you may want to add additional physical memory to the system.
based on the above can I said that the disk is currently going swapping due to large percentage of swap space being used compare to total swap space
total swap space is 2097148 KB, used swap space is 2043464. nearly 100%, but then should we take note of memory usage as well?
Note total memory is 32782584 KB while usage is only 4856440 KB.
Swap space is 2GB, that's tiny compared to your 32GB RAM. While I am not too knowlegeable about memory management algorithms in Linux, here are the scenarios I imagine:
At some point in time, memory management decided that dirty pages had to be removed from RAM and copied them to swap space. Memory pressure went down since that moment, but as those pages have not been accessed since, they continue to live on swap space.
While only 4-5GB memory is used for applications, the buffer cache occupies some 26GB. Again, there may have been a lot of file I/O in the past, which inflated the buffer cache. If applications don't need more memory, the situation remains as it is.
Or file I/O continues to be strong, in which case it is hard to "compress" the buffer cache.
The output of vmstat and iostat might help clarify what's going on.
which means the CPU is almost 100% idle. If it were waiting for disk I/O, including I/O to and from swap space, you would see a non-zero value in the fourth column, "wa", but that's not the case.
vmstat also shows a sustained but very moderate bo value ("block out", meaning disk output), but no swap activity.
iostat shows idleness most of the time, except for ten or fifteen seconds of I/O on sde and sdf.
In summary, at the time you made this measurement, the system was essentially idle. Does this match your observations? I believe the measurements confirm my theory that your swap space use indicates that memory was under pressure some time ago, and the buffer cache size indicates that there has been file I/O, but currently the system looks rather stable.
If, all of a sudden, you started large memory users, you would first see the buffer cache shrink. If, at the same time, you also cause heavy file I/O, you would see a "fight" for RAM between the processes and buffer cache.
yes the server is idle most of the time. Just because the swap space does not met the requirements doesn't mean swapping will occur most of the time. If the server is idle most of the time even a low swap space will only mean a short instance of swapping.
vmstat also shows a sustained but very moderate bo value ("block out", meaning disk output), but no swap activity.
is there any figure for moderate bo value?
iostat shows idleness most of the time, except for ten or fifteen seconds of I/O on sde and sdf.
are you referring to these time instances:
“moderate” is my subjective judgment. Disks can transfer much more than 80 blocks per second (I think a block is 1K).
I suggested iostat to see if there is any pressure to keep a large buffer cache, i.e. file I/O. Indeed I meant the peak you mention, perhaps the kernel is sync’ing a few buffer cache blocks, or the application initiated some I/O at this point.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.