On 7/3/26 12:25 PM, Samar Yadav wrote:
virtio_user secondary processes cannot communicate with the vhost
backend: the kick/call eventfds are opened by the primary and never
shared, so a secondary's queue notification writes to an invalid fd
and traffic stalls.

Share the fds over a dedicated virtio-user multiprocess channel. The
primary registers a process-wide MP action that returns a port's
kick/call fds (looked up by port name); a secondary requests them at
probe time, before the port is announced.

The received fds are stored in eth_dev->process_private, which is
per-process, instead of the primary-owned shared dev->kickfds and
dev->callfds arrays; the secondary data path notifies the backend using
its own kickfd. In the primary, the MP handler reads the fd arrays under
dev->mutex, and the teardown path takes the same lock while closing and
freeing them, so the two cannot race.

Also fix the pre-existing pthread_mutex_init(&dev->mutex, NULL) call in
virtio_user_dev_init(): POSIX requires PTHREAD_PROCESS_SHARED for a mutex
stored in shared memory regardless of which processes actually lock it;
use rte_thread_mutex_init_shared() as other multiprocess-aware drivers do.

Fixes: 1c8489da561b ("net/virtio-user: fix multi-process support")
Cc: [email protected]
Cc: [email protected]

Signed-off-by: Samar Yadav <[email protected]>
---
v3:
- Reorder new #includes: system headers first, then DPDK lib headers
   (alphabetized), then local virtio_* headers, per project convention.
- Name the "2" in eventfd count/index arithmetic (kick + call per queue)
   as VIRTIO_USER_EVENTFDS_PER_QUEUE instead of a bare literal. Leaves
   the pre-existing max_queue_pairs * 2 vring math untouched, since that
   is a different multiplier (vrings per queue pair) and already matches
   this file's existing style.
- Name the 5-second MP reply timeout in virtio_user_sync_eventfds() as
   VIRTIO_USER_MP_TIMEOUT_SEC with a comment on the rationale.

v2:
- Use rte_calloc() instead of rte_malloc() for the kick/call fd arrays
   in virtio_user_sync_eventfds() so allocation failures are cleaner and
   unset entries are zero-initialised before the explicit -1 sentinel loop.
   (Stephen Hemminger)
- Fix the pre-existing pthread_mutex_init(&dev->mutex, NULL) call in
   virtio_user_dev_init() to use rte_thread_mutex_init_shared(), which
   sets PTHREAD_PROCESS_SHARED as POSIX requires for a mutex in shared
   memory. Add #include <rte_thread.h> to pull in the declaration.
   (Stephen Hemminger)

  .mailmap                                      |   1 +
  .../net/virtio/virtio_user/virtio_user_dev.c  |  59 +++-
  .../net/virtio/virtio_user/virtio_user_dev.h  |  23 ++
  drivers/net/virtio/virtio_user_ethdev.c       | 276 +++++++++++++++++-
  4 files changed, 350 insertions(+), 9 deletions(-)

Applied to next-virtio/for-next-net.

Thanks,
Maxime

Reply via email to