Prevent the operating system from swapping out the pages of a mom process. Inspired by a patch from NCSA, but fixed to make sure that children spawned by the mom do not continue to have all their pages locked too. Also quite simplified. --- pbs-2.3.12-pw/src/resmom/mom_main.c | 4 ++++ pbs-2.3.12-pw/src/resmom/start_exec.c | 6 ++++++ 2 files changed, 10 insertions(+) diff -puN src/resmom/mom_main.c~mom-mlockall src/resmom/mom_main.c --- pbs-2.3.12/src/resmom/mom_main.c~mom-mlockall 2004-04-17 11:10:43.000000000 -0400 +++ pbs-2.3.12-pw/src/resmom/mom_main.c 2004-04-17 11:10:43.000000000 -0400 @@ -2193,6 +2193,10 @@ main(argc, argv) add_conn(rppfd, Primary, (pbs_net_t)0, 0, rpp_request); add_conn(privfd, Primary, (pbs_net_t)0, 0, rpp_request); + /* keep ourselves in memory to avoid getting hurt by the OOM killer */ + if (mlockall(MCL_CURRENT | MCL_FUTURE)) + log_err(errno, id, "mlockall"); + /* initialize machine dependent polling routines */ if ((c = mom_open_poll()) != PBSE_NONE) { log_err(c, msg_daemonname, "pre_poll failed"); diff -puN src/resmom/start_exec.c~mom-mlockall src/resmom/start_exec.c --- pbs-2.3.12/src/resmom/start_exec.c~mom-mlockall 2004-04-17 11:10:43.000000000 -0400 +++ pbs-2.3.12-pw/src/resmom/start_exec.c 2004-04-17 11:10:43.000000000 -0400 @@ -97,6 +97,7 @@ #include #include #include +#include #include #if IBM_SP2==2 /* IBM SP with PSSP 3.1 */ #include @@ -2076,6 +2077,11 @@ pid_t fork_me(conn) (void)mom_close_poll(); net_close(conn); /* close all but for the current */ + + /* release mlock; it seems to be inherited even though the + * man page claims otherwise */ + (void) munlockall(); + } else if (pid < 0) log_err(errno, "fork_me", "fork failed"); _