Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Swap memory is not getting used, swap broken?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon May 24, 2004 7:32 pm    Post subject: Swap memory is not getting used, swap broken? Reply with quote

I came across a very strange problem today. For a long time I have wondered my Gentoo system never seems to be using the swap memory. I read in several other threads that Gentoo hardly ever uses swap, so I figured that everything was fine and I did not have to worry. Today I rememberd again that I had never seen my swap getting used, so I decided to investigate. After poking around for a while, I finally discovered that my vm.swappiness variable was set to 0

Code:
# cat /proc/sys/vm/swappiness
0


So I wanted to set a new value (60 because it should be the default).

Code:
# echo 60 > /proc/sys/vm/swappiness
-bash: /proc/sys/vm/swappiness: Operation not permitted


I also tried this command:

Code:
# sysctl -w vm.swappiness=60
error: unknown error 1 setting key 'vm.swappiness'


Something is obviously very wrong, but I don't know what. Any help or suggestions would be greatly appreciated.

I tried searching the forums and found surprisingly few topics covering anything about "vm.swappiness" problems. I seem to be the only one with a screwed up swap. :?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
Little Nemo
l33t
l33t


Joined: 29 Mar 2004
Posts: 623
Location: Berlin, Germany

PostPosted: Mon May 24, 2004 7:40 pm    Post subject: Reply with quote

swappiness on my Gentoo box is 29. Where does this setting come from? Is it a Gentoo choice?

Anyway, I had no problem changing this setting through either method.
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 7:42 pm    Post subject: Reply with quote

