READPROFILE(1) READPROFILE(1) 名前 readprofile - カーネルのプロファイリング情報を読みだすツール 書式 readprofile [ options ] バージョン このオンラインマニュアルは、バージョン 2.0 のものである。 説明 readprofile コマンドは、 /proc/profile の情報を標準出力に出力する。出力 される情報は、3 種類の情報から構成されている。最初の項目は、クロック チ ック (clock tick) である。 2 番目は、たくさんの時間を消費しているカーネ ル内部の C の関数名である。 3 番目の項目は、手続きの「負荷」を正規化 し た もので、関数の長さとクロック数の比率として計算される。これらの項目は 、読み取りやすいように空白を入れ、桁を揃えて出力される。 次のコマンドラインオプションを指定できる: -m mapfile マップファイルを指定する。デフォルトでは 、 /usr/src/linux/Sys- tem.map が使用される。現在のカーネルが最後にコンパイルしたもので ない場合、または System.map を他の場所に保存している場合は、コマ ンドライン上でマップファイルを指定する必要がある。マップファイル 名の最後が ‘.gz’ となっている場合は、実行時に自動的に伸長され る 。 -p pro-file 別 の プ ロ フ ァ イ リ ングバッファを指定する。デフォルトでは、 /proc/profile が使用される。別のプロファイリングバッファを使用す ると、カーネルプロファイリングを「凍結」した後でプロファイリング 情報を読む場合などに有用である。 /proc/profile は 、‘cat’ や 、‘cp’ コマンドを使ってコピーすることができる。プログラムがプロ ファイリングバッファのサイズを前もって取得する必要があるた め 、 readprofile-1.1 で行なわれていた、圧縮されたプロファイリングバッ ファはサポートされなくなった。 -i カーネルプロファイリング情報の表示。このオプションを指定すると、 readprofile は、カーネルによって使用されているプロファイリングス テップのみを表示する。プロファイリングステップはプロファイリング バッファの精度であり、 (make config を使った) カーネルの設定、ま たはカーネルのコマンドラインで指定される。 -t (terse: 簡潔 モ ー ド) スイッチが -i と一緒に指定されると、単に 10 進数の数字のみが 表示される。 -a マップファイル中のすべてのシンボルを表示する。デフォルトでは、使 用クロック数が 0 の手続きは出力されない。 -b 各メモリ領域に対する出現数のカウントを表示する。 -r プロファイリングバッファの内容を初期化する。 /proc/profile は、 スーパーユーザーだけが書き込み可能で、一般ユーザーは読み込みしか できないため、このオプションを使用するには、スーパーユーザーの権 限が必要となる。しかし、 readprofile を setuid 0 とすることで 、 特権を持たないユーザーでもプロファイリングバッファの内容を初期化 することができる。 -M multiplier カーネルがプロファイリング割り込みを各 CPU に送る周期を変更で き るアーキテクチャもある。このオプションにより、周期をシステムクロ ック周波数 HZ の倍数で設定できる。 i386-SMP (2.2 と 2.4 カ ー ネ ル) と sparc64-SMP (2.4 カーネル) でサポートされている。このオプ ションはプロファイリングバッファの初期化も行うので、スーパーユー ザー特権が必要である。 -v 詳細モード。出力は 4 つの項目から構成され、それぞれ空白により桁 が揃えられる。最初の項目はカーネルの関数の RAM アドレス、 2 番目 の 項目は関数の名前、 3 番目の項目は使用したクロック数、最後の項 目には正規化された負荷が表示される。 -V バージョン情報の表示。 readprofile は、現在のバージョン番号を 表 示した後、終了する。 例 プロファイリングバッファの内容を使用したクロック数の順に表示するには: readprofile | sort -nr | less 最もたくさんクロックを使用した関数の上位 20 個を表示するには: readprofile | sort -nr +2 | head -20 ファイルシステムのプロファイリング情報だけを表示するには: readprofile | grep _ext2 すべてのカーネル情報を RAM アドレスと一緒に表示させるには: readprofile -av | less 現 在のカーネルのものではない「凍結された」プロファイリングバッファの内 容を表示するには: readprofile -p ~/profile.freeze -m /zImage.map.gz 各 CPU に対して 2kHz の周期でプロファイリングを要求し、プロファイリング バッファを初期化するには: sudo readprofile -M 20 バグ カ ー ネ ル バージョン 1.2 から 1.3 で /proc/profile が変更されたため、 readprofile は 1.3.x 以降のカーネルでのみ動作する。 このプログラムは、ELF カーネルでのみ動作する。 a.out カーネルへの変更は 大きな作業ではない。 a.out カーネルユーザーへの練習問題として残してある 。 プロファイリングを有効にするためには、カーネルの (再構築と) リブート が 必 要である。これはプロファイリング用のモジュールは存在せず、かつ、簡単 には作れないためである。プロファイリングを有効にするには、カーネルの コ マ ンドライン上で、 "profile=2" (または、別の数字) を指定する必要がある 。この数字を指数として 2 を累乗したものが、プロファイリングステップとし て使用される。 プ ロファイリングは、割り込みが禁止されていると使用できない。これは、割 り込みを再び有効にするときに、多くのプロファイリングのカウントが行わ れ ることを意味する。誤った情報に注意すること。 ファイル /proc/profile プロファイリングバッファのバイナリスナップショット /usr/src/linux/System.map カーネルのシンボルテーブル /usr/src/linux/* プロファイルされるプログラム :-) 4th Berkeley Distribution May 1996 READPROFILE(1)
READPROFILE(1) READPROFILE(1) NAME readprofile - a tool to read kernel profiling information SYNOPSIS readprofile [options] VERSION This manpage documents version 2.0 of the program. DESCRIPTION The readprofile command uses the /proc/profile information to print ascii data on standard output. The output is organized in three columns: the first is the number of clock ticks, the second is the name of the C function in the kernel where those many ticks occurred, and the third is the normalized ‘load’ of the procedure, calculated as a ratio between the number of ticks and the length of the procedure. The output is filled with blanks to ease readability. Available command line options are the following: -m mapfile Specify a mapfile, which by default is /usr/src/linux/Sys- tem.map. You should specify the map file on cmdline if your current kernel isn’t the last one you compiled, or if you keep System.map elsewhere. If the name of the map file ends with ‘.gz’ it is decompressed on the fly. -p pro-file Specify a different profiling buffer, which by default is /proc/profile. Using a different pro-file is useful if you want to ‘freeze’ the kernel profiling at some time and read it later. The /proc/profile file can be copied using ‘cat’ or ‘cp’. There is no more support for compressed profile buffers, like in read- profile-1.1, because the program needs to know the size of the buffer in advance. -i Info. This makes readprofile only print the profiling step used by the kernel. The profiling step is the resolution of the pro- filing buffer, and is chosen during kernel configuration (through ‘make config’), or in the kernel’s command line. If the -t (terse) switch is used together with -i only the decimal number is printed. -a Print all symbols in the mapfile. By default the procedures with 0 reported ticks are not printed. -b Print individual histogram-bin counts. -r Reset the profiling buffer. This can only be invoked by root, because /proc/profile is readable by everybody but writable only by the superuser. However, you can make readprofile setuid 0, in order to reset the buffer without gaining privileges. -M multiplier On some architectures it is possible to alter the frequency at which the kernel delivers profiling interrupts to each CPU. This option allows you to set the frequency, as a multiplier of the system clock frequency, HZ. This is supported on i386-SMP (2.2 and 2.4 kernel) and also on sparc-SMP and sparc64-SMP (2.4 kernel). This option also resets the profiling buffer, and requires superuser privileges. -v Verbose. The output is organized in four columns and filled with blanks. The first column is the RAM address of a kernel func- tion, the second is the name of the function, the third is the number of clock ticks and the last is the normalized load. -V Version. This makes readprofile print its version number and exit. EXAMPLES Browse the profiling buffer ordering by clock ticks: readprofile | sort -nr | less Print the 20 most loaded procedures: readprofile | sort -nr +2 | head -20 Print only filesystem profile: readprofile | grep _ext2 Look at all the kernel information, with ram addresses" readprofile -av | less Browse a ‘freezed’ profile buffer for a non current kernel: readprofile -p ~/profile.freeze -m /zImage.map.gz Request profiling at 2kHz per CPU, and reset the profiling buffer sudo readprofile -M 20 BUGS readprofile only works with an 1.3.x or newer kernel, because /proc/profile changed in the step from 1.2 to 1.3 This program only works with ELF kernels. The change for a.out kernels is trivial, and left as an exercise to the a.out user. To enable profiling, the kernel must be rebooted, because no profiling module is available, and it wouldn’t be easy to build. To enable pro- filing, you can specify "profile=2" (or another number) on the kernel commandline. The number you specify is the two-exponent used as pro- filing step. Profiling is disabled when interrupts are inhibited. This means that many profiling ticks happen when interrupts are re-enabled. Watch out for misleading information. FILES /proc/profile A binary snapshot of the profiling buffer. /usr/src/linux/System.map The symbol table for the kernel. /usr/src/linux/* The program being profiled :-) AVAILABILITY The readprofile command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. 4th Berkeley Distribution May 1996 READPROFILE(1)
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa