Message ID | 20210119045920.447-5-xieyongji@bytedance.com (mailing list archive) |
---|---|
State | RFC |
Headers | show |
Series | Introduce VDUSE - vDPA Device in Userspace | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 2021/1/19 下午12:59, Xie Yongji wrote: > Introduce a mutex to protect vhost device iotlb from > concurrent access. > > Fixes: 4c8cf318("vhost: introduce vDPA-based backend") > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > --- > drivers/vhost/vdpa.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 448be7875b6d..4a241d380c40 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -49,6 +49,7 @@ struct vhost_vdpa { > struct eventfd_ctx *config_ctx; > int in_batch; > struct vdpa_iova_range range; > + struct mutex mutex; Let's use the device mutex like what vhost_process_iotlb_msg() did. Thanks > }; > > static DEFINE_IDA(vhost_vdpa_ida); > @@ -728,6 +729,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, > if (r) > return r; > > + mutex_lock(&v->mutex); > switch (msg->type) { > case VHOST_IOTLB_UPDATE: > r = vhost_vdpa_process_iotlb_update(v, msg); > @@ -747,6 +749,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, > r = -EINVAL; > break; > } > + mutex_unlock(&v->mutex); > > return r; > } > @@ -1017,6 +1020,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) > return minor; > } > > + mutex_init(&v->mutex); > atomic_set(&v->opened, 0); > v->minor = minor; > v->vdpa = vdpa;
On Wed, Jan 20, 2021 at 11:44 AM Jason Wang <jasowang@redhat.com> wrote: > > > On 2021/1/19 下午12:59, Xie Yongji wrote: > > Introduce a mutex to protect vhost device iotlb from > > concurrent access. > > > > Fixes: 4c8cf318("vhost: introduce vDPA-based backend") > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > > --- > > drivers/vhost/vdpa.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > index 448be7875b6d..4a241d380c40 100644 > > --- a/drivers/vhost/vdpa.c > > +++ b/drivers/vhost/vdpa.c > > @@ -49,6 +49,7 @@ struct vhost_vdpa { > > struct eventfd_ctx *config_ctx; > > int in_batch; > > struct vdpa_iova_range range; > > + struct mutex mutex; > > > Let's use the device mutex like what vhost_process_iotlb_msg() did. > Looks fine. Thanks, Yongji
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 448be7875b6d..4a241d380c40 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -49,6 +49,7 @@ struct vhost_vdpa { struct eventfd_ctx *config_ctx; int in_batch; struct vdpa_iova_range range; + struct mutex mutex; }; static DEFINE_IDA(vhost_vdpa_ida); @@ -728,6 +729,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, if (r) return r; + mutex_lock(&v->mutex); switch (msg->type) { case VHOST_IOTLB_UPDATE: r = vhost_vdpa_process_iotlb_update(v, msg); @@ -747,6 +749,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, r = -EINVAL; break; } + mutex_unlock(&v->mutex); return r; } @@ -1017,6 +1020,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) return minor; } + mutex_init(&v->mutex); atomic_set(&v->opened, 0); v->minor = minor; v->vdpa = vdpa;
Introduce a mutex to protect vhost device iotlb from concurrent access. Fixes: 4c8cf318("vhost: introduce vDPA-based backend") Signed-off-by: Xie Yongji <xieyongji@bytedance.com> --- drivers/vhost/vdpa.c | 4 ++++ 1 file changed, 4 insertions(+)