public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Documentation/sparse.txt: document context annotations for lock checking
@ 2012-10-18 14:27 Ed Cashin
  2012-10-18 23:09 ` Josh Triplett
  2012-10-19 22:14 ` Christopher Li
  0 siblings, 2 replies; 3+ messages in thread
From: Ed Cashin @ 2012-10-18 14:27 UTC (permalink / raw)
  To: akpm
  Cc: ecashin, josh, rob, linux-doc, linux-kernel, linux-sparse, sam,
	sparse, ak

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>
---
 Documentation/sparse.txt |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/Documentation/sparse.txt b/Documentation/sparse.txt
index 4909d41..eceab13 100644
--- a/Documentation/sparse.txt
+++ b/Documentation/sparse.txt
@@ -49,6 +49,24 @@ be generated without __CHECK_ENDIAN__.
 __bitwise - noisy stuff; in particular, __le*/__be* are that.  We really
 don't want to drown in noise unless we'd explicitly asked for it.
 
+Using sparse for lock checking
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The following macros are undefined for gcc and defined during a sparse
+run to use the "context" tracking feature of sparse, applied to
+locking.  These annotations tell sparse when a lock is held, with
+regard to the annotated function's entry and exit.
+
+__must_hold - The specified lock is held on function entry and exit.
+
+__acquires - The specified lock is held on function exit, but not entry.
+
+__releases - The specified lock is held on function entry, but not exit.
+
+If the function enters and exits without the lock held, acquiring and
+releasing the lock inside the function in a balanced way, no
+annotation is needed.  The tree annotations above are for cases where
+sparse would otherwise report a context imbalance.
 
 Getting sparse
 ~~~~~~~~~~~~~~
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation/sparse.txt: document context annotations for lock checking
  2012-10-18 14:27 [PATCH] Documentation/sparse.txt: document context annotations for lock checking Ed Cashin
@ 2012-10-18 23:09 ` Josh Triplett
  2012-10-19 22:14 ` Christopher Li
  1 sibling, 0 replies; 3+ messages in thread
From: Josh Triplett @ 2012-10-18 23:09 UTC (permalink / raw)
  To: Ed Cashin
  Cc: akpm, rob, linux-doc, linux-kernel, linux-sparse, sam, sparse, ak

On Thu, Oct 18, 2012 at 07:27:26AM -0700, Ed Cashin wrote:
> 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>

>  Documentation/sparse.txt |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/sparse.txt b/Documentation/sparse.txt
> index 4909d41..eceab13 100644
> --- a/Documentation/sparse.txt
> +++ b/Documentation/sparse.txt
> @@ -49,6 +49,24 @@ be generated without __CHECK_ENDIAN__.
>  __bitwise - noisy stuff; in particular, __le*/__be* are that.  We really
>  don't want to drown in noise unless we'd explicitly asked for it.
>  
> +Using sparse for lock checking
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The following macros are undefined for gcc and defined during a sparse
> +run to use the "context" tracking feature of sparse, applied to
> +locking.  These annotations tell sparse when a lock is held, with
> +regard to the annotated function's entry and exit.
> +
> +__must_hold - The specified lock is held on function entry and exit.
> +
> +__acquires - The specified lock is held on function exit, but not entry.
> +
> +__releases - The specified lock is held on function entry, but not exit.
> +
> +If the function enters and exits without the lock held, acquiring and
> +releasing the lock inside the function in a balanced way, no
> +annotation is needed.  The tree annotations above are for cases where
> +sparse would otherwise report a context imbalance.
>  
>  Getting sparse
>  ~~~~~~~~~~~~~~
> -- 
> 1.7.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation/sparse.txt: document context annotations for lock checking
  2012-10-18 14:27 [PATCH] Documentation/sparse.txt: document context annotations for lock checking Ed Cashin
  2012-10-18 23:09 ` Josh Triplett
@ 2012-10-19 22:14 ` Christopher Li
  1 sibling, 0 replies; 3+ messages in thread
From: Christopher Li @ 2012-10-19 22:14 UTC (permalink / raw)
  To: Ed Cashin; +Cc: akpm, josh, rob, linux-doc, linux-kernel, linux-sparse, sam, ak

On Thu, Oct 18, 2012 at 7:27 AM, Ed Cashin <ecashin@coraid.com> wrote:
> 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>

Signed-off-by: Christopher Li <sparse@chrisli.org>

Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-19 22:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-18 14:27 [PATCH] Documentation/sparse.txt: document context annotations for lock checking Ed Cashin
2012-10-18 23:09 ` Josh Triplett
2012-10-19 22:14 ` Christopher Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox