Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation/sparse.txt: document context annotations for lock checking

The context feature of sparse is used with the Linux kernel sources to
check for imbalanced uses of locks. Document the annotations defined in
include/linux/compiler.h that tell sparse what to expect when a lock is
held on function entry, exit, or both.

Signed-off-by: Ed Cashin <ecashin@coraid.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Christopher Li <sparse@chrisli.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ed Cashin and committed by
Linus Torvalds
6e976631 8529091e

+18
+18
Documentation/sparse.txt
··· 49 49 __bitwise - noisy stuff; in particular, __le*/__be* are that. We really 50 50 don't want to drown in noise unless we'd explicitly asked for it. 51 51 52 + Using sparse for lock checking 53 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 + 55 + The following macros are undefined for gcc and defined during a sparse 56 + run to use the "context" tracking feature of sparse, applied to 57 + locking. These annotations tell sparse when a lock is held, with 58 + regard to the annotated function's entry and exit. 59 + 60 + __must_hold - The specified lock is held on function entry and exit. 61 + 62 + __acquires - The specified lock is held on function exit, but not entry. 63 + 64 + __releases - The specified lock is held on function entry, but not exit. 65 + 66 + If the function enters and exits without the lock held, acquiring and 67 + releasing the lock inside the function in a balanced way, no 68 + annotation is needed. The tree annotations above are for cases where 69 + sparse would otherwise report a context imbalance. 52 70 53 71 Getting sparse 54 72 ~~~~~~~~~~~~~~