No it's:
t1 = rw->pre_sequence
t2 = rw->post_sequence
t1 += 1;
t2 += 2;
rw->pre_sequence = t1
wmb()
xtimensec = xtime.tv_nsec
wmb()
rw->post_sequence = t2
you're missing xtimensec is a write.
or this if you prefer:
spin_lock() / now xtime can't change under us
t1 = rw->pre_sequence
t2 = rw->post_sequence
t3 = xtime.tv_nsec
t1 += 1;
t2 += 2;
rw->pre_sequence = t1
wmb()
xtimensec = t3
wmb()
rw->post_sequence = t2
spin_unlock() / now xtime can change again
and the above is the optimal implementation of the write-side. We
definitely don't want to forbid those reoderings. if gcc or cpu thinks
it's worthwhile they must be allowed to optimize it since it's legal.
I believe wmb() is correct, and mb() is overkill.
Andrea
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/