[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/4] device-core: use atomic_set on .realized property
From: |
Maxim Levitsky |
Subject: |
Re: [PATCH 3/4] device-core: use atomic_set on .realized property |
Date: |
Mon, 04 May 2020 14:36:21 +0300 |
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.
>
> Paolo
>
I was under impression that atomic_set implies a barrier, but now indeed it
looks like it doesn't.
I''l read upon this a bit and then send an updated patch.
For RCU, sorry for not knowing the details yet, I was under impression that for
reads you need the rcu read lock
and for writes you also need the RCU read lock, since I first would read then
write the data,
plus follow the RCU rule of the update (read, copy, update),
with an atomic swap of a pointer to point to the new copy, and finally register
a callback with RCU so it frees the old
copy when all the readers of the old copy are guaranteed to be gone.
Best regards,
Maxim Levitsky