From: Johannes Berg <johannes@sipsolutions.net>
To: David Brownell <david-b@pacbell.net>
Cc: linux-sparse@vger.kernel.org
Subject: Re: sparse context warning problem ...
Date: Tue, 13 May 2008 23:52:48 +0200 [thread overview]
Message-ID: <1210715568.4279.35.camel@johannes.berg> (raw)
In-Reply-To: <1210466447.3646.3.camel@johannes.berg> (sfid-20080511_024133_180993_8E974B71)
[-- Attachment #1: Type: text/plain, Size: 1832 bytes --]
> > static void
> > finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status)
> > __releases(ohci->lock)
> > __acquires(ohci->lock)
> > But current versions of "sparse" complain (wrongly):
> >
> > drivers/usb/host/ohci-q.c:66:2: warning: context imbalance in 'finish_urb': __context__ statement expected different context
> > drivers/usb/host/ohci-q.c:66:2: context '<noident>': wanted >= 0, got -1
> However, I took __releases and __acquires to mean that this function
> *changed* the context, doing both doesn't really make much sense. I
> think the function should actually be declared
>
> static void
> finish_urb(...)
> __requires(ohci->lock)
> {...}
>
> where __requires is (for sparse) defined as
>
> #define __requires(x) __attribute__((context(x,1,1)))
Actually, it turns out my analysis was completely wrong.
This is exactly the issue I pointed out in my other mail. You have:
__acquires(ohci->lock)
^^^^^^^^^^
but, on the other hand:
spin_unlock (&ohci->lock);
^
I think you can fix this particular case by adding the & in the
__acquires(), but that will only work for UP, for actual spinlocks my
other patches will be needed, because w/o my patches sparse will, on
SMP, not be able to see that
void __lockfunc _spin_lock(spinlock_t *lock) __acquires(lock);
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.
Ultimately, this whole problem comes from the fact that sparse accepted
adding an expression, documented it, but never complained if they
slightly mismatched as above.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2008-05-13 21:53 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 [this message]
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
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=1210715568.4279.35.camel@johannes.berg \
--to=johannes@sipsolutions.net \
--cc=david-b@pacbell.net \
--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).