When mongod is under intense memory pressure on systems that do not have swap space, the operating system pages out the only pages it can when mongod makes a request for more privately mapped memory: program text segment (code) pages. It pages them out because they are available for retrieval from stable storage. Unfortunately, this means that under heavy load mongod spends an immense amount of time paging code in from disk, which can make the system become unresponsive when it would be better for it to crash.
We should offer the option to pin code segments in memory via the mlock(2) syscall. The stack tracing machinery already knows how to find the base address of every code segment loaded into the process, and could be extended with modest effort to also report the size of those segments. This would in turn allow us to invoke `mlock` to pin those pages in memory.