Gandi / packet-journey

DEPRECATED - Packet-journey, userland router which uses DPDK for its fastpath switching.
Other
205 stars 50 forks source link

rte_eth_tx_burst() usage looks racy #16

Closed sysoleg closed 8 years ago

sysoleg commented 8 years ago

There is no any internal locking in DPDK library inside the rte_eth_tx_burst() call. Two or more threads going to send packets using the same queue of the given port can lead to race condition.

There are (at least) two posible solutions:

  1. Wrap rte_eth_tx_burst() with spinlock - as with rte_kni_tx_burst() (need to estimate performance cost in different scenarios)
  2. Consider using AMP (see http://dpdk.org/doc/guides/prog_guide/multi_proc_support.html)
klnikita commented 8 years ago

Hello, Yes you are right, rte_eth/kni_rx/tx_burst() functions are not thread-safe.

For the kni part, we have one thread for the rx and a spinlock for the tx part. The spinlock is here because all our "forwarding" threads share the same kni device.

For the rteeth*_burst() part (the called in our "forwarding" threads), each thread has different queue, this configuration is stored in qconf. The queues related params of each qconf are set-up in init_port(), in this function we are setting a different rx and tx queue for each threads, so you shall not experience any threading issue.

Note that this part of the code is taken from DPDK's l3fwd example.

If it's not the case for you, I would be interested to know more about your setup.

klnikita commented 8 years ago

closing it since no new input.