<div dir="ltr">Agreed on the related pthread_mutex_init bug. <br>In this patch dev->mutex is only ever locked by the primary process:<br>the MP handler runs in the primary's EAL dispatch thread, and the<br>teardown path in virtio_user_dev_uninit() is primary-only. The<br>secondary communicates via rte_mp_request_sync() over the EAL socket<br>and never calls pthread_mutex_lock() on dev->mutex directly.<br><br>That said, POSIX requires PTHREAD_PROCESS_SHARED for a mutex stored in<br>shared memory regardless of which processes actually lock it, and other<br>DPDK multiprocess-aware code already uses rte_thread_mutex_init_shared()<br> for shared-memory mutexes. The pthread_mutex_init(&dev->mutex, NULL) call predates this <div>patch but since this patch explicitly documents the lock's role I will fix the<br>initialisation in v2:<br>-    pthread_mutex_init(&dev->mutex, NULL);<br>+        rte_thread_mutex_init_shared(&dev->mutex);<br><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Jun 24, 2026 at 8:46 PM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org">stephen@networkplumber.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 24 Jun 2026 08:57:41 +0000<br>
Samar Yadav <<a href="mailto:samaryadav5@gmail.com" target="_blank">samaryadav5@gmail.com</a>> wrote:<br>
<br>
> @@ -865,9 +913,15 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)<br>
>  <br>
>       rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME, dev);<br>
>  <br>
> +     /*<br>
> +      * Serialize closing/freeing the kick/call fd arrays against the MP<br>
> +      * handler, which reads them under the same lock to share them with<br>
> +      * secondary processes.<br>
> +      */<br>
> +     pthread_mutex_lock(&dev->mutex);<br>
>       virtio_user_dev_uninit_notify(dev);<br>
> -<br>
>       virtio_user_free_vrings(dev);<br>
> +     pthread_mutex_unlock(&dev->mutex);<br>
>  <br>
>       free(dev->ifname);<br>
<br>
Related bug. virtio_user is not initializing mutex as safe between<br>
processes. See rte_thread_mutex_init_shared() vs pthread_mutex_init()<br>
</blockquote></div>