English Portuguese (Brazil)
This mode consists of the [command]#opcontrol# shell script, the `oprofiled` daemon, and several post-processing tools. The [command]#opcontrol# command is used for configuring, starting, and stopping a profiling session. An OProfile kernel driver, usually built as a kernel module, is used for collecting samples, which are then recorded into sample files by `oprofiled`. You can use legacy mode only if you have `root` privileges. In certain cases, such as when you need to sample areas with disabled interrupt request (IRQ), this is a better alternative.
Before OProfile can be run in legacy mode, it must be configured as shown in xref:OProfile.adoc#s1-oprofile-configuring[Configuring OProfile Using Legacy Mode]. These settings are then applied when starting OProfile (xref:OProfile.adoc#s1-oprofile-starting[Starting and Stopping OProfile Using Legacy Mode]).
Using operf
[command]#operf# is the recommended profiling mode that does not require initial setup before starting. All settings are specified as command-line options and there is no separate command to start the profiling process. To stop [command]#operf#, press Ctrl+C. The typical [command]#operf# command syntax looks as follows:
[command]#operf# _options_ _range_ _command_ _args_
Replace _options_ with the desired command-line options to specify your profiling settings. Full set of options is described in `operf(1)` manual page. Replace _range_ with one of the following:
[option]`--system-wide` - this setting allows for global profiling, see xref:OProfile.adoc#using_operf_system-wide[Using [command]#operf# in System-wide Mode] +
[option]`--pid=pass:attributes[{blank}]_PID_pass:attributes[{blank}]` - this is to profile a running application, where _PID_ is the process ID of the process you want to profile. +
With _command_ and _args_, you can define a specific command or application to be profiled, and also the input arguments that this command or application requires. Either _command_, [option]`--pid` or [option]`--system-wide` is required, but these cannot be used simultaneously.
When you invoke [command]#operf# on a command line without setting the _range_ option, data will be collected for the children processes.
Using [command]#operf# in System-wide Mode
To run [command]#operf# [option]`--system-wide`, you need `root` authority. When finished profiling, you can stop [command]#operf# with `Ctrl+C`.
If you run [command]#operf# [option]`--system-wide` as a background process (with `&`), stop it in a controlled manner in order to process the collected profile data. For this purpose, use:
[command]#kill -SIGINT operf-PID#
When running [command]#operf# [option]`--system-wide`, it is recommended that your current working directory is `/root` or a subdirectory of `/root` so that sample data files are not stored in locations accessible by regular users.
Specifying the Kernel
To monitor the kernel, execute the following command:
operf --vmlinux=pass:quotes[_vmlinux_path_]
With this option, you can specify a path to a vmlinux file that matches the running kernel. Kernel samples will be attributed to this binary, allowing post-processing tools to attribute samples to the appropriate kernel symbols. If this option is not specified, all kernel samples will be attributed to a pseudo binary named "no-vmlinux".
Setting Events to Monitor