views:

240

answers:

1

For an dedicated test I have to disable "demand paging" for exactly one of my userspace programs

http://en.wikipedia.org/wiki/Demand_paging

Any idea how I could do this ? (embedded linux appliance; 2.6 kernel)

+2  A: 

If you have the ability to modify the application, you could use the mlock() / mlockall() system calls to ensure that your memory doesn't get paged out:

#include <sys/mman.h>

mlockall(MCL_FUTURE);

This will prevent all memory currently allocated, and any future memory that is allocated to this process from being swapped out. You can use the mlock() system call to get finer control over which parts of memory are locked.

Chris AtLee
I have a problem with initialisation (C++, do_global_ctors_aux) to debug this I want to make sure that from the very beginning everything is - and remains in memory- so maybe mlockall is too late for this
In that case, you can disable your swap device altogether :)I'm not aware of a way to do the equivalent of mlockall to another process. You could try and hack the executable to insert a call to mlockall as the very first thing to do when the application starts.
Chris AtLee