Friday, April 15, 2011

How can I disable "demand paging" for one of my userspace programs ?

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)

From stackoverflow
  • 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 : 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.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.