当前位置: 技术问答>linux和unix
oprofile的使用
来源: 互联网 发布时间:2016-06-06
本文导语: 请问哪位高手用过oprofile?我在用opcontrol --dump收集完数据之后,用opannotate --source ./myapp,会出现下面的错误:opannotate error: No sample file found: try running opcontrol --dump or specify a session containing sample files。按照...
请问哪位高手用过oprofile?我在用opcontrol --dump收集完数据之后,用opannotate --source ./myapp,会出现下面的错误:opannotate error: No sample file found: try running opcontrol --dump or specify a session containing sample files。按照它说的我执行无数遍opcontrol --dump ,还是会出现这样的错误。我的oprofile内核也加载进来了,拼写之类的都没有错。这该如何解决呢?哪位高手可以指点一下?谢谢。
|
1. Getting started
Before you can use OProfile, you must set it up. The minimum setup required for this is
to tell OProfile where the vmlinux file corresponding to the running kernel is, for example :
opcontrol --vmlinux=/boot/vmlinux-`uname -r`
If you don't want to profile the kernel itself, you can tell OProfile you don't have a vmlinux file :
opcontrol --no-vmlinux
Now we are ready to start the daemon (oprofiled) which collects the profile data :
opcontrol --start
When I want to stop profiling, I can do so with :
opcontrol --shutdown
Note that unlike gprof, no instrumentation (-pg and -a options to gcc) is necessary.
Periodically (or on opcontrol --shutdown or opcontrol --dump) the profile data is written out
into the $SESSION_DIR/samples directory (by default at /var/lib/oprofile/samples).
These profile files cover shared libraries, applications, the kernel (vmlinux), and kernel modules.
You can clear the profile data (at any time) with opcontrol --reset.
To place these sample database files in a specific directory instead of the default
location (/var/lib/oprofile) use the --session-dir=dir option. You must also specify
the --session-dir to tell the tools to continue using this directory. (In the future,
we should allow this to be specified in an environment variable.) :
opcontrol --no-vmlinux --session-dir=/home/me/tmpsession
opcontrol --start --session-dir=/home/me/tmpsession
You can get summaries of this data in a number of ways at any time. To get a summary of
data across the entire system for all of these profiles, you can do :
opreport [--session-dir=dir]
Or to get a more detailed summary, for a particular image, you can do something like :
opreport -l /boot/vmlinux-`uname -r`
There are also a number of other ways of presenting the data, as described later in this manual.
Note that OProfile will choose a default profiling setup for you. However, there are a number
of options you can pass to opcontrol if you need to change something, also detailed later.
-------------------------------------------------------------------------------------------------
Before you can use OProfile, you must set it up. The minimum setup required for this is
to tell OProfile where the vmlinux file corresponding to the running kernel is, for example :
opcontrol --vmlinux=/boot/vmlinux-`uname -r`
If you don't want to profile the kernel itself, you can tell OProfile you don't have a vmlinux file :
opcontrol --no-vmlinux
Now we are ready to start the daemon (oprofiled) which collects the profile data :
opcontrol --start
When I want to stop profiling, I can do so with :
opcontrol --shutdown
Note that unlike gprof, no instrumentation (-pg and -a options to gcc) is necessary.
Periodically (or on opcontrol --shutdown or opcontrol --dump) the profile data is written out
into the $SESSION_DIR/samples directory (by default at /var/lib/oprofile/samples).
These profile files cover shared libraries, applications, the kernel (vmlinux), and kernel modules.
You can clear the profile data (at any time) with opcontrol --reset.
To place these sample database files in a specific directory instead of the default
location (/var/lib/oprofile) use the --session-dir=dir option. You must also specify
the --session-dir to tell the tools to continue using this directory. (In the future,
we should allow this to be specified in an environment variable.) :
opcontrol --no-vmlinux --session-dir=/home/me/tmpsession
opcontrol --start --session-dir=/home/me/tmpsession
You can get summaries of this data in a number of ways at any time. To get a summary of
data across the entire system for all of these profiles, you can do :
opreport [--session-dir=dir]
Or to get a more detailed summary, for a particular image, you can do something like :
opreport -l /boot/vmlinux-`uname -r`
There are also a number of other ways of presenting the data, as described later in this manual.
Note that OProfile will choose a default profiling setup for you. However, there are a number
of options you can pass to opcontrol if you need to change something, also detailed later.
-------------------------------------------------------------------------------------------------
|
看oprofile下的帮助文档