Messages in this thread | | | Date | Thu, 11 Jun 2015 09:31:28 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH 08/14] hrtimer: Allow hrtimer::function() to free the timer |
| |
On Wed, Jun 10, 2015 at 06:04:44PM +0200, Oleg Nesterov wrote: > If we rely on the "locking" semantics of seqcount_t, this doesn't really > differ from > > spinlock_t LOCK; > bool X = true, Y = false; > > void read(void) > { > bool x, y; > > spin_lock(LOCK); > x = X; y = Y; > spin_unlock(LOCK); > > BUG_ON(!x && !y); > } > > void write(void) > { > Y = true; > > spin_lock(LOCK); > spin_unlock(LOCK); > > X = false; > }
So when I first saw that I went, wait what?
Because I looked at it like:
Y = true; ACQUIRE RELEASE X = false;
And we both know that is not ordered at all.
But its the actual lock semantics that make it work, we cannot acquire until the other completes, at which time the acquire matches its release and things end up ordered again.
And its exactly that part we lost in our transformation C yesterday.
In any case, breakfast time, will go do the patches shortly.
| |