LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-13-2011, 11:51 PM   #1
dubak
LQ Newbie
 
Registered: Aug 2010
Posts: 6

Rep: Reputation: 0
How to minimize the swap usage


Hi,
we have several clusters used for high performance computing.
The cluster nodes have 48GB memory and on each there is 2GB swap available.
What I would like to avoid is the usage of swap as long as there is enough free memory or empty the swap as soon as there is a free memory.
I thought that this could be achieved by setting the swapiness to 0, but although it helped a bit, it still didn't solve the problem completely.
Even with swapiness set to 0, my memory usage looks like this:

total used free shared buffers cached
Mem: 48264 35534 12730 0 19 99
-/+ buffers/cache: 35416 12848
Swap: 2055 1286 768


So the system is using ~1.2GB of swap even if there's ~12.7GB free memory.

Thanks for your reply
 
Old 05-14-2011, 12:15 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
If there is (still) data in swap with that config, it likely isn't a performance impact.
You could simply swapoff/swapon to "fix" it quickly. Let's see
Code:
uname -a
cat /proc/meminfo
 
Old 05-14-2011, 12:37 AM   #3
dubak
LQ Newbie
 
Registered: Aug 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
If there is (still) data in swap with that config, it likely isn't a performance impact.
You could simply swapoff/swapon to "fix" it quickly. Let's see
Code:
uname -a
cat /proc/meminfo
Hi,
it surely has no performance effect. But this may happen on any of the clusters we have. And the swap usage is being monitored. And of course I want to know when really the swap usage is an issue just because the system is running out of memory.
Like this I'm getting warning messages also for systems, which have plenty of free memory, but still use swap.
Like this one for example:

cl13:~ # uname -a
Linux cl13 2.6.32.36-0.5-default #1 SMP 2011-04-14 10:12:31 +0200 x86_64 x86_64 x86_64 GNU/Linux
cl13:~ # cat /proc/meminfo
MemTotal: 49423080 kB
MemFree: 48383000 kB
Buffers: 19756 kB
Cached: 115848 kB
SwapCached: 16372 kB
Active: 75092 kB
Inactive: 129604 kB
Active(anon): 49724 kB
Inactive(anon): 20048 kB
Active(file): 25368 kB
Inactive(file): 109556 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 2104472 kB
SwapFree: 2004280 kB
Dirty: 16 kB
Writeback: 0 kB
AnonPages: 52900 kB
Mapped: 19740 kB
Shmem: 652 kB
Slab: 59752 kB
SReclaimable: 10424 kB
SUnreclaim: 49328 kB
KernelStack: 3104 kB
PageTables: 8152 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 26816012 kB
Committed_AS: 327308 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 388992 kB
VmallocChunk: 34333293024 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 5504 kB
DirectMap2M: 2082816 kB
DirectMap1G: 48234496 kB
 
Old 05-26-2011, 04:21 AM   #4
dubak
LQ Newbie
 
Registered: Aug 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Rallo no ideas anyone????

Hi, isn't there really anyone who would know how to solve this?
 
Old 05-26-2011, 04:48 AM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

Can you post the output of
Code:
cat /proc/sys/vm/swapiness
Kind regards,

Eric
 
Old 05-26-2011, 05:12 AM   #6
dubak
LQ Newbie
 
Registered: Aug 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Hi, here it is:

hostname:~ # cat /proc/sys/vm/swappiness
0
 
Old 05-26-2011, 07:05 AM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by dubak View Post
it surely has no performance effect. But ... swap usage is being monitored.
Quote:
Originally Posted by dubak View Post
Hi, isn't there really anyone who would know how to solve this?
Solve it by monitoring some more meaningful measure of memory pressure, and ignoring the swap space used.

The rate of physical swap-in I/O can be monitored and that is a significant measure (some low threshold like 100 swap-in I/Os per minute should be ignored and be sure to look at physical, not "soft" swap-in). But with 48GB ram and only 2GB swap, your system will be in pretty bad shape before swap activity could be used as a measure of memory pressure.
 
Old 05-26-2011, 07:06 AM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Is the issue here that you're getting warning messages that you shouldn't be? Or maybe too many false alarms from the warning system?

"The use of swap space" is not, categorically, a sign of alarm. What is significant is a large number of processes that are spending a noticeable percentage of their time in a swap-wait state.

The kernel uses swap space for many reasons, even when RAM availability is not an issue. Therefore, measurement of "the amount of swap space that is in use right now" might not be particularly useful as a metric.

The only two metrics that you really want to be alerted to are: (1) "The ship is actually sinking," or (2) "There is an actual fire that is actually very smoky and very hot." These are metrics that focus upon effects first, and symptoms second. A red spot on your arm is one thing; a red spot that hurts when you touch it is another.

Last edited by sundialsvcs; 05-26-2011 at 07:09 AM.
 
Old 07-27-2011, 09:15 AM   #9
bslade
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Rep: Reputation: 0
This seems to be a typical Linux problem where it grabs unused pages from running programs to use them for buffering/caching disk I/O (even if it causes swapping, even if swappiness=0).

There's a "drop cache" command that might help (misnamed, it's really a clear cache). See http://linux-mm.org/Drop_Caches for details.

Ben
 
Old 07-27-2011, 09:56 AM   #10
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by bslade View Post
This seems to be a typical Linux problem
That is not a problem.

Quote:
There's a "drop cache" command that might help
That does not help.

The actual problem is user misunderstanding of the way Linux uses memory and user misunderstanding of the reported memory use statistics.

"Drop caches" makes memory use look better to a user who is misunderstanding memory use.
 
Old 07-27-2011, 10:25 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by sundialsvcs View Post
The kernel uses swap space for many reasons, even when RAM availability is not an issue.
I'm curious. Which reasons?
 
Old 07-28-2011, 09:42 AM   #12
bslade
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Rep: Reputation: 0
Re: drop caches is misunderstanding of the way Linux uses memory

Respectfully, I disagree. On our dedicated 48gbyte data warehousing system, we leave 10 gbytes of free memory on the system. But Linux still grabs memory from running processes and swaps out about 12g bytes of ram in order to allocate that memory to the free/buffered categories (the memory sloshes back and forth between these categories). Linux is using this memory to buffer terabytes of data read & write activity which don't need to be buffered (or at least don't need to be buffered this much). When the partially swapped out process suddenly starts accessing the swapped out memory, the I/O (via kswapd activity) causes slowdowns.

Having said that, dropping (clearing) cache probably won't help once the memory has been allocated, because it just goes back to the free category and doesn't free up already used swap. Maybe something like swapoff?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Swap Usage Kristijan AIX 3 04-24-2007 02:17 AM
How to minimize ink usage? [HP Printers] eddiep Linux - Hardware 4 03-21-2007 09:58 AM
How much swap usage is too much? sneakyimp Linux - Hardware 3 11-30-2006 04:48 PM
Swap Usage ComputerErik Slackware 3 05-06-2005 02:33 PM
RedHat AS 3.0: Minimize memory(RAM) usage mhathi Linux - Newbie 0 11-02-2004 11:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration