On Mon, 2020-05-04 at 13:22 +0200, Paolo Bonzini wrote: > On 04/05/20 12:45, Stefan Hajnoczi wrote: > > > @@ -983,7 +983,7 @@ static void device_set_realized(Object *obj, bool > > > value, Error **errp) > > > } > > > > > > assert(local_err == NULL); > > > - dev->realized = value; > > > + atomic_set(&dev->realized, value); > > > > A memory barrier is probably needed so that the atomic_read() thread > > sees up-to-date dev fields. > > Yes, it should be a store-release for the false->true case. The > true->false case probably doesn't matter as much.
On second thought, I think both cases matter, after I examined the device removal case. In device removal case, the device is first un-realized and then removed from the bus, so just like in device hotplug case, the scsi_device_find can give you an unrealized device. I will change this patch to set .realized to false at the start (if needed) of the function and to true at the end (also if needed) Will atomic_rcu_set work? or atomic_store_release? (Both are the same thing, but former documents the purpose of using with RCU. Best regards, Maxim Levitsky > > Paolo >