forked from jkstill/memory-verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chk-anon-huge.sh
executable file
·74 lines (47 loc) · 1.63 KB
/
chk-anon-huge.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/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'
)
declare fileCount=${#anonConfigFiles[@]}
declare i=0
declare 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
declare anonHugePagesConfigured=1
[[ -z $anonFileToChk ]] && anonHugePagesConfigured=0
#echo anonHugePagesConfigured: $anonHugePagesConfigured
declare 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"