/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/debugging/profiling/oprofile.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Compilation Requirements
 
2
  * Debuging flags: -g -gdwarf-2 -g3
 
3
  * Disable inlining: -fno-inline
 
4
 
 
5
Supported Events
 
6
    opcontrol --list-events
 
7
 
 
8
    CPU_CLK_UNHALTED                    - CPU load
 
9
    BR_MISSP_EXEC                       - Branch missprediction
 
10
    L2_LINES_IN                         - L2 Cache lines modifications
 
11
    ...
 
12
    
 
13
 
 
14
Initialization
 
15
    opcontrol --init
 
16
    opcontrol --start-daemon
 
17
    opcontrol --vmlinux=vmlinux (uncompressed and not stripped
 
18
        Normally coudl be found after compilation in
 
19
        /usr/src/linux/arch/x86/boot/compressed/vmlinux
 
20
 
 
21
    opcontrol --status                  - Daemon configuration
 
22
    
 
23
Shutdown
 
24
    opcontrol --shutdown
 
25
 
 
26
 Events:
 
27
    opcontrol --event=<event1_spec> --event=<event2_spec>
 
28
    - This should be executed before daemon started
 
29
    - The number of supported counters dependens on CPU (1-8)
 
30
    - Default event counter (depends on CPU): CPU_CLK_UNHALTED:100000:0:1:1
 
31
    - Multiple events are not working for me (core duo, just first is collected)
 
32
 
 
33
    event_spec: <name:sample_rate:mask:kernel_mode:user_mode>
 
34
        + name and mask are obtained using 'ophelp'
 
35
        + sample_rate - events are generated once at specified amount of cycles
 
36
        + if kernel_mode = 0, the events obtained in kernel mode are ignored
 
37
        + if user_mode = 0, the events obtained in user mode are ignored
 
38
 
 
39
    opcontrol  --separate=<mode>
 
40
        + none          - do not separate the profiles (default)
 
41
        + library       - generate per-application profiles for libraries
 
42
        + kernel        - generate per-application profiles for the kernel 
 
43
                        and kernel modules
 
44
        + all           - generate per-application profiles for libraries and 
 
45
                        per-application profiles for the kernel and kernel 
 
46
                        modules
 
47
 
 
48
    oprof_start         - Simple UI allowing selection of events from list
 
49
 
 
50
Running
 
51
    opcontrol --reset
 
52
    opcontrol --start
 
53
    run app
 
54
    opcontrol --stop
 
55
 
 
56
    opcontrol --dump    forces daemon to flush current data
 
57
    
 
58
Analyzing
 
59
 Dump all shared libraries and apps consumed cpu cycles
 
60
    opreport --threshold 4.0    
 
61
 
 
62
 Dump symbols used cpu cycles (apps should be compiled with -g to get this info)
 
63
    opreport --symbols --debug-info /path/to/library_or_app
 
64
 
 
65
 Get line infomation
 
66
    opreport --symbols --debug-info --details --include-symbols symbol /path/to/library_or_app
 
67
        
 
68
 Anotate library source
 
69
    opannotate --source /home/csa/opc/libds/libds.so
 
70
    opannotate --source --output-dir=<result_dir> /home/csa/opc/libds/libds.so
 
71
    opannotate --assembly /home/csa/opc/libds/libds.so
 
72
 
 
73
 Filtering certain events:
 
74
    opreport event:CPU_CLK_UNHALTED cpu:1 ... (see man opreport)
 
75
    opreport -l /usr/sbin/apach2 (full path is mandatory)
 
76
    
 
77
 
 
78
Counter Multiplexing
 
79
====================
 
80
 There is limited amount of counters which can monitor arbitrary events. AMD
 
81
have 4 and Intel have 2 (actually 5, but 3 is predefined and not used by
 
82
oprofile). To count more, the counter multiplexing is could be used by 
 
83
modules. This actually implemented for AMD (and probably old P4 of Intel).
 
84
However, the support for modern Intel CPU's is still missing.
 
85
 Development is going on in oprofile git branch by Robert Richter and he is
 
86
promising to include complete version 2.6.30 or 31.
 
87
 http://git.kernel.org/?p=linux/kernel/git/rric/oprofile.git;a=shortlog;h=multiplexing
 
88
    arch/x86/oprofile/nmi_int.c:op_nmi_init     appropriate CPU model
 
89
        op_model_ppro.c - is currently used for Core* processors
 
90
 Patch agains 2.6.28 is certainly not including support for Intel
 
91
 There is also was development to update oprofile apps to work with perfmon2
 
92
 module, already supporting multiplexing, but it's only for ia64 at the moment
 
93
    http://sourceforge.net/mailarchive/forum.php?thread_name=20090212222748.GA7205%40suse.de&forum_name=perfmon2-devel