1
0
mirror of https://github.com/systemd/systemd synced 2026-03-17 18:44:46 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Mike Yuan
5119063196 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.
2026-01-15 13:56:34 +01:00
Michal Sekletar
bcbf80c43d core: only activate transaction that contain useful jobs
If no real jobs were added to the transaction, do not activate it.
The JOB_NOP anchor does not perform any useful work and activating
such transaction only wastes resources.

Fixes #9751
2026-01-15 12:53:50 +01:00
4 changed files with 9 additions and 3 deletions

View File

@ -2278,6 +2278,11 @@ int manager_propagate_reload(Manager *m, Unit *unit, JobMode mode, sd_bus_error
tr->anchor_job,
mode == JOB_IGNORE_DEPENDENCIES ? TRANSACTION_IGNORE_ORDER : 0);
/* Only activate the transaction if it contains jobs other than NOP anchor.
* Short-circuiting here avoids unnecessary processing, such as emitting D-Bus signals. */
if (hashmap_size(tr->jobs) <= 1)
return 0;
r = transaction_activate(tr, m, mode, NULL, e);
if (r < 0)
return r;

View File

@ -850,7 +850,7 @@ static int run(int argc, char *argv[]) {
return r;
/* A delicious drop of snake oil */
(void) mlockall(MCL_FUTURE);
(void) mlockall(MCL_CURRENT|MCL_FUTURE|MCL_ONFAULT);
cryptsetup_enable_logging(NULL);

View File

@ -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 */

View File

@ -402,7 +402,8 @@ int main(int argc, char *argv[]) {
init_watchdog();
/* Lock us into memory */
(void) mlockall(MCL_CURRENT|MCL_FUTURE);
(void) mlockall(MCL_FUTURE|MCL_ONFAULT);
(void) mlockall(MCL_CURRENT);
/* We need to make mounts private so that we can MS_MOVE in unmount_all(). Kernel does not allow
* MS_MOVE when parent mountpoints have shared propagation. */