summaryrefslogtreecommitdiffstats
path: root/src/core/execute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/execute.c')
-rw-r--r--src/core/execute.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 3b327ac88d..1802ae05b3 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -5193,6 +5193,16 @@ static int exec_child(
return r;
}
+ if (context->memory_ksm >= 0)
+ if (prctl(PR_SET_MEMORY_MERGE, context->memory_ksm) < 0) {
+ if (ERRNO_IS_NOT_SUPPORTED(errno))
+ log_unit_debug_errno(unit, errno, "KSM support not available, ignoring.");
+ else {
+ *exit_status = EXIT_KSM;
+ return log_unit_error_errno(unit, errno, "Failed to set KSM: %m");
+ }
+ }
+
/* Drop groups as early as possible.
* This needs to be done after PrivateDevices=y setup as device nodes should be owned by the host's root.
* For non-root in a userns, devices will be owned by the user/group before the group change, and nobody. */
@@ -5773,6 +5783,7 @@ void exec_context_init(ExecContext *c) {
c->tty_cols = UINT_MAX;
numa_policy_reset(&c->numa_policy);
c->private_mounts = -1;
+ c->memory_ksm = -1;
}
void exec_context_done(ExecContext *c) {