FreeBSD Kernel Profiling2008年05月23日 18時49分42秒

先日の Kernel Profiling を試してみた。


# cd /usr/src/sys/i386/conf
# cp GENERIC PROFILE
# vi PROFILE
# config -p PROFILE
# cd ../compile/PROFILE
# make install KODIR=/boot/profile

GENRIC を PROFILE にコピーして編集する。option SMP を消し、kldstat を頼りにカーネルに必要なオプションを組み込む。


# reboot
# kgmon -b
# kgmon -p
kgmon: kernel profiling is running.
# gprof /boot/profile/kernel gmon.out | less
        None             




call graph profile:
          The sum of self and descendents is the major sort
          for this listing.

          function entries:

index     the index of the function in the call graph
          listing, as an aid to locating it (see below).
...
index  %time    self descendents  called+self    name           index
                                  called/total       children

                                                     <spontaneous>
[1]     54.6   65.10        0.00                 __mcount [1]

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

                                                     <spontaneous>
[2]     41.1    0.00       48.93                 g_eli_worker [2]
                0.49       48.39   16233/16233       g_eli_crypto_run [3]
                0.00        0.04   16220/115326      _sleep [43]
                0.00        0.00   32453/32468       bioq_takefirst [404]

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

                0.49       48.39   16233/16233       g_eli_worker [2]
[3]     41.0    0.49       48.39   16233         g_eli_crypto_run [3]
                0.04       41.81 3764630/3764630     crypto_dispatch [4]
                0.07        6.43 3764630/3764630     g_eli_crypto_ivgen [10]
                0.01        0.03   16233/408591      malloc <cycle 1> [108]
                0.00        0.00   16233/76658       __divdi3 [280]
                0.00        0.00      33/256245122     generic_bcopy [11]
                0.00        0.00      33/256245122     bcopy [38]
...

再起動後、kgmon でプロファイリングを有効にする。その後、再度 kgmon を使い、結果を書き出す。その結果を gprof を用いて整形する。

今回は、config -p を使ったので、低粒度のプロファイルが適用された。kgmon に -pp を渡すと高粒度のプロファイルが出来るとあるの。カーネルを作り直さずにでも出来るのかと疑問に思ったので試してみた。


# kgmon -rBp
kgmon: warning: cannot turn profiling on
kgmon: kernel profiling is running (high resolution).
# kgmon -B
kgmon: warning: cannot turn profiling on
kgmon: kernel profiling is running (high resolution).
# kgmon -p
kgmon: kernel profiling is off
# gprof /boot/profile/kernel gmon.out
...

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name

Index by function name



やはり、カーネルを高粒度用に作り直さないと無理な様だ。

前回