1.å¦ä½ä½¿ç¨oprofile对软件åprofiling
å¦ä½ä½¿ç¨oprofile对软件åprofiling
ããä¸. Oprofileç®ä»
ãã
ããProfilingæ¯å¯¹ä¸åæ§è½ç¹å¾çæ°æ®çå½¢å¼åæ»ç»æåæï¼å®é常以å¾å½¢å表çå½¢å¼åºç°ãå®æä¾ä¸ºç¹å®çå¤çå¨äºä»¶æ¶éçéæ ·ç¾åæ°ææ°éï¼æ¯å¦cache miss rateãTLB miss rateççãä¸è¬æ¥è¯´ï¼ä¸»è¦ç®çæ¯ä¸ºäºæ¾åºè½¯ä»¶ä¸çæ§è½ç¶é¢ï¼ç¶åæé对æ§çä¼å以æå软件çæ´ä½æ§è½ã
ãã
ããOprofile æ¯ç¨äº Linux çè¥å¹²ç§è¯æµåæ§è½çæ§å·¥å ·ä¸çä¸ç§ãå®å¯ä»¥å·¥ä½å¨ä¸åçä½ç³»ç»æä¸ï¼å æ¬ARM,源码潍坊到德州源码 PowerPC, MIPS, IA, IA å AMD Athlonççãå®çå¼éå¾å°ï¼ä»Linux 2.6 çèµ·ï¼å®è¢«å å«è¿äºLinuxå æ ¸ä¸ã
ãã
ããOprofileå¯ä»¥æ¶éæå ³å¤çå¨äºä»¶çä¿¡æ¯ï¼å¸®å©ç¨æ·è¯å«è¯¸å¦å¾ªç¯çå±å¼ãcacheç使ç¨çä½ãä½æçç±»å转æ¢ååä½æä½ãé误é¢æµè½¬ç§»çé®é¢ãOprofileæ¯ä¸ç§ç»ç²åº¦çå·¥å ·ï¼å¯ä»¥ä¸ºæ令éæè 为å½æ°ãç³»ç»è°ç¨æä¸æå¤çä¾ç¨æ¶ééæ ·ãOprofile éè¿åæ ·æ¥å·¥ä½ã使ç¨æ¶éå°çè¯æµæ°æ®ï¼ç¨æ·å¯ä»¥å¾å®¹æå°æ¾åºæ§è½é®é¢ã
ãã
ããéè¿çå¯CPUçhardware eventsï¼oprofileå¯ä»¥å¨è¿è¡ç¶æä¸å¯¹æ´ä¸ªLinuxç³»ç»è¿è¡profilingãProfilingç对象å¯ä»¥æ¯Linux kernel (å æ¬modulesåinterrupt handlers), shared librariesæè åºç¨ç¨åºã
ãã
ããä»0.9.8çæ¬å¼å§ï¼oprofileæ¯æPerf_events profiling mode模å¼ãåºç¨ç¨åºoperf被ç¨æ¥æ§å¶profilingè¿ç¨ï¼èå¨legacy modeä¸ï¼æ¯éè¿opcontrolèæ¬åoprofiled daemonæ¥å®æçãOperfä¸å象legacy modeé£æ ·éè¦OProfile kernel driverï¼å®ç´æ¥åLinux Kernel Performance Events Subsystemæ交éã使ç¨operfï¼å°±å¯ä»¥ç¨æ®éç¨æ·ç身份æ¥profilingç¨æ·çåºç¨ç¨åºäºï¼å½ç¶å¦æéè¦å¯¹æ´ä¸ªç³»ç»æ¥profilingçæ¶åè¿æ¯éè¦rootæéçã
ãã
ããå¦æ硬件ä¸æ¯æOProfile使ç¨performance countersï¼OProfileå°±åªè½å·¥ä½å¨Timer Modeä¸äºãTimer Modeåªè½å¨legacy profiling modeä¸ä½¿ç¨ï¼å³åªè½éè¿opcontrolèæ¬æ¥æ§å¶ã
ããOprofileçä¼å¿ï¼
ã㟠æ¯è¾ä½çè¿è¡å¼é
ã㟠对被profilingç对象影åå¾å°
ã㟠å¯ä»¥profilingä¸ææå¡ç¨åº(interrupt handlers)
ã㟠å¯ä»¥profilingåºç¨ç¨åºåshared libraries
ã㟠å¯ä»¥profiling dynamically compiled (JIT) code
ã㟠å¯ä»¥å¯¹æ´ä¸ªç³»ç»åprofiling
ã㟠å¯ä»¥è§å¯CPUå é¨çç»èï¼ä¾å¦cache miss rate
ã㟠å¯ä»¥å¤æºä»£ç åannotation
ã㟠å¯ä»¥æ¯æinstruction-levelçprofiling
ã㟠å¯ä»¥çæcall-graph profiles
ãã
ããä¸è¿OProfileä¹ä¸æ¯ä¸è½çï¼å®ä¹æèªå·±çå±éæ§ï¼
ã㟠åªè½å¨x, ARM, åPowerPCæ¶æä¸çæcall graph profiles
ã㟠ä¸æ¯æ%精确çinstruction-level profiling
ã㟠对dynamically compiled (JIT) code profilingçæ¯æè¿ä¸å®åã
ãã
ããæ 论å¦ä½ï¼Oprofileçåè½é½æ¯gprofè¦å¼ºå¾å¤ï¼ä»£ä»·æ¯é 置起æ¥ä¼æ¯è¾éº»ç¦ã
ãã
ãã
ããäº. ç¼è¯Oprofile
ãã
ããé¦å æ好å¨Linux kerneléé¢éä¸Oprofile driverï¼ä»¥è·å¾å ¨é¢çæ¯æã
ãã
ã
ããå 为ç¬è 使ç¨çæ¯Xilinx Linux pre-built .7ï¼æ以è¿éä¸è½½çæ¯linux-xlnx-xilinx-v.7.tar.gz
ãã
ãã解å缩åï¼ç¨ä»¥ä¸å½ä»¤è°åºLinux kernelçé ç½®çé¢ï¼
ããexport ARCH=arm
ããexport CROSS_COMPILE=arm-xilinx-linux-gnueabi-
ããmake xilinx_zynq_defconfig
ããmake xconfig æè make menuconfig
ãã
ããå¨é ç½®çé¢ä¸å°ä»¥ä¸ä¸¤é¡¹å¾ä¸ï¼
ããGeneral setup --->
ãã[*] Profiling support
ãã<*> OProfile system profiling
ãã
ããç¶åmake uImageå³å¯çææ°çuImageï¼ç¨æ¥æ¿æ¢Xilinx Linux pre-built .7ä¸çLinux kernel imageãåæ¶æ们ä¹éè¦vmlinuxæ¥æ£æ¥profilingçç»æã
ãã
ãã
ããOprofileéè¦popt, bfd, libertyåºï¼è¦å¨åµå ¥å¼åæ¿ä¸ä½¿ç¨è¿äºåºï¼éè¦æå·¥å®æ交åç¼è¯ã
ãã
ããé对popt 1.7ï¼ç¨ä»¥ä¸å½ä»¤å®æç¼è¯ï¼
ãã./configure --prefix=/home/wave/xilinx/oprofileprj/rootfs --host=arm-xilinx-linux-gnueabi --with-kernel-support --disable-nls && make && make install
ãã
ããé对binutils 2.ï¼ç¨ä»¥ä¸å½ä»¤å®æç¼è¯ï¼
ãã./configure --host=arm-xilinx-linux-gnueabi --prefix=/home/wave/xilinx/oprofileprj/rootfs --enable-install-libbfd --enable-install-libiberty --enable-shared && make && make install
ããä¸è¿--enable-install-libiberty没æææï¼æ以éè¦æå·¥ælibiberty.aålibiberty.hæ·è´å°ç¸åºçä½ç½®ã
ãã
ããé对oprofile 0.9.9ï¼ç¨ä»¥ä¸å½ä»¤å®æç¼è¯ï¼
ãã./configure --host=arm-xilinx-linux-gnueabi --prefix=/home/wave/xilinx/oprofileprj/rootfs --with-kernel-support --with-binutils=/home/wave/xilinx/oprofileprj/rootfs && make && make install
ããé ç½®è¿ç¨ç»æåå¯è½ä¼æ以ä¸æ示ï¼å 为没ææç®ç¨GUIåprofile JITed codeï¼æ以ç´æ¥å¿½è§ä¹ã
ããconfig.status: executing libtool commands
ããWarning: QT version 3 was requested but not found. No GUI will be built.
ããWarning: The user account 'oprofile:oprofile' does not exist on the system.
ããTo profile JITed code, this special user account must exist.
ããPlease ask your system administrator to add the following user and group:
ããuser name : 'oprofile'
ããgroup name: 'oprofile'
ããThe 'oprofile' group must be the default group for the 'oprofile' user.
ãã
ããå°ç¼è¯å®æçuImageï¼vmlinuxï¼oprofile binaryï¼éæ°ç¼è¯ç没æ-pgçlibjpeg binary以åtool chainçlibcæå æ¾å°SDå¡ä¸ï¼åå¤å¨ZCå¼åæ¿ä¸å°è¯profile djpegã
ãã
ããä¸. è¿è¡Oprofile
ãã
ããæ£å¸¸å¯å¨åµå ¥å¼Linuxåï¼å¨å¼åæ¿çconsoleä¸ä¸æ¬¡è¾å ¥ä»¥ä¸å½ä»¤ï¼
ãã
ããmount /dev/mmcblk0p1 /mnt
ãã
ããmkdir -p /home/root/work
ããcd /home/root/work
ããtar zxvf /mnt/jpeg-bin-nopg.tar.gz
ããcd jpeg-bin/bin
ããcp /mnt/park-x.jpg .
ããexport LD_LIBRARY_PATH=/home/root/work/jpeg-bin/lib
ãã
ããcd /home/root/work
ããtar zxvf /mnt/rootfs.tar.gz
ããcd rootfs
ããchown root:root -R
*ããcp -R bin/* /usr/bin
ããcp -R lib/* /lib
ããcp /bin/which /usr/bin
ããcp /bin/dirname /usr/bin
ããmkdir -p /home/wave/xilinx/oprofileprj/rootfs/share
ããcp -R ./rootfs/* /home/wave/xilinx/oprofileprj/rootfs
ãã
ããcd /home/root/work
ããtar zxvf /mnt/libc.tar.gz
ããcp ./lib/libstdc*.* /lib
ãã
ããmkdir -p /home/wave/xilinx/libjpeg
ããcd /home/wave/xilinx/libjpeg
ããtar zxvf /mnt/jpeg-9.tar.gz
ãã
ããcp /mnt/vmlinux /home/root/work
ãã
ããcd /home/root/work/jpeg-bin/bin
ãã
ããopcontrol --init
ããopcontrol --vmlinux=/home/root/work/vmlinux
ããopcontrol --setup --event=CPU_CYCLES:::0:1 --session-dir=/home/root/
ãã
ããoperf --vmlinux /home/root/work/vmlinux ./djpeg -bmp park-x.jpg > result.bmp
ããopreport -l ./djpeg
ãã
ããå®æè¿ä¸æ¥åï¼æ们就å¯ä»¥çå°profilingçç»æäºï¼å¨ç¬è çå¹³å°ä¸çå°çå 容ç主è¦é¨åå¦ä¸ï¼
ããroot@zynq:~/work/jpeg-bin/bin# opreport -l ./djpeg
ããUsing /home/root/work/jpeg-bin/bin/oprofile_data/samples/ for samples directory.
ããCPU: ARM Cortex-A9, speed MHz (estimated)
ããCounted CPU_CYCLES events (CPU cycle) with a unit mask of 0x (No unit mask) count
ããsamples % image name symbol name
ãã . libc-2..so /lib/libc-2..so
ãã
2024-11-25 12:01
2024-11-25 11:50
2024-11-25 10:44
2024-11-25 10:35
2024-11-25 10:33
2024-11-25 10:13