Re: [PATCH 08/14] hrtimer: Allow hrtimer::function() to free the timer

From: Peter Zijlstra
Date: Thu Jun 11 2015 - 03:31:52 EST


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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/