[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1401746280.3645.187.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Mon, 02 Jun 2014 14:58:00 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: "Michael S. Tsirkin" <mst@...hat.com>
Cc: linux-kernel@...r.kernel.org, David Miller <davem@...emloft.net>,
kvm@...r.kernel.org, virtualization@...ts.linux-foundation.org,
netdev@...r.kernel.org
Subject: Re: [PULL 2/2] vhost: replace rcu with mutex
On Tue, 2014-06-03 at 00:30 +0300, Michael S. Tsirkin wrote:
> All memory accesses are done under some VQ mutex.
> So lock/unlock all VQs is a faster equivalent of synchronize_rcu()
> for memory access changes.
> Some guests cause a lot of these changes, so it's helpful
> to make them faster.
>
> Reported-by: "Gonglei (Arei)" <arei.gonglei@...wei.com>
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
> ---
> drivers/vhost/vhost.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 78987e4..1c05e60 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -593,6 +593,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
> {
> struct vhost_memory mem, *newmem, *oldmem;
> unsigned long size = offsetof(struct vhost_memory, regions);
> + int i;
>
> if (copy_from_user(&mem, m, size))
> return -EFAULT;
> @@ -619,7 +620,14 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
> oldmem = rcu_dereference_protected(d->memory,
> lockdep_is_held(&d->mutex));
> rcu_assign_pointer(d->memory, newmem);
> - synchronize_rcu();
> +
> + /* All memory accesses are done under some VQ mutex.
> + * So below is a faster equivalent of synchronize_rcu()
> + */
> + for (i = 0; i < d->nvqs; ++i) {
> + mutex_lock(&d->vqs[i]->mutex);
> + mutex_unlock(&d->vqs[i]->mutex);
> + }
> kfree(oldmem);
> return 0;
> }
This looks dubious
What about using kfree_rcu() instead ?
translate_desc() still uses rcu_read_lock(), its not clear if the mutex
is really held.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists