Re: [PATCH 14/14] vfio/mdev: add mdev available instance checking to the core

Christoph Hellwig
2022-07-19T14:48:16Z

On Mon, Jul 18, 2022 at 10:00:26PM -0400, Eric Farman wrote:
> > + if (!drv->get_available) {
> > + if (atomic_dec_and_test(&parent->available_instances))
> > {
>
> Ah, subtle change between v5 and v6 to use atomics. As vfio-ccw only
> has 1 available instance per mdev, this breaks us. Did you mean
> atomic_dec_if_positive() ?

Yes, this should have been atomic_dec_if_positive. Or just an open
coded atomic_dec + atomic_read a the only reason to use an atomic is
for the sysfs file that reads it outside the lock.