📄 enabling_oprofile.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <title></title> <link rel="stylesheet" media="screen" type="text/css" href="./style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="./design.css" /> <link rel="stylesheet" media="print" type="text/css" href="./print.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><h2><a name="enabling_oprofile" id="enabling_oprofile">Enabling Oprofile</a></h2><div class="level2"><p>It is fairly easy to get oprofile on your target system. This section will help guide you through the process of compile oprofile and run it in your target system. But if you want to know how to use oprofile in detailed, I recommend you to browse user manaul of oprofile on the offical website : <a href="http://oprofile.sourceforge.net/" class="urlextern" title="http://oprofile.sourceforge.net/" rel="nofollow">http://oprofile.sourceforge.net/</a>.</p></div><h4><a name="step_by_step_instructions" id="step_by_step_instructions">Step by Step Instructions</a></h4><div class="level4"><ul><li class="level1"><div class="li"> First you want to make sure you have the latest sources from <acronym title="Concurrent Versions System">CVS</acronym> for the toolchain and the kernel. For more information on this please refer to the <a href="version_control_systems.html#cvs_quickstart" class="wikilink1" title="version_control_systems.html">CVS Quickstart</a>.</div></li></ul><ul><li class="level1"><div class="li"> Next you must build and install the toolchain. If you are unsure on how to do this please see <a href="toolchain_build_script.html" class="wikilink1" title="toolchain_build_script.html">Toolchain Build Script</a>.Please note you should run Build Script with “-i” option for target bfd library.That is very important!</div></li></ul><ul><li class="level1"><div class="li"> After the toolchain has finished building you must add the toolchain to your <strong>PATH</strong>. Please refer to <a href="installing_the_blackfin_tool_chain.html#setting_the_path_environment_variable" class="wikilink1" title="installing_the_blackfin_tool_chain.html">Setting the PATH Environment</a> for more details.</div></li></ul><ul><li class="level1"><div class="li"> Next <em>cd</em> into the freshly downloaded kernel directory, <strong>uClinux-dist</strong>.</div></li></ul><pre class="code">user@linux:~/checkouts/kernel/uClinux-dist> cd where/you/put/uClinux-dist</pre><ul><li class="level1"><div class="li"> Now enter the command:</div></li></ul><pre class="code">user@linux:~/checkouts/kernel/uClinux-dist> make clean</pre><ul><li class="level1"><div class="li"> Next enter the following command to configure your kernel:</div></li></ul><pre class="code">user@linux:~/checkouts/kernel/uClinux-dist> make menuconfig</pre><ul><li class="level1"><div class="li"> In the make menuconfig menu select the <strong>Kernel/Library/Defaults Selection</strong></div></li></ul><ul><li class="level1"><div class="li"> Here check off the boxes:</div></li></ul><pre class="code">(x) Customize Kernel Settings(x) Customize Vendor/User Settings</pre><ul><li class="level1"><div class="li"> Then select <strong>Exit and Save</strong></div></li></ul><p> </p><ul><li class="level1"><div class="li"> Then we will enter <strong>linux kernel configuration </strong> ,under <strong>Profiling support</strong> menu, check off the following options:</div></li></ul><pre class="code"> [*] Profiling support (EXPERIMENTAL) <*> OProfile system profiling (EXPERIMENTAL) < > Hardware Performance Monitor Profiling</pre><p> </p><ul><li class="level1"><div class="li">Then we will enter user application configuration ,under the <strong>Blackfin app programs </strong> menu check off the following options:</div></li></ul><pre class="code"> [*] oprofile </pre><ul><li class="level1"><div class="li"> Now <strong>Save and Exit</strong></div></li><li class="level1"><div class="li"> Modify vendors/AnalogDevices/BF533-STAMP/Makefile </div></li></ul><p>Modify the following line :</p><pre class="code"> BLOCKS = 8192</pre><p>to:</p><pre class="code"> BLOCKS = 20480</pre><ul><li class="level1"><div class="li"> When you get back to the command line. Issue a make to create the kernel image.</div></li></ul><pre class="code">user@linux:~/checkouts/kernel/uClinux-dist> make</pre><ul><li class="level1"><div class="li"> After the make finishes, copy the linux image to your tftp directory. (For more information setting up a tftp server please see <a href="setting_up_a_tftp_server.html" class="wikilink1" title="setting_up_a_tftp_server.html">Setting up a TFTP Server</a>.)</div></li></ul><pre class="code">user@linux:~/checkouts/kernel/uClinux-dist> cp ./images/linux /tftpboot/linux</pre><ul><li class="level1"><div class="li"> Tftp the file to your target and boot the kernel using U-Boot. (For more information on using U-Boot please see <a href="das_u-boot_on_blackfin.html" class="wikilink1" title="das_u-boot_on_blackfin.html">Das U-Boot on Blackfin</a>.)</div></li></ul><pre class="code">stamp> tftp 0x2000000 linuxstamp> bootelf</pre><ul><li class="level1"><div class="li"> Once the kernel has booted make sure that there is the following files under root directory:</div></li></ul><p> bin/opannotate bin/oparchive bin/opcontrol bin/opgprof bin/ophelp bin/opreport bin/oprofiled bin/bfin_opcontrol</p><ul><li class="level1"><div class="li"> Now bfin_opcontrol have some options that we maybe need to modify to fit our profiling requirement, Such as event type , counter. Also you can run “/usr/bin/bfin_opcontrol –help” on the uClinux console to get more information about the usage of bfin_opcontrol. Now in the bfin_opcontrol script ,the default event type is TIMER_INT , and the minimum counter is 100000 since BRANCH event happen very frequently. We need to set a large counter for its profing , or our kernel will be very busy. Now we can run the following commmand to get the profiling samples:</div></li></ul><pre class="code">/usr/bin/bfin_opcontrol --init/usr/bin/bfin_opcontrol --start-daemon &/usr/bin/bfin_opcontrol --start</pre><p> “–” Then the profiling of specific event is beginning...</p><p> Then you need wait some time, at least ten minutes, to get enough sample data. A quick way to get the sample result is to send alarm signal to oprofiled process. The id of oprofiled is stored in /var/lib/oprofile/lock file.</p><p>Then we should be run </p><pre class="code">/usr/bin/bfin_opcontrol --dump</pre><p> The sample data file will be generated in /var/lib/oprofile/samples/. Then we can run </p><pre class="code">/usr/bin/opreport -l</pre><p> to see some friendly output as the following. </p><pre class="code">CPU: CPU with timer interrupt, speed 0 MHz (estimated)Profiling through timer interruptsamples % symbol name50061 99.9561 _default_idle12 0.0240 _evt_system_call5 0.0100 system_call2 0.0040 _old_mmap1 0.0020 ___do_irq1 0.0020 _do_wait1 0.0020 resume_userspace </pre><p> Known issues: 1. If you collect too many samples , there will appear the following error when you run opreport </p><pre class="code">./opreport error: /var/lib/oprofile/samples/current/{root}/var/vmlinux/{dep}/{root}/var/vmlinux/TIMER.0.0.all.all.all: Cannot allocate memory</pre></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -