]> git.baikalelectronics.ru Git - kernel.git/commit
vhost: use mmgrab() instead of mmget() for non worker device
authorJason Wang <jasowang@redhat.com>
Fri, 29 May 2020 08:02:59 +0000 (16:02 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 4 Jun 2020 19:36:51 +0000 (15:36 -0400)
commit308c633530450676cd865255643f51971e4db2aa
tree45625f17916f0f8c9ae5cdd2b1acbd8404bb90aa
parenta611fa5c2a0cec9d18758d600ef758eed537ee6a
vhost: use mmgrab() instead of mmget() for non worker device

For the device that doesn't use vhost worker and use_mm(), mmget() is
too heavy weight and it may brings troubles for implementing mmap()
support for vDPA device.

This is because, an reference to the address space was held via
mm_get() in vhost_dev_set_owner() and an reference to the file was
held in mmap(). This means when process exits, the mm can not be
released thus we can not release the file.

This patch tries to use mmgrab() instead of mmget(), which allows the
address space to be destroy in process exit without releasing the mm
structure itself. This is sufficient for vDPA device which pin user
pages and does not depend on the address space to work.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20200529080303.15449-3-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c