LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-26-2015, 09:18 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post Change Swap and Memory Priority.


Hello.
How can I change Swap Priority and tell Linux to use Swap more than RAM?

Thank you.
 
Old 04-26-2015, 09:31 AM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Interesting question, why would you want to do that? I have never seen a parameter which can provide precedence to swap over RAM. You can set priorities between different swap devices / files but prioritizing swap over RAM, never heard of it.

It is not possible as far as I am aware. Even if somehow it is possible it will definitely a blow to performance, you can't compare RAM performance with swap.
 
Old 04-26-2015, 10:00 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,122

Rep: Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337
You can set swappiness=100 which may suit your purposes.

http://web.archive.org/web/201403280...vm-swappiness/
 
Old 04-26-2015, 10:04 AM   #4
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,937

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
You can change the "swappiness" parameter to swap more aggressively.

Your RAM would not necessarily show more free storage - but if RAM were needed
there would be no delay to swap out memory as it would have already been swapped out.

Doing this is usually a sub-optimal strategy as Linux tries to use as much unused memory as possible for extra buffer space.

I would leave it alone.
 
Old 04-26-2015, 10:13 AM   #5
Rezney
LQ Newbie
 
Registered: Apr 2015
Posts: 16

Rep: Reputation: 1
No idea about this but if you would like to affect swapping on your system you can play with vm.swappiness but you probably already know this.

Cheers
 
Old 04-26-2015, 10:39 AM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by michaelk View Post
You can set swappiness=100 which may suit your purposes.

http://web.archive.org/web/201403280...vm-swappiness/
I am not sure if that will serve what OP is looking for. By default if swappiness is set to low it will make the kernel to drop cached pages for freeing up the memory instead of swapping. If swappiness is set to higher value instead of dropping cached pages kernel will use swap. Setting swap to 100 will not give precedence to swap over RAM.
 
Old 04-26-2015, 10:55 AM   #7
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Just did a small test with swappiness set to 100 (rebooted the VM after putting it in sysctl) and the output does not shows system giving precedence to swap over RAM.

Command for testing load was taken from stackexchange (did little change), here is the link: http://unix.stackexchange.com/questi...he-free-memory


Code:
[root@rhel6-test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1500        327       1173          0         13        153
-/+ buffers/cache:        159       1340
Swap:         3007          0       3007
[root@rhel6-test ~]# cat /proc/sys/vm/swappiness
100
[root@rhel6-test ~]# cat /etc/sysctl.conf | grep swappiness
vm.swappiness = 100
[root@rhel6-test ~]# stress --vm-bytes $(awk '/MemFree/{printf "d\n", $2 * 1.2;}' < /proc/meminfo)k --vm-keep -m 1 &
[1] 2477
[root@rhel6-test ~]# stress: info: [2477] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd

[root@rhel6-test ~]# free -m

             total       used       free     shared    buffers     cached
Mem:          1500       1450         49          0          0         21
-/+ buffers/cache:       1429         71
Swap:         3007        169       2838
[root@rhel6-test ~]#
[root@rhel6-test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1500       1428         72          0          0         14
-/+ buffers/cache:       1413         86
Swap:         3007        388       2619
[root@rhel6-test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1500       1427         72          0          0         13
-/+ buffers/cache:       1414         86
Swap:         3007        482       2525
[root@rhel6-test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1500       1444         56          0          0         12
-/+ buffers/cache:       1431         68
Swap:         3007        581       2426
[root@rhel6-test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1500       1435         65          0          0          9
-/+ buffers/cache:       1425         74
Swap:         3007        696       2311
[root@rhel6-test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1500       1450         49          0          0          8
-/+ buffers/cache:       1442         58
Swap:         3007        884       2123
[root@rhel6-test ~]#
 
1 members found this post helpful.
Old 04-26-2015, 12:38 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,122

Rep: Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337Reputation: 5337
Thanks for posting the data.
 
Old 04-26-2015, 12:42 PM   #9
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
You're welcome!
 
Old 04-26-2015, 04:38 PM   #10
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 997

Rep: Reputation: 130Reputation: 130
Hi
Maybe using cgroups as mentioned here?
 
Old 04-26-2015, 11:55 PM   #11
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
I guess that in the new version Swap file, Speed between Swap partition and Swap file solved and both are same. If we use Some HDD like SSD can Swap speed same RAM speed?
 
Old 04-27-2015, 12:42 AM   #12
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
No, RAM will still be significantly faster than swap on SSD. You might want to have a look at this article where they had similar discussion: http://superuser.com/questions/61786...d-space-as-ram

It is not only about the speed but your SSD will wear out faster due to continuous read / write / erase / re-write.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Live DVD runs out of memory - using swap - free memory doesn't help at upgrade .... LiNuXkOlOnIe Linux - Distributions 3 06-09-2013 09:35 PM
[SOLVED] Swap files priority values vikas027 Linux - Server 2 05-14-2010 11:24 PM
Swap Memory / Virtual Memory in Fedora Core 6 Jojo_CFT Linux - Newbie 2 10-15-2007 04:23 AM
Multiple SWAP partitions: what is priority number?? coolblue Linux - Newbie 1 05-01-2007 02:26 PM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 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