Thread (6 messages) flat view 6 messages, 3 authors, 2021-02-03

Re: [dpdk-dev] [PATCH v2] vhost: fix vid allocation race

From: Maxime Coquelin <hidden>
Date: 2021-02-03 17:21:46


On 2/1/21 9:48 AM, Peng He wrote:
vhost_new_device might be called in different threads at the same time.
thread 1(config thread)
            rte_vhost_driver_start
               ->vhost_user_start_client
                   ->vhost_user_add_connection
                     -> vhost_new_device

thread 2(vhost-events)
	vhost_user_read_cb
           ->vhost_user_msg_handler (return value < 0)
             -> vhost_user_start_client
                 -> vhost_new_device

So there could be a case that a same vid has been allocated twice, or
some vid might be lost in DPDK lib however still held by the upper
applications.

Another place where race would happen is at the func *vhost_destroy_device*,
but after a detailed investigation, the race does not exist as long as
no two devices have the same vid: Calling vhost_destroy_devices in
different threads with different vids is actually safe.

Fixes: a277c715987 ("vhost: refactor code structure")
Reported-by: Peng He <redacted>
Signed-off-by: Fei Chen <redacted>
Reviewed-by: Zhihong Wang <redacted>
---
 lib/librte_vhost/vhost.c | 6 ++++++
 1 file changed, 6 insertions(+)
Applied to dpdk-next-virtio/main.

Thanks,
Maxime
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help