1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2018 Intel Corporation.
4 Debug & Troubleshoot guide
5 ==========================
7 DPDK applications can be designed to have simple or complex pipeline processing
8 stages making use of single or multiple threads. Applications can use poll mode
9 hardware devices which helps in offloading CPU cycles too. It is common to find
10 solutions designed with
12 * single or multiple primary processes
14 * single primary and single secondary
16 * single primary and multiple secondaries
18 In all the above cases, it is tedious to isolate, debug, and understand various
19 behaviors which occur randomly or periodically. The goal of the guide is to
20 consolidate a few commonly seen issues for reference. Then, isolate to identify
21 the root cause through step by step debug at various stages.
25 It is difficult to cover all possible issues; in a single attempt. With
26 feedback and suggestions from the community, more cases can be covered.
32 By making use of the application model as a reference, we can discuss multiple
33 causes of issues in the guide. Let us assume the sample makes use of a single
34 primary process, with various processing stages running on multiple cores. The
35 application may also make uses of Poll Mode Driver, and libraries like service
36 cores, mempool, mbuf, eventdev, cryptodev, QoS, and ethdev.
38 The overview of an application modeled using PMD is shown in
39 :numref:`dtg_sample_app_model`.
41 .. _dtg_sample_app_model:
43 .. figure:: img/dtg_sample_app_model.*
45 Overview of pipeline stage of an application
51 A couple of factors that lead the design decision could be the platform, scale
52 factor, and target. This distinct preference leads to multiple combinations,
53 that are built using PMD and libraries of DPDK. While the compiler, library
54 mode, and optimization flags are the components are to be constant, that
55 affects the application too.
58 Is there mismatch in packet (received < desired) rate?
59 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 RX Port and associated core :numref:`dtg_rx_rate`.
65 .. figure:: img/dtg_rx_rate.*
67 RX packet rate compared against received rate.
69 #. Is the configuration for the RX setup correctly?
71 * Identify if port Speed and Duplex is matching to desired values with
74 * Check ``DEV_RX_OFFLOAD_JUMBO_FRAME`` is set with ``rte_eth_dev_info_get``.
76 * Check promiscuous mode if the drops do not occur for unique MAC address
77 with ``rte_eth_promiscuous_get``.
79 #. Is the drop isolated to certain NIC only?
81 * Make use of ``rte_eth_dev_stats`` to identify the drops cause.
83 * If there are mbuf drops, check nb_desc for RX descriptor as it might not
84 be sufficient for the application.
86 * If ``rte_eth_dev_stats`` shows drops are on specific RX queues, ensure RX
87 lcore threads has enough cycles for ``rte_eth_rx_burst`` on the port queue
90 * If there are redirect to a specific port queue pair with, ensure RX lcore
91 threads gets enough cycles.
93 * Check the RSS configuration ``rte_eth_dev_rss_hash_conf_get`` if the
94 spread is not even and causing drops.
96 * If PMD stats are not updating, then there might be offload or configuration
97 which is dropping the incoming traffic.
99 #. Is there drops still seen?
101 * If there are multiple port queue pair, it might be the RX thread, RX
102 distributor, or event RX adapter not having enough cycles.
104 * If there are drops seen for RX adapter or RX distributor, try using
105 ``rte_prefetch_non_temporal`` which intimates the core that the mbuf in the
109 Is there packet drops at receive or transmit?
110 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112 RX-TX port and associated cores :numref:`dtg_rx_tx_drop`.
116 .. figure:: img/dtg_rx_tx_drop.*
122 * Identify if there are multiple RX queue configured for port by
123 ``nb_rx_queues`` using ``rte_eth_dev_info_get``.
125 * Using ``rte_eth_dev_stats`` fetch drops in q_errors, check if RX thread
126 is configured to fetch packets from the port queue pair.
128 * Using ``rte_eth_dev_stats`` shows drops in ``rx_nombuf``, check if RX
129 thread has enough cycles to consume the packets from the queue.
133 * If the TX rate is falling behind the application fill rate, identify if
134 there are enough descriptors with ``rte_eth_dev_info_get`` for TX.
136 * Check the ``nb_pkt`` in ``rte_eth_tx_burst`` is done for multiple packets.
138 * Check ``rte_eth_tx_burst`` invokes the vector function call for the PMD.
140 * If oerrors are getting incremented, TX packet validations are failing.
141 Check if there queue specific offload failures.
143 * If the drops occur for large size packets, check MTU and multi-segment
144 support configured for NIC.
147 Is there object drops in producer point for the ring library?
148 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150 Producer point for ring :numref:`dtg_producer_ring`.
152 .. _dtg_producer_ring:
154 .. figure:: img/dtg_producer_ring.*
156 Producer point for Rings
158 #. Performance issue isolation at producer
160 * Use ``rte_ring_dump`` to validate for all single producer flag is set to
163 * There should be sufficient ``rte_ring_free_count`` at any point in time.
165 * Extreme stalls in dequeue stage of the pipeline will cause
166 ``rte_ring_full`` to be true.
169 Is there object drops in consumer point for the ring library?
170 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172 Consumer point for ring :numref:`dtg_consumer_ring`.
174 .. _dtg_consumer_ring:
176 .. figure:: img/dtg_consumer_ring.*
178 Consumer point for Rings
180 #. Performance issue isolation at consumer
182 * Use ``rte_ring_dump`` to validate for all single consumer flag is set to
185 * If the desired burst dequeue falls behind the actual dequeue, the enqueue
186 stage is not filling up the ring as required.
188 * Extreme stall in the enqueue will lead to ``rte_ring_empty`` to be true.
191 Is there a variance in packet or object processing rate in the pipeline?
192 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194 Memory objects close to NUMA :numref:`dtg_mempool`.
198 .. figure:: img/dtg_mempool.*
200 Memory objects have to be close to the device per NUMA.
202 #. Stall in processing pipeline can be attributes of MBUF release delays.
203 These can be narrowed down to
205 * Heavy processing cycles at single or multiple processing stages.
207 * Cache is spread due to the increased stages in the pipeline.
209 * CPU thread responsible for TX is not able to keep up with the burst of
212 * Extra cycles to linearize multi-segment buffer and software offload like
213 checksum, TSO, and VLAN strip.
215 * Packet buffer copy in fast path also results in stalls in MBUF release if
216 not done selectively.
218 * Application logic sets ``rte_pktmbuf_refcnt_set`` to higher than the
219 desired value and frequently uses ``rte_pktmbuf_prefree_seg`` and does
220 not release MBUF back to mempool.
222 #. Lower performance between the pipeline processing stages can be
224 * The NUMA instance for packets or objects from NIC, mempool, and ring
227 * Drops on a specific socket are due to insufficient objects in the pool.
228 Use ``rte_mempool_get_count`` or ``rte_mempool_avail_count`` to monitor
231 * Try prefetching the content in processing pipeline logic to minimize the
234 #. Performance issue can be due to special cases
236 * Check if MBUF continuous with ``rte_pktmbuf_is_contiguous`` as certain
237 offload requires the same.
239 * Use ``rte_mempool_cache_create`` for user threads require access to
242 * If the variance is absent for larger huge pages, then try rte_mem_lock_page
243 on the objects, packets, lookup tables to isolate the issue.
246 Is there a variance in cryptodev performance?
247 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
249 Crypto device and PMD :numref:`dtg_crypto`.
253 .. figure:: img/dtg_crypto.*
255 CRYPTO and interaction with PMD device.
257 #. Performance issue isolation for enqueue
259 * Ensure cryptodev, resources and enqueue is running on NUMA cores.
261 * Isolate if the cause of errors for err_count using ``rte_cryptodev_stats``.
263 * Parallelize enqueue thread for varied multiple queue pair.
265 #. Performance issue isolation for dequeue
267 * Ensure cryptodev, resources and dequeue are running on NUMA cores.
269 * Isolate if the cause of errors for err_count using ``rte_cryptodev_stats``.
271 * Parallelize dequeue thread for varied multiple queue pair.
273 #. Performance issue isolation for crypto operation
275 * If the cryptodev software-assist is in use, ensure the library is built
276 with right (SIMD) flags or check if the queue pair using CPU ISA for
277 feature_flags AVX|SSE|NEON using ``rte_cryptodev_info_get``.
279 * If the cryptodev hardware-assist is in use, ensure both firmware and
280 drivers are up to date.
282 #. Configuration issue isolation
284 * Identify cryptodev instances with ``rte_cryptodev_count`` and
285 ``rte_cryptodev_info_get``.
288 Is user functions performance is not as expected?
289 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 Custom worker function :numref:`dtg_distributor_worker`.
293 .. _dtg_distributor_worker:
295 .. figure:: img/dtg_distributor_worker.*
297 Custom worker function performance drops.
299 #. Performance issue isolation
301 * The functions running on CPU cores without context switches are the
302 performing scenarios. Identify lcore with ``rte_lcore`` and lcore index
303 mapping with CPU using ``rte_lcore_index``.
305 * Use ``rte_thread_get_affinity`` to isolate functions running on the same
308 #. Configuration issue isolation
310 * Identify core role using ``rte_eal_lcore_role`` to identify RTE, OFF and
311 SERVICE. Check performance functions are mapped to run on the cores.
313 * For high-performance execution logic ensure running it on correct NUMA
316 * Analyze run logic with ``rte_dump_stack``, ``rte_dump_registers`` and
317 ``rte_memdump`` for more insights.
319 * Make use of objdump to ensure opcode is matching to the desired state.
322 Is the execution cycles for dynamic service functions are not frequent?
323 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325 service functions on service cores :numref:`dtg_service`.
329 .. figure:: img/dtg_service.*
331 functions running on service cores
333 #. Performance issue isolation
335 * Services configured for parallel execution should have
336 ``rte_service_lcore_count`` should be equal to
337 ``rte_service_lcore_count_services``.
339 * A service to run parallel on all cores should return
340 ``RTE_SERVICE_CAP_MT_SAFE`` for ``rte_service_probe_capability`` and
341 ``rte_service_map_lcore_get`` returns unique lcore.
343 * If service function execution cycles for dynamic service functions are
346 * If services share the lcore, overall execution should fit budget.
348 #. Configuration issue isolation
350 * Check if service is running with ``rte_service_runstate_get``.
352 * Generic debug via ``rte_service_dump``.
355 Is there a bottleneck in the performance of eventdev?
356 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 #. Check for generic configuration
360 * Ensure the event devices created are right NUMA using
361 ``rte_event_dev_count`` and ``rte_event_dev_socket_id``.
363 * Check for event stages if the events are looped back into the same queue.
365 * If the failure is on the enqueue stage for events, check if queue depth
366 with ``rte_event_dev_info_get``.
368 #. If there are performance drops in the enqueue stage
370 * Use ``rte_event_dev_dump`` to dump the eventdev information.
372 * Periodically checks stats for queue and port to identify the starvation.
374 * Check the in-flight events for the desired queue for enqueue and dequeue.
377 Is there a variance in traffic manager?
378 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380 Traffic Manager on TX interface :numref:`dtg_qos_tx`.
384 .. figure:: img/dtg_qos_tx.*
386 Traffic Manager just before TX.
388 #. Identify the cause for a variance from expected behavior, is due to
389 insufficient CPU cycles. Use ``rte_tm_capabilities_get`` to fetch features
390 for hierarchies, WRED and priority schedulers to be offloaded hardware.
392 #. Undesired flow drops can be narrowed down to WRED, priority, and rates
395 #. Isolate the flow in which the undesired drops occur. Use
396 ``rte_tn_get_number_of_leaf_node`` and flow table to ping down the leaf
399 #. Check the stats using ``rte_tm_stats_update`` and ``rte_tm_node_stats_read``
400 for drops for hierarchy, schedulers and WRED configurations.
403 Is the packet in the unexpected format?
404 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406 Packet capture before and after processing :numref:`dtg_pdump`.
410 .. figure:: img/dtg_pdump.*
412 Capture points of Traffic at RX-TX.
414 #. To isolate the possible packet corruption in the processing pipeline,
415 carefully staged capture packets are to be implemented.
417 * First, isolate at NIC entry and exit.
419 Use pdump in primary to allow secondary to access port-queue pair. The
420 packets get copied over in RX|TX callback by the secondary process using
423 * Second, isolate at pipeline entry and exit.
425 Using hooks or callbacks capture the packet middle of the pipeline stage
426 to copy the packets, which can be shared to the secondary debug process
427 via user-defined custom rings.
431 Use similar analysis to objects and metadata corruption.
434 Does the issue still persist?
435 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437 The issue can be further narrowed down to the following causes.
439 #. If there are vendor or application specific metadata, check for errors due
440 to META data error flags. Dumping private meta-data in the objects can give
441 insight into details for debugging.
443 #. If there are multi-process for either data or configuration, check for
444 possible errors in the secondary process where the configuration fails and
445 possible data corruption in the data plane.
447 #. Random drops in the RX or TX when opening other application is an indication
448 of the effect of a noisy neighbor. Try using the cache allocation technique
449 to minimize the effect between applications.
452 How to develop a custom code to debug?
453 --------------------------------------
455 #. For an application that runs as the primary process only, debug functionality
456 is added in the same process. These can be invoked by timer call-back,
457 service core and signal handler.
459 #. For the application that runs as multiple processes. debug functionality in
460 a standalone secondary process.