From 5967a01fad02ed330c711a5e281a2d243c515a7e Mon Sep 17 00:00:00 2001 From: Fabian Wiesel Date: Thu, 18 Jul 2024 13:25:05 +0200 Subject: [PATCH] [orabos] Tune vm.watermark_scale_factor The value is scaling with the amount of RAM in the system, but we take a way a large chunk for huge-pages. --- .../99ensure-hugepages/ensure-hugepages.sh | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/features/orabos/file.include/usr/lib/dracut/modules.d/99ensure-hugepages/ensure-hugepages.sh b/features/orabos/file.include/usr/lib/dracut/modules.d/99ensure-hugepages/ensure-hugepages.sh index 9053ece0c..0432566cd 100755 --- a/features/orabos/file.include/usr/lib/dracut/modules.d/99ensure-hugepages/ensure-hugepages.sh +++ b/features/orabos/file.include/usr/lib/dracut/modules.d/99ensure-hugepages/ensure-hugepages.sh @@ -4,17 +4,33 @@ hugepages=$(getarg hugepages=) || hugepages=0 +mem_total_mb=$(($(sed -rn 's/MemTotal:\s+(.*) kB/\1/p' /proc/meminfo) / 1024 )) +hugepagesize_mb=$(($(sed -rn 's/Hugepagesize:\s+(.*) kB/\1/p' /proc/meminfo) / 1024 )) + +function adopt_watermark_scale_factor() { + # On a 3TiB host, the default watermark_scale_factor=10 was exactly that + # that the kswapd0 was running permanently. Setting it to 5 was solving the + # issue, but is likely a suboptimal value, but a first start. + # The value 500 reproduces exactly that value for that scale, and hopefully + # also holds for larger hosts. + max_watermark_scale_factor=$(($non_hugepages_mb * 500 / $mem_total_mb)) + watermark_scale_factor=$( /proc/sys/vm/watermark_scale_factor + fi +} + if [ $hugepages -gt 0 ]; then + hugepages_mb=$(($hugepages * $hugepagesize_mb)) + non_hugepages_mb=$(($mem_total_mb - $hugepages_mb)) + adopt_watermark_scale_factor exit 0 fi non_hugepages_mb=$(getarg rd.non_hugepages_mb=) || non_hugepages_mb=32768 +hugepages=$((($mem_total_mb - $non_hugepages_mb) / $hugepagesize_mb)) -mem_total_mb=$(($(sed -rn 's/MemTotal:\s+(.*) kB/\1/p' /proc/meminfo) / 1024 )) -hugepagesize_mb=$(($(sed -rn 's/Hugepagesize:\s+(.*) kB/\1/p' /proc/meminfo) / 1024 )) -nr_hugepages=$((($mem_total_mb - $non_hugepages_mb) / $hugepagesize_mb)) - -if [ $nr_hugepages -le 0 ]; then +if [ $hugepages -le 0 ]; then exit 0 fi