Re: blk-throttle: Correct the placement of smp_rmb()
From: Oleg Nesterov
Date: Wed Dec 08 2010 - 17:13:41 EST
On 12/08, Oleg Nesterov wrote:
>
> Unfortunately, I can't prove this. You can ask
> Paul McKenney if you want the authoritative answer.
Well. I think we should ask ;) This is interesting.
Paul could you please shed a light?
Suppose we have 2 variables, A = 0 and B = 0.
CPU0 does:
A = 1;
wmb();
B = 1;
CPU1 does:
B = 0;
mb();
if (A)
A = 2;
My understanding is: after that we can safely assume that
B == 1 || A == 2
IOW. Either CPU1 notices that A was changed, or CPU0 "wins"
and sets B = 1 "after" CPU1. But, it is not possible that
CPU1 clears B "after" it was set by CPU0 _and_ sees A == 0.
Is it true? I think it should be true, but can't prove. This
reminds me the old (and long) discussion about STORE-MB-LOAD.
Iirc, finally it was decided that
CPU0: CPU1:
A = 1; B = 1;
mb(); mb();
if (B) if (A)
printf("Yes"); printf("Yes");
should print "Yes" at least once. This looks very similar to
the the previous example.
Thanks,
Oleg.
--
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/