linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Christopher Li <sparse@chrisli.org>
Cc: Josh Triplett <josh@freedesktop.org>,
	Philipp Reisner <philipp.reisner@linbit.com>,
	linux-sparse@vger.kernel.org,
	Harvey Harrison <harvey.harrison@gmail.com>
Subject: Re: [PATCH 6/9 v2] check context expressions as expressions
Date: Wed, 10 Sep 2008 23:34:00 +0200	[thread overview]
Message-ID: <1221082440.3804.40.camel@johannes.berg> (raw)
In-Reply-To: <70318cbf0809101221n53dd06c2x19c68a1df336cb35@mail.gmail.com> (sfid-20080910_212133_681576_089D6D0F)

[-- Attachment #1: Type: text/plain, Size: 3953 bytes --]

On Wed, 2008-09-10 at 12:21 -0700, Christopher Li wrote:

> Nah, you pretty should never need to do that.
> Ident equal should just need to compare ident1 == ident2.
> 
> All ident has been hashed. Same ident, should show up
> as same pointer. Doing strncmp again is unnecessary.
> 
> I feel that this patch  is adding too much hack to the
> sparse front end. At the very least, can you
> just change __context__ parsing to accept symbol expression
> and the let the checking back end to do the code motions
> stuff?

Can you explain?

> I haven't study the new context checking very carefully.
> I actually prefer the Linus's  old simple context checking.
> Yes, that does not distinguish which symbols taking the lock.
> But other than that it is working and counting the number
> correctly. And, it is very simple.

Well, yeah, it's very simple, and that doesn't help. And it's not about
cross-function checking either:

extern spinlock_t a;

spin_lock(&a);
rcu_read_unlock()

will not result in an error which is a pain.

> The new context checking seems able to do more features.
> But it has too many sore spots. I vote for back it out.

I don't care, I don't have any more cycles to burn on this. For all I'm
concerned it works pretty well and is a HUGE improvement over the
current sparse which
 * doesn't tell you what line the error really is in, it only warns
   about the last line of the function
 * isn't able to check different contexts despite documenting it
   (see above)

> Instead of keep adding more hacks to fix up the problem. I
> think we should step back and ask ourselves what do we really
> want to achieve.

See above.

> The fundamental problem I saw here is that, sparse does not
> support cross function checking. There is no good way to save
> some analyzed result for some function and used it later by other
> function. That is why we actually have to put __context__
> around so many functions. The __context__ describe what
> these functions in forms of source code annotation. There is
> only so much we can do with source code annotations.
> I am not saying that annotation is not useful. I agree source
> code annotation helps on the source code reading. But it
> shouldn't limit checker only use the annotations. The checker
> should be able to draw intelligent conclusions, by looking the
> the function source code itself.

Actually, I kinda disagree. Annotating *each and every function* with
the locks it requires is _very_ useful, not just for sparse but also for
human readers of the code. Hence, I don't just want sparse to check
across functions, I want to be able to tell people what to do for
calling a given function as well. The fact that sparse can check my
annotations is great, but having them would be useful without that as
well.

> e.g. Why do we have to annotate foo_lock(&bar->lock) will take a lock
> on &bar->lock? The checker should be able to find out foo_lock() just
> callers some lower level locking functions. For example,  let say if we
> can force foo to be inlined into the caller even foo is not declared as
> inline. Then there is no need to annotate foo itself. The caller see
> exactly what foo does.

It used to be like that. But I'm arguing (and others backed me up on
this) that inlines are really just functions and as such should be
annotated, not magically inlined into the code and then checked as
sparse behaves right now.

> So, I think we should implement cross functions checking capability
> systematically rather than putting more hacks on source code
> annotation. The writer patch I send out earlier is one step towards it.
> I will write up more detail proposal.

Please don't focus on cross-function checking so much. Having different
contexts is way more desirable, and cross-function checking probably is
_not_ desirable in that you _want_ the annotations.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2008-09-10 21:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-29  8:54 [PATCH 0/9] context tracking updates Johannes Berg
2008-05-29  8:54 ` [PATCH 1/9] add test for acquire/release Johannes Berg
2008-05-29  8:54 ` [PATCH 2/9] add __exact_context__ Johannes Berg
2008-05-29  8:54 ` [PATCH 3/9] allow context() attribute on variables Johannes Berg
2008-05-29  8:54 ` [PATCH 4/9] evaluate/expand context expressions Johannes Berg
2008-05-29  8:54 ` [PATCH 5/9] revert the conditional_context patch Johannes Berg
2008-05-29  8:54 ` [PATCH 6/9] check context expressions as expressions Johannes Berg
2008-09-10  7:33   ` [PATCH 6/9 v2] " Johannes Berg
2008-09-10 19:21     ` Christopher Li
2008-09-10 21:34       ` Johannes Berg [this message]
2008-09-11  0:15         ` Christopher Li
2008-05-29  8:54 ` [PATCH 7/9] test conditional result locking Johannes Berg
2008-05-29  8:54 ` [PATCH 8/9] show required context in instruction output Johannes Berg
2008-05-29  8:54 ` [PATCH 9/9] check inlines explicitly Johannes Berg
2008-05-29 23:14   ` [PATCH 9/9 v2] " Johannes Berg
2008-05-29 23:20     ` Harvey Harrison
2008-05-29 22:12 ` [PATCH 0/9] context tracking updates Harvey Harrison
2008-05-29 22:35 ` Harvey Harrison
2008-05-29 22:45   ` Johannes Berg
2008-05-29 22:47     ` Harvey Harrison
2008-05-29 22:51     ` Harvey Harrison
2008-05-29 22:54       ` Johannes Berg
2008-05-29 23:03         ` Pavel Roskin
2008-05-29 23:06           ` Johannes Berg
2008-05-29 23:15             ` Johannes Berg
2008-05-29 23:04       ` Johannes Berg
2008-07-20 12:30 ` 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=1221082440.3804.40.camel@johannes.berg \
    --to=johannes@sipsolutions.net \
    --cc=harvey.harrison@gmail.com \
    --cc=josh@freedesktop.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=philipp.reisner@linbit.com \
    --cc=sparse@chrisli.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).