On Fri, Jan 20, 2023 at 02:00:26PM +0000, Liu, Yi L wrote: > Say in the same time, we have thread B closes device, it will hold > group_lock first and then calls kvm_put_kvm() which is the last > reference, then it would loop the kvm-device list. Currently, it is > not holding kvm_lock. But it also manipulating the kvm-device list, > should it hold kvm_lock? No. When using refcounts if the refcount is 0 it guarantees there are no other threads that can possibly touch this memory, so any locks internal to the memory are not required. Jason