linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-sparse@vger.kernel.org, Josh Triplett <josh@freedesktop.org>
Subject: Re: sparse context warning problem ...
Date: Thu, 29 May 2008 02:39:13 -0700	[thread overview]
Message-ID: <200805290239.13436.david-b@pacbell.net> (raw)
In-Reply-To: <1212050823.16917.37.camel@johannes.berg>

On Thursday 29 May 2008, Johannes Berg wrote:
> 
> > > means to lock "&ohci->lock" when doing "spin_lock(&ohci->lock);" but
> > > will treat it as locking the abstractly-named "lock" context, while on
> > > UP/no-preempt the "spin_lock" macro is expanded by the preprocessor and
> > > you will get "&ohci->lock" as the expression.
> > 
> > Yeah, well the lock being acquired or released *IS* "ohci->lock",
> > but the spinlock calls don't take the lock, they take pointers
> > to it!
> > 
> > If you were to argue that understanding pointers like that is a
> > lot to demand of "sparse", I might agree.  But that won't change
> > the fact that locks themselves are not pointers to locks.  ;)
> 
> Yeah, I agree the locks aren't pointers, but really, it is a lot easier
> for you to do that annotation than for sparse to figure it out.

I was fairly sure you'd argue that!


> I blame these problems on whoever implemented sparse context tracking in
> the first place, documented the optional first expression parameter and
> then didn't write any code for looking at the expression at all.

Yeah, that Torvalds clown is always leaving stuff unfinished.  ;)


> static inline void netif_tx_lock_bh(struct net_device *dev)
> 	__acquires(&dev->_xmit_lock)
> {
>         spin_lock_bh(&dev->_xmit_lock);
>         dev->xmit_lock_owner = smp_processor_id();
> }
> 
> Conceptually, I think this is cleaner because inlines are treated more
> like real functions then, but you may disagree.

I disagree.  They *are* real functions, so treating them
as such is the only reasonable option!

(Note by the way a convenience there:  the lock is easily
described using just the function parameters.  I suspect
that will be common, but not always true ...)


Will it be possible to put annotations on methods declared
in ops vectors?  Just today I was cleaning up some locking
issues and had to start using a lock.  But I couldn't find
any clear statement about the call contexts for some of the
new lock/unlock calls ... I had to go look at other drivers
to see an answer (and hope they weren't buggy).  It would
have been nicer to just have "sparse" tell me the answers.

(If right now that seems more like a research problem, I'd
not be too surprised.  But I'd like to think that someday
it should be practical to have kernel lockdep tools tell
us about such things, and have such constraints verified
during builds.)

 
> The status quo, however, has turned out to be unacceptable to users
> because of the spinlock problem I mentioned above. Can we, based on an
> evaluation of the problems I just outlined, either apply the patches I'm
> about to send, or revert them to go back to the completely unchecked
> contexts?

Haven't seen the patches, but in principle I have no objection
to finishing the lock context code.  Fixing all the kernel code
to get better lock annotations will take time, but that's OK.

What's probably more important right now is to make sure the
annotations are simple and correct, so they can be built on
over time.

- Dave



  reply	other threads:[~2008-05-29  9:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-11  0:24 sparse context warning problem David Brownell
2008-05-11  0:40 ` Johannes Berg
2008-05-11  3:18   ` David Brownell
2008-05-11  9:46     ` Johannes Berg
2008-05-13 21:52   ` Johannes Berg
2008-05-14 13:58     ` David Brownell
2008-05-14 14:06       ` Johannes Berg
2008-05-29  8:47       ` Johannes Berg
2008-05-29  9:39         ` David Brownell [this message]
2008-05-29  9:54           ` Johannes Berg

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=200805290239.13436.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=johannes@sipsolutions.net \
    --cc=josh@freedesktop.org \
    --cc=linux-sparse@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).