On Sat, Nov 05, 2022 at 03:44:57PM -0700, Anthony DeRossi wrote: > The open count of a device set is the sum of the open counts of all > devices in the set. Drivers can use this value to determine whether > shared resources are in use without tracking them manually or accessing > the private open_count in vfio_device. > > Signed-off-by: Anthony DeRossi <ajderossi@xxxxxxxxx> > --- > drivers/vfio/vfio_main.c | 11 +++++++++++ > include/linux/vfio.h | 1 + > 2 files changed, 12 insertions(+) > > +unsigned int vfio_device_set_open_count(struct vfio_device_set *dev_set) > +{ > + struct vfio_device *cur; > + unsigned int open_count = 0; I'd probably just make this a bool 'vfio_device_set_last_close()' And roll in the < 1 logic too Nothing will ever need to know the number of fds open across the set. But this is fine as written Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Jason