xref: /dpdk/doc/guides/prog_guide/profile_app.rst (revision eb6d5a0af9a05bf940ba19ec1ddbe575b5e7540b)
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
31Profile Your Application
32========================
33
34The following sections describe methods of profiling DPDK applications on
35different architectures.
36
37
38Profiling on x86
39----------------
40
41Intel processors provide performance counters to monitor events.
42Some tools provided by Intel, such as Intel® VTune™ Amplifier, can be used
43to profile and benchmark an application.
44See the *VTune Performance Analyzer Essentials* publication from Intel Press for more information.
45
46For a DPDK application, this can be done in a Linux* application environment only.
47
48The 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
58Refer to the
59`Intel Performance Analysis Guide <http://software.intel.com/sites/products/collateral/hpc/vtune/performance_analysis_guide.pdf>`_
60for details about application profiling.
61
62
63Empty cycles tracing
64~~~~~~~~~~~~~~~~~~~~
65
66Iterations that yielded no RX packets (empty cycles, wasted iterations) can
67be analyzed using VTune Amplifier. This profiling employs the
68`Instrumentation and Tracing Technology (ITT) API
69<https://software.intel.com/en-us/node/544195>`_
70feature of VTune Amplifier and requires only reconfiguring the DPDK library,
71no changes in a DPDK application are needed.
72
73To 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
77Then rebuild DPDK, specifying paths to the ITT header and library, which can
78be found in any VTune Amplifier distribution in the *include* and *lib*
79directories 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
86Finally, to see wasted iterations in your performance analysis results,
87select the *"Analyze user tasks, events, and counters"* checkbox in the
88*"Analysis Type"* tab when configuring analysis via VTune Amplifier GUI.
89Alternatively, when running VTune Amplifier via command line, specify
90``-knob enable-user-tasks=true`` option.
91
92Collected regions of wasted iterations will be marked on VTune Amplifier's
93timeline as ITT tasks. These ITT tasks have predefined names, containing
94Ethernet device and RX queue identifiers.
95
96
97Profiling on ARM64
98------------------
99
100Using Linux perf
101~~~~~~~~~~~~~~~~
102
103The ARM64 architecture provide performance counters to monitor events.  The
104Linux ``perf`` tool can be used to profile and benchmark an application.  In
105addition to the standard events, ``perf`` can be used to profile arm64
106specific PMU (Performance Monitor Unit) events through raw events (``-e``
107``-rXX``).
108
109For 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
113High-resolution cycle counter
114~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115
116The default ``cntvct_el0`` based ``rte_rdtsc()`` provides a portable means to
117get a wall clock counter in user space. Typically it runs at <= 100MHz.
118
119The alternative method to enable ``rte_rdtsc()`` for a high resolution wall
120clock counter is through the armv8 PMU subsystem. The PMU cycle counter runs
121at CPU frequency. However, access to the PMU cycle counter from user space is
122not enabled by default in the arm64 linux kernel. It is possible to enable
123cycle counter for user space access by configuring the PMU from the privileged
124mode (kernel space).
125
126By default the ``rte_rdtsc()`` implementation uses a portable ``cntvct_el0``
127scheme.  Application can choose the PMU based implementation with
128``CONFIG_RTE_ARM_EAL_RDTSC_USE_PMU``.
129
130The example below shows the steps to configure the PMU based cycle counter on
131an 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.
150