tree-wide: lock in all memory pages when mlockall() is utilized, and on demand
When employing MCL_FUTURE we don't actually want it to impose immediate population of malloc()-ed pages. Hence let's set MCL_ONFAULT everywhere. Additionally, specify MCL_CURRENT to ensure future memory allocations on already mapped pages are covered too. (Addresses https://github.com/systemd/systemd/pull/40319#discussion_r2693726196) Note that in shutdown the mlockall() is done to avoid keeping swap space busy, hence a dedicated call w/ MCL_CURRENT and w/o MCL_ONFAULT is made.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
bcbf80c43d
commit
5119063196
@@ -2582,7 +2582,7 @@ static int verb_attach(int argc, char *argv[], void *userdata) {
|
||||
volume, source, strempty(arg_type), strempty(arg_cipher));
|
||||
|
||||
/* A delicious drop of snake oil */
|
||||
(void) mlockall(MCL_FUTURE);
|
||||
(void) mlockall(MCL_CURRENT|MCL_FUTURE|MCL_ONFAULT);
|
||||
|
||||
if (key_file && arg_keyfile_erase)
|
||||
destroy_key_file = key_file; /* let's get this baby erased when we leave */
|
||||
|
||||
Reference in New Issue
Block a user