Re: Can on-demand loading of user-space executables be disabled ?

From: P.O. Gaillard
Date: Tue Feb 07 2006 - 11:44:08 EST


Thank you everybody. Somebody gave me another solution that applies when you can recompile the executable and are willing to change the source code : call mlockall to lock the process' memory space in memory.

It might be useful to quote the man page :
mlockall disables paging for all pages mapped into the address space of
the calling process. This includes the pages of the code, data and
stack segment, as well as shared libraries, user space kernel data,
shared memory and memory mapped files. All mapped pages are guaranteed
to be resident in RAM when the mlockall system call returns success-
fully and they are guaranteed to stay in RAM until the pages are
unlocked again by munlock or munlockall or until the process terminates
or starts another program with exec. Child processes do not inherit
page locks across a fork.

As you see, calling mlockall forces all the executable code to be loaded into RAM and stay there. This also protects the program from getting swapped out. And you can keep your swap for the other programs.

thanks again,

P.O. Gaillard

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/