From: malte.vesper@postgrad.manchester.ac.uk (Malte Vesper) Date: Thu, 26 Mar 2015 17:47:38 +0000 Subject: Atomics and memory barriers Message-ID: <5514463A.2010109@postgrad.manchester.ac.uk> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hello, I have been reading up on atomics and struggle to grasp when exactly I need explicit memory barriers. While the documentation (Documentat/atomic_ops.txt), talks about operations needing explicit barriers both sides, I assume this is only half true. If I for instance only want to use an atomic as a flag to show that some operation is complete I reckon that a barrier before is sufficient. Furthermore I found the following lines: 288 If a caller requires memory barrier semantics around an atomic_t 289 operation which does not return a value, a set of interfaces are 290 defined which accomplish this: 291 292 void smp_mb__before_atomic(void); 293 void smp_mb__after_atomic(void); note how it refers to "operation which does not return a value", why can't I use these for atomic operations that do return a value? What should I use instead, normal barriers like mb? Please enlighten me Malte -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150326/581e805b/attachment.html