diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-16 11:10:02 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-16 11:13:31 +0000 |
commit | d9c15aa7b6d77232e35ce715092fbf1f064fe11a (patch) | |
tree | 303d0b021ea3f321f1b51dff970798ca47595354 /vespabase | |
parent | 43935f2b36a8b3ae2f4b5381ab692b9219b05aae (diff) |
Keep local variables local and check if /sys/kernel/mm/transparent_hugepage/hpage_pmd_size exists.
Diffstat (limited to 'vespabase')
-rwxr-xr-x | vespabase/src/common-env.sh | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/vespabase/src/common-env.sh b/vespabase/src/common-env.sh index 443234e82ed..afed1595a19 100755 --- a/vespabase/src/common-env.sh +++ b/vespabase/src/common-env.sh @@ -111,8 +111,7 @@ prepend_path () { } add_valgrind_suppressions_file() { - if [ -f "$1" ] - then + if [ -f "$1" ] ; then VESPA_VALGRIND_SUPPREESSIONS_OPT="$VESPA_VALGRIND_SUPPREESSIONS_OPT --suppressions=$1" fi } @@ -130,18 +129,18 @@ optionally_reduce_base_frequency() { } get_thp_size_mb() { - thp_size=2 - while read -r size - do - thp_size=$(($size / 1024 / 1024)) - break - done < /sys/kernel/mm/transparent_hugepage/hpage_pmd_size + local thp_size=2 + if [ -r /sys/kernel/mm/transparent_hugepage/hpage_pmd_size ]; then + local bytes + read -r bytes < /sys/kernel/mm/transparent_hugepage/hpage_pmd_size + thp_size=$((bytes / 1024 / 1024)) + fi echo "$thp_size" } get_jvm_hugepage_settings() { local heap_mb="$1" - sz_mb=$(get_thp_size_mb) + local sz_mb=$(get_thp_size_mb) if (($sz_mb * 2 < $heap_mb)); then options=" -XX:+UseTransparentHugePages" fi @@ -149,9 +148,9 @@ get_jvm_hugepage_settings() { } get_heap_size() { - param=$1 - args=$2 - value=$3 + local param=$1 + local args=$2 + local value=$3 for token in $args do [[ "$token" =~ ^"${param}"([0-9]+)(.)$ ]] || continue |