Not problem changing it here either (was 60). What's your kernel?
(I'm running mm-sources 2.6.6-mm1)
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon May 24, 2004 7:51 pm    Post subject: Reply with quote

Currently I am running the 2.6.3-gentoo-r1 kernel. This problem is really frustrating. No one else has it! :? :cry:
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 8:15 pm    Post subject: Reply with quote

Well, the thing is, I don't really see why you would want to use your swap in the first place.

If you really want to change the swappiness, try a -mm kernel maybe, or maybe a -aa kernel (he's the one who did the most work on the VM area, AFAIK, so it might be a good idea to give it a try).
Back to top
View user's profile Send private message
darksbane
n00b
n00b


Joined: 15 Apr 2004
Posts: 28
Location: Fredonia, NY

PostPosted: Mon May 24, 2004 8:23 pm    Post subject: Re: Swap memory is not getting used, swap broken? Reply with quote

tommy_fila wrote:

Code:
# echo 60 > /proc/sys/vm/swappiness
-bash: /proc/sys/vm/swappiness: Operation not permitted


I also tried this command:

Code:
# sysctl -w vm.swappiness=60
error: unknown error 1 setting key 'vm.swappiness'

This may be a silly question, but you're root when you try this right?

Also as someone said in an earlier post, not using swap is a good thing in most cases. If you can keep everything in memory then your computer will be a happy camper.

What kernel are you using?
_________________
:wq
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 8:32 pm    Post subject: Reply with quote

BTW, if you want to check that you _can_ swap, try something stupid like starting a couple vi's on absurdly large files (gentoo iso images for instance...) and watch your mem go down, swap kicking in at some point, then god knows what once you've maxed everything out :twisted:
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon May 24, 2004 8:44 pm    Post subject: Reply with quote

I don't think any of you are quite understanding the problem. It's not a matter of whether I want to use swap or not, it's a matter of swap simply not working. A swappiness setting of 0 means that swap is not getting used at all. No matter what application I run, swap is not getting used. I tried changing this value, but it doesn't work. The problem is I don't understand why it will not let me change the swappiness value.

@darksbane

Yes I am using root. Check above for the kernel I'm using.


Thank you all for your help! Some input is better than none at all!


I was thinking perhaps it could be that I have the wrong permissions set on /proc or something along those lines. Anyone?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 8:56 pm    Post subject: Reply with quote

swappiness == 0 does not mean no swap. It just means the kernel will very reluctantly use swap.
Code:
saidin root # cat /proc/sys/vm/swappiness
0
saidin root # free
             total       used       free     shared    buffers     cached
Mem:       1028696    1023344       5352          0        168      49532
-/+ buffers/cache:     973644      55052
Swap:      1999832     136324    1863508


EDIT: There's a good article about swappiness over at kerneltrap.org (last week I think).
(EDIT #2: Running 2.6.5-aa5 right now)
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon May 24, 2004 9:00 pm    Post subject: Reply with quote

mseigneurin wrote:
swappiness == 0 does not mean no swap. It just means the kernel will very reluctantly use swap.


I didn't know that. Anyways, my swap doesn't work at all. I can't change the swappiness settings or ever actually use the swap. How did you get your system to use swap even when your swappiness was at 0?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 9:05 pm    Post subject: Reply with quote

Simple: in KDE right now, three konsoles:
- one running top to see what's going on
- one doing vi KNOPPIX-something.iso (700M RAM eaten up right there)
- one doing vi on another large .iso so that total RAM need > physical RAM
(and < total RAM+swap)

System does slow down a bit for a while when the two vi's are running, but settle down after that.
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon May 24, 2004 9:20 pm    Post subject: Reply with quote

Success! Opening the stage3 tarball did the job and got my kernel to use some swap memory! Thank you very much for that tip!

What I still don't understand, and it still bothers me is why I can't change the swappinss variable. I would like to be able to experiment around with my swap and see what works best for my system. Any idea what could be causing that. My swap does indeed work, but I can't fiddle around with it. :(

Thanks for hanging in there with me! :wink:
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 9:35 pm    Post subject: Reply with quote

I really don't know why you can't change your swappiness.
I'd suggest trying out other kernel varieties if you're interested in VM tuning.
(Or maybe try a fresh compile of your kernel - maybe something wasn't exactly
right when you built yours? - not very likely)

You wouldn't have errors in dmesg when you cat to swappiness, would you?
Have you tried changing other sysctl settings (like kernel/shmmax for instance) ?
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon May 24, 2004 10:07 pm    Post subject: Reply with quote

BTW, the kerneltrap article is here: http://kerneltrap.org/node/view/3000
There's also a real good interview with Andrea Arcangeli on the front page right now.
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Thu Jun 03, 2004 1:10 pm    Post subject: Reply with quote

I solved the problem by switching kernels. It must have been the kernel that was either configured imporperly or the kernel itself that did not support changing the swappiness variable. Thank you all for your help! :D
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon Jun 07, 2004 1:20 pm    Post subject: Reply with quote

Now I have a new problem with my swap. Whenever I change the /proc/sys/vm/swappiness variable it doesn't save the changes. After a reboot, it always resets back to 60 and not to what I had it set at. Is this intentional or am I making a mistake setting the swappiness?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
infirit
l33t
l33t


Joined: 11 Jan 2003
Posts: 778
Location: Hoofddorp / The Netherlands

PostPosted: Mon Jun 07, 2004 1:35 pm    Post subject: Reply with quote

Put the line in localstart!
Code:
echo "command" >> /etc/conf.d/localstart
do not forget the doubble quotes
_________________
EASY TO INSTALL = Difficult to install, but instruction manual has pictures.
Join the adopt an unanswered post initiative today
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon Jun 07, 2004 2:10 pm    Post subject: Reply with quote

I guess I could do that, but I'm more interested in what's causing the problem than a solution. There are many ways to fix the problem. I'm just wondering if this is supposed to happen. It would seem more logic for the kernel to save your changes.
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
infirit
l33t
l33t


Joined: 11 Jan 2003
Posts: 778
Location: Hoofddorp / The Netherlands

PostPosted: Tue Jun 08, 2004 10:19 am    Post subject: Reply with quote

Dont know if you can use sysctl for this (im at work now and connot test it) but you can try.
Code:
sys.vm.swappiness=60
in /etc/sysctl

EDIT: Unless there is a kernel option when you compile the kernel to set swappiness i think the kernel will forget the setting on every shutdown. Please someone correct me if im wrong.
_________________
EASY TO INSTALL = Difficult to install, but instruction manual has pictures.
Join the adopt an unanswered post initiative today
Back to top
View user's profile Send private message
Little Nemo
l33t
l33t


Joined: 29 Mar 2004
Posts: 623
Location: Berlin, Germany

PostPosted: Tue Jun 08, 2004 11:40 am    Post subject: Reply with quote

infirit wrote:
Unless there is a kernel option when you compile the kernel to set swappiness i think the kernel will forget the setting on every shutdown.


If that's correct, where does the "Gentoo default" of 60 come from? And why is my swappiness always 29? I haven't found anything in the Gentoo scripts that would set this.
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Wed Jun 09, 2004 7:20 pm    Post subject: Reply with quote

Little Nemo wrote:
If that's correct, where does the "Gentoo default" of 60 come from? And why is my swappiness always 29? I haven't found anything in the Gentoo scripts that would set this.


I think the values are determined by the kernel developers. They decide what level of swappiness they want. My kernel puts it at 60, your kernel might put it at 29. This is just my theory. I have a bad feeling it might be wrong because it seems kind of strange that kernel developers would set the swappiness at 29 - why not make it 30.

It would be nice if we could get a kernel developer in here to clear up the issue.
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Fri Jun 18, 2004 3:25 pm    Post subject: Reply with quote

For anyone who is interested, the answers to all the above questions can be found here:

https://forums.gentoo.org/viewtopic.php?t=175419
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
bk0
Apprentice
Apprentice


Joined: 04 Jan 2004
Posts: 266

PostPosted: Sat Jun 19, 2004 12:22 am    Post subject: Reply with quote

tommy_fila wrote:
Now I have a new problem with my swap. Whenever I change the /proc/sys/vm/swappiness variable it doesn't save the changes. After a reboot, it always resets back to 60 and not to what I had it set at. Is this intentional or am I making a mistake setting the swappiness?


gentoo-dev-sources (and probably other gentoo 2.6 kernels) contains the Con Kolivas autoregulated swappiness patch. This means that the kernel automatically adjusts the /proc/sys/vm/swappiness value as needed during runtime, so any changes you make will be clobbered next time it updates. A good explanation of this patch and how it works is here on KernelTrap.

I repeat: With gentoo-dev-sources it is neither necessary nor possible to permanently adjust the swappiness value. It's taken care of automatically, no need to worry. :)
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Sat Jun 19, 2004 3:37 pm    Post subject: Reply with quote

Great! Finally the one and only correct answer! :D Thanks
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum