Thread (82 messages) 82 messages, 8 authors, 2021-03-23

Re: [PATCH v2 01/14] vfio: Remove extra put/gets around vfio_device->group

From: Max Gurtovoy <mgurtovoy@nvidia.com>
Date: 2021-03-16 11:16:30

On 3/13/2021 2:55 AM, Jason Gunthorpe wrote:
The vfio_device->group value has a get obtained during
vfio_add_group_dev() which gets moved from the stack to vfio_device->group
in vfio_group_create_device().

The reference remains until we reach the end of vfio_del_group_dev() when
it is put back.

Thus anything that already has a kref on the vfio_device is guaranteed a
valid group pointer. Remove all the extra reference traffic.

It is tricky to see, but the get at the start of vfio_del_group_dev() is
actually pairing with the put hidden inside vfio_device_put() a few lines
below.

A later patch merges vfio_group_create_device() into vfio_add_group_dev()
which makes the ownership and error flow on the create side easier to
follow.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
  drivers/vfio/vfio.c | 21 ++-------------------
  1 file changed, 2 insertions(+), 19 deletions(-)
Looks good,

Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help