DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: samar yadav <samaryadav5@gmail.com>
To: stephen@networkplumber.org
Cc: chenbox@nvidia.com, dev@dpdk.org, maxime.coquelin@redhat.com,
	samaryadav5@gmail.com, stable@dpdk.org, tiwei.bie@intel.com
Subject: Re: [PATCH] net/virtio-user: fix eventfd sharing in secondary process
Date: Fri, 26 Jun 2026 08:05:13 +0000	[thread overview]
Message-ID: <20260626080513.2371033-1-ysamar@vmware.com> (raw)
In-Reply-To: <20260624081610.780c4b0f@phoenix.local>

On Wed, 24 Jun 2026 08:16:10 -0700
Stephen Hemminger <stephen@networkplumber.org> wrote:

> > +	/*
> > +	 * Serialize closing/freeing the kick/call fd arrays against the MP
> > +	 * handler, which reads them under the same lock to share them with
> > +	 * secondary processes.
> > +	 */
> > +	pthread_mutex_lock(&dev->mutex);
> >  	virtio_user_dev_uninit_notify(dev);
> > -
> >  	virtio_user_free_vrings(dev);
> > +	pthread_mutex_unlock(&dev->mutex);
>
> Related bug. virtio_user is not initializing mutex as safe between
> processes. See rte_thread_mutex_init_shared() vs pthread_mutex_init()

Agreed on the related pthread_mutex_init bug.
In this patch dev->mutex is only ever locked by the primary process:
the MP handler runs in the primary's EAL dispatch thread, and the
teardown path in virtio_user_dev_uninit() is primary-only. The
secondary communicates via rte_mp_request_sync() over the EAL socket
and never calls pthread_mutex_lock() on dev->mutex directly.

That said, POSIX requires PTHREAD_PROCESS_SHARED for a mutex stored in
shared memory regardless of which processes actually lock it, and other
DPDK multiprocess-aware code already uses rte_thread_mutex_init_shared()
 for shared-memory mutexes. The pthread_mutex_init(&dev->mutex, NULL) call predates this 
patch but since this patch explicitly documents the lock's role I will fix the
initialisation in v2:

-	pthread_mutex_init(&dev->mutex, NULL);
+	rte_thread_mutex_init_shared(&dev->mutex);

Samar Yadav

  parent reply	other threads:[~2026-06-28 13:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24  8:57 [PATCH] net/virtio-user: fix eventfd sharing in secondary process Samar Yadav
2026-06-24 15:10 ` Stephen Hemminger
2026-06-26  7:41   ` Samar Yadav
2026-06-26  8:04   ` samar yadav
2026-06-24 15:16 ` Stephen Hemminger
2026-06-26  7:37   ` Samar Yadav
2026-06-26  8:05   ` samar yadav [this message]
2026-06-29 12:06     ` [PATCH v2] " Samar Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260626080513.2371033-1-ysamar@vmware.com \
    --to=samaryadav5@gmail.com \
    --cc=chenbox@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=tiwei.bie@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox