From: Jason Wang <jasowang@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: mst@redhat.com, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH V2 3/3] vhost: access vq metadata through kernel virtual address
Date: Sat, 29 Dec 2018 20:41:33 +0800 [thread overview]
Message-ID: <86418701-d57d-70a4-6f4c-25598b2c077e@redhat.com> (raw)
In-Reply-To: <20181228.113444.2162917443074434767.davem@davemloft.net>
On 2018/12/29 上午3:34, David Miller wrote:
> From: Jason Wang <jasowang@redhat.com>
> Date: Fri, 28 Dec 2018 15:55:37 +0800
>
>> +static int vhost_invalidate_vmap(struct vhost_virtqueue *vq,
>> + struct vhost_vmap *map,
>> + unsigned long uaddr,
>> + unsigned long start,
>> + unsigned long end,
>> + bool blockable)
>> +{
>> + if (start < uaddr && end >= uaddr) {
>> + if (!blockable)
>> + return -EAGAIN;
>> + mutex_lock(&vq->mutex);
>> + if (map->addr)
>> + vunmap(map->unmap_addr);
>> + map->addr = NULL;
>> + map->unmap_addr = NULL;
>> + mutex_unlock(&vq->mutex);
>> + }
>> +
>> + return 0;
>> +}
> What are the rules for these invalidate operations?
>
> Can there be partial overlaps? If so, wouldn't you need some way of
> keeping track of the partially overlapping unmaps so that once all of
> the invalidates covering the range occur you properly cleanup and do
> the vunmap()?
Yes, there can be partial overlap, so the check is buggy. We will remap
the whole range in vq_meta_prefetch() before datapath path try to use
them, so there's no need to track partial mapping here.
I spot another bug that the caller will access vq->avail without
synchronized with vhost ioctl. Since we don't want to hold vq mutex for
each invalidation, I will tear down MMU notifier during vhost ioctl to
make sure invalidation request can access them without hold vq mutex.
Thanks
prev parent reply other threads:[~2018-12-29 12:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-28 7:55 [RFC PATCH V2 0/3] vhost: accelerate metadata access through vmap() Jason Wang
2018-12-28 7:55 ` [RFC PATCH V2 1/3] vhost: generalize adding used elem Jason Wang
2018-12-28 7:55 ` [RFC PATCH V2 2/3] vhost: fine grain userspace memory accessors Jason Wang
2018-12-28 7:55 ` [RFC PATCH V2 3/3] vhost: access vq metadata through kernel virtual address Jason Wang
2018-12-28 19:34 ` David Miller
2018-12-29 12:41 ` Jason Wang [this message]
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=86418701-d57d-70a4-6f4c-25598b2c077e@redhat.com \
--to=jasowang@redhat.com \
--cc=davem@davemloft.net \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).