Skip to content

Commit

Permalink
chk-anon-huge.sh prototype to check if Anonymous HugePages are config…
Browse files Browse the repository at this point in the history
…ured and enabled
  • Loading branch information
jkstill committed Jul 18, 2016
1 parent 9ac1820 commit 713edb8
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions chk-anon-huge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

function chkAnonHuge () {

: <<'PYTHDOC'
check for anonymous huge pages
see Oracle Support Note:
ALERT: Disable Transparent HugePages on SLES11, RHEL6, RHEL7, OL6, OL7 and UEK2 Kernels (Doc ID 1557478.1)
The note contains a recommendation to check /proc/meminfo as one method to detect Anonymous HugePages,
but that method is only reliable if some Anonymous HugePages have actually been allocated.
PYTHDOC

declare -a anonConfigFiles=(
[0]='/sys/kernel/mm/redhat_transparent_hugepage/enabled'
[1]='/sys/kernel/mm/transparent_hugepage/enabled'
)

fileCount=${#anonConfigFiles[@]}

i=0

anonFileToChk=''

while [[ $fileCount -gt $i ]]
do
#echo $i: ${anonConfigFiles[$i]}
[[ -r ${anonConfigFiles[$i]} ]] && {
anonFileToChk=${anonConfigFiles[$i]}
break
}
(( i++ ))
done

#echo anonFileToChk: $anonFileToChk

: <<'ANONCHK'
check the contents of file anonFileToChk
'[always] never': Anonymous HugePages should be disabled.
'always [never]': Anonymous HugePages are configured in the kernel, but disabled.
If the file does not even exist, that Anonymous HugePages are not configured and can be ignored.
ANONCHK

anonHugePagesConfigured=1
[[ -z $anonFileToChk ]] && anonHugePagesConfigured=0

#echo anonHugePagesConfigured: $anonHugePagesConfigured

anonHugePagesEnabled=0

if [[ $anonHugePagesConfigured -gt 0 ]]; then
grep '[always]' $anonFileToChk >/dev/null && {
#echo anonymous HugePages are enabled
anonHugePagesEnabled=1
}
fi

# return code - will be either 0 or 1
echo $(( anonHugePagesConfigured * anonHugePagesEnabled ))

}

r=$(chkAnonHuge)

echo "r: $r"


0 comments on commit 713edb8

Please sign in to comment.