I'd like to know if it's possible to bring pages from a particular process into main memory, or to set parameters for a given process, or class of process so that it will not be swapped out.

link|improve this question

48% accept rate
feedback

1 Answer

If what you're trying to do is improve the performance of a process, I'd recommend nice.

You can also influence the kernel's tendency to swap in general by setting its swappiness.

You might also find this question and its answers helpful.

link|improve this answer
What I'm looking to do is avoid the lag that occurs when a process is accessed for the first time since real memory was full. EG I have a browser tab (in chrome) displaying some static page; I open a gazillion more; main memory fills up and my original tab gets swapped out; I close the gazillion more; I do some stuff; I go to look at the original one again: it has to load from swap. What i'd like to do is just explicitly unswap the pages containing that original tab, ie the process running it (this is in Chrome). – intuited May 22 '10 at 21:15
mlockall() and madvise() seem like they would be applicable if they worked on a per-process basis rather than a per-address basis. I guess I could connect to the process with gdb and run mlockall(). – intuited May 22 '10 at 21:21
It also seems like setting the swappiness doesn't affect how quickly pages are swapped back in? I've changed my swappiness to 0 and still 1/6 of memory contains cache, and about 3% is free. – intuited May 22 '10 at 21:27
@intuited: So you want to look at the original page and it's in swap so you want to bring it out of swap. Well, looking at it will do that. You shouldn't need to do something explicitly that the system is going to do for you (at the same time you'd do it yourself, I might add). Your proposed unswap would have the same kind of lag at the same moment in time that the lag occurs already. Really, Linux does a good job of all this by itself. More RAM is one sure answer. – Dennis Williamson May 22 '10 at 22:38
1  
@Dennis Williamson: The point would be to do it before the system does it. Normally the system will wait until, as I understand it, the pages are needed before bringing them out of swap. I'd like to say "okay, I just closed my huge Audacity project, I have a ton of free memory.. I'm going to bring a bunch of stuff that I'm going to use soon into main memory". While the disk is chugging away I can be working on stuff that's already in memory -- ie stuff that wasn't swapped out while I was working in Audacity. – intuited May 23 '10 at 2:34
show 2 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.