[20191204]hugepage相關引數含義.txt

lfree發表於2019-12-06

[20191204]hugepage相關引數含義.txt

--//別人問題的問題,就是grep -i pages /proc/meminfo輸出的HugePages_Total,HugePages_Free,HugePages_Rsvd,HugePages_Surp含義.

#  grep -i pages /proc/meminfo
AnonPages:      31476112 kB
HugePages_Total:   78600
HugePages_Free:     3092
HugePages_Rsvd:     3085
HugePages_Surp:        0
Hugepagesize:       2048 kB

--//為了更好說明,我修改指令碼加入asm例項分析:
#  cat huge.sh
#! /bin/bash
total_shmsize=0
total_hugepagesize=0

for pid in `ps -ef | egrep "ora_pmon_|asm_pmon" |egrep -v "grep"|  awk '{print $2}'`
do
        echo
        echo "-----------------------------------------------------------"
        echo
#       ps -ef | grep $pid | grep -v grep
        ps v $pid
        echo

        shmsize=`grep -A 1 'SYSV00000000' /proc/$pid/smaps | grep "^Size:" | awk 'BEGIN{sum=0}{sum+=$2}END{print sum/1024}' |  awk -F"." '{print $1}'`
        hugepagesize=`grep -B 11 'KernelPageSize:     2048 kB' /proc/$pid/smaps | grep "^Size:" | awk 'BEGIN{sum=0}{sum+=$2}END{print sum/1024}' | awk -F"." '{print $1}'`

        echo "INSTANCE SGA (SMALL/HUGE page)"  : $shmsize "MB"
        echo "INSTANCE SGA (HUGE PAGE)" $hugepagesize "MB"

        echo "Percent Huge page :"  $(( $hugepagesize *100 / $shmsize  )) "%"


        total_shmsize=$(( $shmsize + $total_shmsize ))
        total_hugepagesize=$(( $total_hugepagesize + $hugepagesize ))

done

echo
echo "-----------------------------------------------------------"
echo "-----------------------------------------------------------"
echo

echo "SGA TOTAL (SMALL/HUGE page)"  : $total_shmsize "MB"
echo "SGA TOTAL (HUGE PAGE)" $total_hugepagesize "MB"
echo "Percent Huge page :"  $(( $total_hugepagesize *100 / $total_shmsize  )) "%"

#  . /usr/local/bin/huge.sh
-----------------------------------------------------------
   PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 21310 ?        Ss   419:59      4 168518 2147781 13812  0.0 asm_pmon_+ASM1

INSTANCE SGA (SMALL/HUGE page) : 2044 MB
INSTANCE SGA (HUGE PAGE) 2046 MB
Percent Huge page : 100 %
-----------------------------------------------------------

   PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 23988 ?        Ss   2304:27     7 189443 79487228 26248  0.0 ora_pmon_dbcn1

INSTANCE SGA (SMALL/HUGE page) : 77568 MB
INSTANCE SGA (HUGE PAGE) 77570 MB
Percent Huge page : 100 %

-----------------------------------------------------------
   PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 27535 ?        Ss   579:31      0 189443 79485216 18832  0.0 ora_pmon_dben1

INSTANCE SGA (SMALL/HUGE page) : 77568 MB
INSTANCE SGA (HUGE PAGE) 77570 MB
Percent Huge page : 100 %

-----------------------------------------------------------
-----------------------------------------------------------

SGA TOTAL (SMALL/HUGE page) : 157180 MB
SGA TOTAL (HUGE PAGE) 157186 MB
Percent Huge page : 100 %

--//3個例項使用HUGEpages記憶體157186,157186/2 = 78593.

#  grep -i pages /proc/meminfo
AnonPages:      30329756 kB
HugePages_Total:   78600
HugePages_Free:     3092
HugePages_Rsvd:     3085
HugePages_Surp:        0
Hugepagesize:       2048 kB

--//我的理解
--//HugePages_Total表示總量.
--//HugePages_Free表示沒有使用的數量.
--//HugePages_Rsvd表示reserved,保留未用的數量
--//HugePages_Surp表示surplus剩餘; 盈餘; 結餘的數量.

--//HugePages_Total-HugePages_Free+HugePages_Rsvd=78600-3092+3085 = 78593 ,就是當前全部例項使用hugepages的數量.

--//HugePages_Surp表示surplus剩餘; 盈餘; 結餘的數量.實際上設定vm.nr_overcommit_hugepages引數就可以看到.
--//並且vm.nr_hugepages不足的情況下就可以看到.注意測試這樣的情況必須設定use_large_pages=only.

--//看我的測試環境:

$ grep "^vm.nr" /etc/sysctl.conf
vm.nr_hugepages = 104
vm.nr_overcommit_hugepages = 1000

SYS@book> show parameter use_large
NAME            TYPE   VALUE
--------------- ------ -----
use_large_pages string ONLY

$ grep -i pages /proc/meminfo
AnonPages:        236260 kB
AnonHugePages:         0 kB
HugePages_Total:     309
HugePages_Free:       68
HugePages_Rsvd:       68
HugePages_Surp:      205
Hugepagesize:       2048 kB

--//我設定vm.nr_hugepages = 104,而實際需求總量是309.這樣需要從vm.nr_overcommit_hugepages借用
--//HugePages_Total-vm.nr_hugepages  309-104 = 205.HugePages_Surp表示就是這個含義.

$ . huge.sh
-----------------------------------------------------------
oracle   19367     1  0 15:59 ?        00:00:00 ora_pmon_book
INSTANCE SGA (SMALL/HUGE page) : 616 MB
INSTANCE SGA (HUGE PAGE) 618 MB
Percent Huge page : 100 %
-----------------------------------------------------------
SGA TOTAL (SMALL/HUGE page) : 616 MB
SGA TOTAL (HUGE PAGE) 618 MB
Percent Huge page : 100 %

--//表達能力有限,但願透過前面的例子能理解這些引數的含義.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2667178/,如需轉載,請註明出處,否則將追究法律責任。

相關文章