All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: Patches that add sparse annotations
Date: Wed, 18 Apr 2012 18:41:56 +0000	[thread overview]
Message-ID: <20120418184156.GM6498@mwanda> (raw)
In-Reply-To: <1334759646-16415-1-git-send-email-emilgoode@gmail.com>

On Wed, Apr 18, 2012 at 04:34:06PM +0200, Emil Goode wrote:
> Hello all,
> 
> I just wanted to get your opinion on if maintainers will find the
> patch bellow (and other like it) to be annoying or somewhat useful?
> 
> In the following lwn article Linus is saying that if you intend to
> grab a lock in one function and release it in another, you need to
> inform sparse of this by adding annotations to the functions.
> 
> http://lwn.net/Articles/109066/
> 
> The patch silences the following sparse warnings:
> arch/x86/kernel/apic/io_apic.c:1115:6: warning: 
> context imbalance in 'lock_vector_lock' - wrong count at exit
> arch/x86/kernel/apic/io_apic.c:1123:6: warning: 
> context imbalance in 'unlock_vector_lock' - unexpected unlock

If you have to ask, then probably it's not worth it.

If you don't run Sparse then this warning doesn't affect you.
I run Sparse every day but I only look at new warnings so this
warning doesn't affect me.  If I did see the warning message, it
wouldn't be hard to see why it was there and ignore it.

The downside of sending the patch is that it is a bit of work for
the maintainer to review and apply.  It's also two extra lines of
code that they might not care about or might think is ugly.

Adding the annotations to the .c file silences the warning, but it
doesn't add any more information for finding future bugs.  To do
that you would have to add it to .h file as well.  (But don't do
that because it will find two false positives and zero real bugs).

Also the format isn't right.  It should be:

void lock_vector_lock(void)
__acquires(vector_lock)
{

Your way works, but it looks weird.

Of course, there are times when adding Sparse annotations is the
correct thing to do.  You when that is if you feel it in your heart.
:P

regards,
dan carpenter

PS. if you are looking for inspiration, you could just do what I do
and read Axel Lin's postings to LKML and copy his ideas.


  reply	other threads:[~2012-04-18 18:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-18 14:34 Patches that add sparse annotations Emil Goode
2012-04-18 18:41 ` Dan Carpenter [this message]
2012-04-18 19:03 ` Marcos Souza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120418184156.GM6498@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.