On Fri, Dec 08, 2023 at 08:09:34PM +0000, Jim Harris wrote: > On Fri, Dec 08, 2023 at 03:41:59PM -0400, Jason Gunthorpe wrote: > > On Fri, Dec 08, 2023 at 05:07:22PM +0000, Jim Harris wrote: > > > > > > Maybe for now we just whack this specific mole with a separate mutex > > > for synchronizing access to sriov->num_VFs in the sysfs paths? > > > Something like this (tested on my system): > > > > TBH, I don't have the time right now to unpack this locking > > mystery. Maybe Leon remembers? > > > > device_lock() gets everywhere and does a lot of different stuff, so I > > would be surprised if it was so easy.. > > The store() side still keeps the device_lock(), it just also acquires this > new sriov lock. So store() side should observe zero differences. The only > difference is now the show() side can acquire just the more-granular lock, > since it is only trying to synchronize on sriov->num_VFs with the store() > side. But maybe I'm missing something subtle here... Oh if that is the only goal then probably a READ_ONCE is fine Jason