3

I started 4 processes doing heavy computations. The machine has 4 full cores, and each process is single-threaded, so they don't compete for CPU. However I realized that they require more memory than physically exist in this system (16GB). Now their allocated address space combined is about 20GB, so each of them has part of their address space swapped out.

So I decided to suspend one of those processes and I wanted to put its memory pages to swap, so that physical memory would serve only the three other processes. I assume that this will eventually happen while the three alive processes will try to access swapped-out pages. But I'd like to force it so that the computations wont have to wait for IO.

My questions:

  1. Is it possible to force a suspended process' memory go to swap? (so that there wont be IO when alive processes will do new allocations)

  2. Is it possible to force an alive process' memory to come back to RAM?

This is Debian SID.

liori
  • 737
  • 3
  • 14

1 Answers1

2

You could suspend one of the processes for instance attaching a debugger to the process.

 gdb process_executable process_pid

and let the linux scheduler do the rest. When the first three processes terminate you can just detach the debugger to resume the fourth process.

You can achieve the same purpose just by issuing SIGSTOP to the process:

 kill -stop process_pid

And

 kill -cont process_pid

To resume it when the resources become available. In future you might consider using some job scheduler such as torque to schedule the processes according to their resource requirements semi automatically.

Edit: I did not pay attention to the original question and missed that suspending the process is not an issue. The issue is that simply moving pages to swap and back takes a long time.

Dmitri Chubarov
  • 2,296
  • 1
  • 15
  • 28
  • 1
    I know how to suspend a task, and this is not what this question is about. What I'd like to know is how to manage where memory of suspended or active process are placed by OS. – liori Apr 21 '12 at 16:06
  • Looks like the general opinion holds it is better left to Linux to decide http://serverfault.com/questions/110436/linux-how-to-explicitly-unswap-everything-possible – Dmitri Chubarov Apr 21 '12 at 16:12
  • 1
    In general situation I agree. In this specific situation this slows down my computations significantly for some time… – liori Apr 21 '12 at 16:19