From a8500a0ddc31232e6b21ce5370be0fa1b49c1954 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 22 Jul 2022 12:17:45 +0200 Subject: [system-tweaks] Disable automatic memory compaction, do at session start --- .../etc/systemd/system/general-system-tweaks.service | 7 +++++++ .../general-system-tweaks.service | 1 + .../pam/hooks/auth-final-exec.d/99-compact-memory.sh | 9 +++++++++ .../opt/openslx/scripts/systemd-general_system_tweaks | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 core/modules/system-tweaks/data/etc/systemd/system/general-system-tweaks.service create mode 120000 core/modules/system-tweaks/data/etc/systemd/system/multi-user.target.wants/general-system-tweaks.service create mode 100755 core/modules/system-tweaks/data/opt/openslx/pam/hooks/auth-final-exec.d/99-compact-memory.sh create mode 100755 core/modules/system-tweaks/data/opt/openslx/scripts/systemd-general_system_tweaks (limited to 'core/modules/system-tweaks') diff --git a/core/modules/system-tweaks/data/etc/systemd/system/general-system-tweaks.service b/core/modules/system-tweaks/data/etc/systemd/system/general-system-tweaks.service new file mode 100644 index 00000000..8bf67972 --- /dev/null +++ b/core/modules/system-tweaks/data/etc/systemd/system/general-system-tweaks.service @@ -0,0 +1,7 @@ +[Unit] +Description=Apply general system tweaks + +[Service] +ExecStart=/opt/openslx/scripts/systemd-general_system_tweaks +Type=oneshot +RemainAfterExit=true diff --git a/core/modules/system-tweaks/data/etc/systemd/system/multi-user.target.wants/general-system-tweaks.service b/core/modules/system-tweaks/data/etc/systemd/system/multi-user.target.wants/general-system-tweaks.service new file mode 120000 index 00000000..11e1b73f --- /dev/null +++ b/core/modules/system-tweaks/data/etc/systemd/system/multi-user.target.wants/general-system-tweaks.service @@ -0,0 +1 @@ +../general-system-tweaks.service \ No newline at end of file diff --git a/core/modules/system-tweaks/data/opt/openslx/pam/hooks/auth-final-exec.d/99-compact-memory.sh b/core/modules/system-tweaks/data/opt/openslx/pam/hooks/auth-final-exec.d/99-compact-memory.sh new file mode 100755 index 00000000..6d35a3cc --- /dev/null +++ b/core/modules/system-tweaks/data/opt/openslx/pam/hooks/auth-final-exec.d/99-compact-memory.sh @@ -0,0 +1,9 @@ +#!/bin/ash + +# Compact memory now once at start of graphical session, +# So VM will have as much contiguous blocks available +# as possible. +if [ "$PAM_TTY" = ":0" ]; then + echo 1 > /proc/sys/vm/compact_memory +fi +exit 0 diff --git a/core/modules/system-tweaks/data/opt/openslx/scripts/systemd-general_system_tweaks b/core/modules/system-tweaks/data/opt/openslx/scripts/systemd-general_system_tweaks new file mode 100755 index 00000000..389a3ca2 --- /dev/null +++ b/core/modules/system-tweaks/data/opt/openslx/scripts/systemd-general_system_tweaks @@ -0,0 +1,19 @@ +#!/bin/ash + +# General stuff + +# Breaks performance with certain workloads, so disable. +# See https://unix.stackexchange.com/a/185172 for details and further references +echo never > /sys/kernel/mm/transparent_hugepage/defrag +echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag +# New player in town doing pretty much the same, tame it +echo 1 > /proc/sys/vm/compaction_proactiveness # default 20 + +# run-parts-like stuff +DIR="$0.d" +if [ -d "$DIR" ]; then + for file in "$DIR"/*; do + [ -x "$file" ] && "$file" + done +fi +exit 0 -- cgit v1.2.3-55-g7522