return 0;
}
+static int set_memory_thp(MemoryTHP thp) {
+ int r;
+
+ switch (thp) {
+
+ case MEMORY_THP_INHERIT:
+ return 0;
+
+ case MEMORY_THP_DISABLE:
+ r = RET_NERRNO(prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0));
+ break;
+
+ case MEMORY_THP_MADVISE:
+ r = RET_NERRNO(prctl(PR_SET_THP_DISABLE, 1, PR_THP_DISABLE_EXCEPT_ADVISED, 0, 0));
+ break;
+
+ case MEMORY_THP_SYSTEM:
+ r = RET_NERRNO(prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0));
+ break;
+
+ default:
+ assert_not_reached();
+ }
+
+ return r == -EINVAL ? -EOPNOTSUPP : r;
+}
+
static bool exec_context_shall_confirm_spawn(const ExecContext *context) {
assert(context);
return 1;
}
-static int set_memory_thp(MemoryTHP thp) {
- switch (thp) {
-
- case MEMORY_THP_INHERIT:
- return 0;
-
- case MEMORY_THP_DISABLE:
- if (prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0) < 0)
- return errno == EINVAL ? -EOPNOTSUPP : -errno;
- return 0;
-
- case MEMORY_THP_MADVISE:
- if (prctl(PR_SET_THP_DISABLE, 1, PR_THP_DISABLE_EXCEPT_ADVISED, 0, 0) < 0)
- return errno == EINVAL ? -EOPNOTSUPP : -errno;
- return 0;
-
- case MEMORY_THP_SYSTEM:
- if (prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0) < 0)
- return errno == EINVAL ? -EOPNOTSUPP : -errno;
- return 0;
-
- default:
- assert_not_reached();
- }
-}
-
static int send_handoff_timestamp(
const ExecContext *c,
ExecParameters *p,
r = set_memory_thp(context->memory_thp);
if (r == -EOPNOTSUPP)
- log_debug_errno(r, "Setting MemoryTHP=%s is not supported, ignoring: %m",
+ log_debug_errno(r, "Setting MemoryTHP=%s is not supported, ignoring.",
memory_thp_to_string(context->memory_thp));
else if (r < 0) {
*exit_status = EXIT_MEMORY_THP;