Re: [PATCH RFC tip/core/rcu] rcu: direct algorithmic SRCUimplementation

From: Peter Zijlstra
Date: Thu Feb 16 2012 - 09:58:58 EST


On Thu, 2012-02-16 at 09:52 -0500, Mathieu Desnoyers wrote:
> Ah, so this is what I missed: the context switch has its lock/unlock
> pair, the following migration is performed under its own lock/unlock
> pair, and the following context switch also has its lock/unlock pair. So
> yes, this should be sufficient to act as a full memory barrier.

In fact it typically looks like:

LOCK(rq0->lock)
switch-from-A
UNLOCK(rq0->lock);

LOCK(rq0->lock);
LOCK(rq1->lock);
migrate-A
UNLOCK(rq1->lock);
UNLOCK(rq0->lock);

LOCK(rq1->lock);
switch-to-A
UNLOCK(rq1->lock);

the migrate taking both locks involved guarantees that the switch-to
always comes _after_ the switch_from. The migrate might be performed on
a completely unrelated cpu although typically it would be either the old
(push) or the new (pull).
--
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/