On Wed, Sep 28, 2011 at 11:08 AM, Stephan Diestelhorst <stephan.diestelhorst@xxxxxxx> wrote: > > I must have missed the part when this turned into the propose-the- > craziest-way-that-this-still-works.contest :) So doing it just with the "lock addb" probably works fine, but I have to say that I personally shudder at the "surround the locked addb by reads from the word, in order to approximate an atomic read of the upper bits". Because what you get is not really an "atomic read of the upper bits", it's a "ok, we'll get the worst case of somebody modifying the upper bits at the same time". Which certainly should *work*, but from a conceptual standpoint, isn't it just *much* nicer to say "we actually know *exactly* what the upper bits were". But I don't care all *that* deeply. I do agree that the xaddw trick is pretty tricky. I just happen to think that it's actually *less* tricky than "read the upper bits separately and depend on subtle ordering issues with another writer that happens at the same time on another CPU". So I can live with either form - as long as it works. I think it might be easier to argue that the xaddw is guaranteed to work, because all values at all points are unarguably atomic (yeah, we read the lower bits nonatomically, but as the owner of the lock we know that nobody else can write them). Linus -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html