mbuf: remove control mbuf
[dpdk.git] / doc / guides / prog_guide / profile_app.rst
1 ..  BSD LICENSE
2     Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
3     All rights reserved.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     * Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in
13     the documentation and/or other materials provided with the
14     distribution.
15     * Neither the name of Intel Corporation nor the names of its
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 Profile Your Application
32 ========================
33
34 The following sections describe methods of profiling DPDK applications on
35 different architectures.
36
37
38 Profiling on x86
39 ----------------
40
41 Intel processors provide performance counters to monitor events.
42 Some tools provided by Intel, such as Intel® VTune™ Amplifier, can be used
43 to profile and benchmark an application.
44 See the *VTune Performance Analyzer Essentials* publication from Intel Press for more information.
45
46 For a DPDK application, this can be done in a Linux* application environment only.
47
48 The main situations that should be monitored through event counters are:
49
50 *   Cache misses
51
52 *   Branch mis-predicts
53
54 *   DTLB misses
55
56 *   Long latency instructions and exceptions
57
58 Refer to the
59 `Intel Performance Analysis Guide <http://software.intel.com/sites/products/collateral/hpc/vtune/performance_analysis_guide.pdf>`_
60 for details about application profiling.
61
62
63 Empty cycles tracing
64 ~~~~~~~~~~~~~~~~~~~~
65
66 Iterations that yielded no RX packets (empty cycles, wasted iterations) can
67 be analyzed using VTune Amplifier. This profiling employs the
68 `Instrumentation and Tracing Technology (ITT) API
69 <https://software.intel.com/en-us/node/544195>`_
70 feature of VTune Amplifier and requires only reconfiguring the DPDK library,
71 no changes in a DPDK application are needed.
72
73 To trace wasted iterations on RX queues, first reconfigure DPDK with
74 ``CONFIG_RTE_ETHDEV_RXTX_CALLBACKS`` and
75 ``CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS`` enabled.
76
77 Then rebuild DPDK, specifying paths to the ITT header and library, which can
78 be found in any VTune Amplifier distribution in the *include* and *lib*
79 directories respectively:
80
81 .. code-block:: console
82
83     make EXTRA_CFLAGS=-I<path to ittnotify.h> \
84          EXTRA_LDLIBS="-L<path to libittnotify.a> -littnotify"
85
86 Finally, to see wasted iterations in your performance analysis results,
87 select the *"Analyze user tasks, events, and counters"* checkbox in the
88 *"Analysis Type"* tab when configuring analysis via VTune Amplifier GUI.
89 Alternatively, when running VTune Amplifier via command line, specify
90 ``-knob enable-user-tasks=true`` option.
91
92 Collected regions of wasted iterations will be marked on VTune Amplifier's
93 timeline as ITT tasks. These ITT tasks have predefined names, containing
94 Ethernet device and RX queue identifiers.
95
96
97 Profiling on ARM64
98 ------------------
99
100 Using Linux perf
101 ~~~~~~~~~~~~~~~~
102
103 The ARM64 architecture provide performance counters to monitor events.  The
104 Linux ``perf`` tool can be used to profile and benchmark an application.  In
105 addition to the standard events, ``perf`` can be used to profile arm64
106 specific PMU (Performance Monitor Unit) events through raw events (``-e``
107 ``-rXX``).
108
109 For more derails refer to the
110 `ARM64 specific PMU events enumeration <http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100095_0002_04_en/way1382543438508.html>`_.
111
112
113 High-resolution cycle counter
114 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115
116 The default ``cntvct_el0`` based ``rte_rdtsc()`` provides a portable means to
117 get a wall clock counter in user space. Typically it runs at <= 100MHz.
118
119 The alternative method to enable ``rte_rdtsc()`` for a high resolution wall
120 clock counter is through the armv8 PMU subsystem. The PMU cycle counter runs
121 at CPU frequency. However, access to the PMU cycle counter from user space is
122 not enabled by default in the arm64 linux kernel. It is possible to enable
123 cycle counter for user space access by configuring the PMU from the privileged
124 mode (kernel space).
125
126 By default the ``rte_rdtsc()`` implementation uses a portable ``cntvct_el0``
127 scheme.  Application can choose the PMU based implementation with
128 ``CONFIG_RTE_ARM_EAL_RDTSC_USE_PMU``.
129
130 The example below shows the steps to configure the PMU based cycle counter on
131 an armv8 machine.
132
133 .. code-block:: console
134
135     git clone https://github.com/jerinjacobk/armv8_pmu_cycle_counter_el0
136     cd armv8_pmu_cycle_counter_el0
137     make
138     sudo insmod pmu_el0_cycle_counter.ko
139     cd $DPDK_DIR
140     make config T=arm64-armv8a-linuxapp-gcc
141     echo "CONFIG_RTE_ARM_EAL_RDTSC_USE_PMU=y" >> build/.config
142     make
143
144 .. warning::
145
146    The PMU based scheme is useful for high accuracy performance profiling with
147    ``rte_rdtsc()``. However, this method can not be used in conjunction with
148    Linux userspace profiling tools like ``perf`` as this scheme alters the PMU
149    registers state.