[davem: patch for you at the bottom to Documentation/atomic_ops.txt ]
On Tue, Aug 28, 2007 at 02:38:35PM -0400, Mathieu Desnoyers wrote:
...
Yeah, I didn't expect many users of local_t.
The search for atomic_t usage in DEFINE_PER_CPU was an attempt to
find other potential candidates which could be local_t.
Is there any other programmatic way we could look for code which
could (or should) be using local_t?
Ok...probably not such a good example then. :)
...
...
I've read this before and understand how LOCK works. This isn't helpful
since I want a description of the behavior without LOCK.
I think what I'm looking for but don't know if it's true:
The cmpxchg (for example) at the kernel process context will not
clobber or be clobbered by a cmpxchg done to the same local_t
performed at the kernel interrupt context by the same CPU.
If that's not true, then it would be good to add that as another
restriction to usage.
ok.
...
Perfect! Ship it! ;)
Can you submit a patch to add the above to Documentation/local_ops.txt ?
...
heh...I think DaveM will want it in git or universal patch form. :)
Patch appended below.
thanks!
grant
Add document reference and simple use example of local_t.
Signed-off-by: Grant Grundler <grundler@parisc-linux.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
--- linux-2.6.22.5-ORIG/Documentation/atomic_ops.txt 2007-08-22 16:23:54.000000000 -0700
+++ linux-2.6.22.5-ggg/Documentation/atomic_ops.txt 2007-08-28 22:57:26.000000000 -0700
@@ -7,6 +7,11 @@
maintainers on how to implement atomic counter, bitops, and spinlock
interfaces properly.
+ atomic_t should be used to provide a type with update primitives
+executed atomically from any CPU. If the counter is per CPU and only
+updated by one CPU, local_t is probably more appropriate. Please see
+Documentation/local_ops.txt for the semantics of local_t.
+
The atomic_t type should be defined as a signed integer.
Also, it should be made opaque such that any kind of cast to a normal
C integer type will fail. Something like the following should
-