James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote: > On Thu, 2008-07-03 at 09:12 +0200, Elias Oltmanns wrote: >> Matthew Wilcox <matthew@xxxxxx> wrote: [...] >> > The assumption we make (and it is believed to be true on all SMP systems) >> > is that a write to a naturally aligned memory location that is sized <= >> > sizeof(long) is atomic. That is, a reader will get either the previous >> > value or the subsequent value, not a mixture. The RCU code relies >> > heavily on this assumption. >> >> Does that mean that where ever I have >> >> spin_lock_irqsave(some_lock, flags); >> var = some_val; >> spin_unlock_irqrestore(some_lock, flags); >> >> I could just as well discard the locking provided that >> sizeof(var) <= sizeof(long) >> because the assignment of some_val to var will be atomic anyway? > > I think you're still confused about the difference between integral > observation of values and serialisation. > > Assignment is always integral. In your example above anything observing > the variable always sees either the previous value or the one you set it > to, nothing else. So, if all you're doing is setting a flag and > clearing it (as in setting it to an integral value, not setting it via a > bit operation) and checking it, no locking is needed. It's when you > start doing operations on variables that require serialisation, or the > variables themselves are absolute indicators of events that need > serialisation that you start having to introduce locking. Right. Thank you very much for the clarification. Regards, Elias -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html