All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@freedesktop.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 1/3] make sparse keep its promise about context tracking
Date: Mon, 21 Apr 2008 11:26:04 -0700	[thread overview]
Message-ID: <480CDC3C.4040808@freedesktop.org> (raw)
In-Reply-To: <1208801485.26186.131.camel@johannes.berg>

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

Johannes Berg wrote:
>>>     static void *dev_mc_seq_start(struct seq_file *seq, loff_t * pos)
>>>             __acquires(dev_base_lock)
>>>     {
>>>             [...]
>>>             __acquire__(dev_base_lock);
>>>             read_lock(&dev_base_lock);
>>>             [...]
>>>     }
>> I don't understand why you count this as wrong.  read_lock should
>> handle acquiring the context itself, either via an __acquires
>> annotation if written as a function, or via an __acquire__ statement
>> if written as a macro.  Callers of read_lock shouldn't need to
>> explicitly call __acquire__.
> 
> Well, the question is how you want to name things. What I did is that
> the context identifier is just a name and bears no other relation to the
> code. Hence, read_lock() can't say that it acquires 'dev_base_lock'
> because it doesn't know what the name should be.
> 
> With a slightly different sparse patch than mine you could declare
> read_lock() something like this:
> 
> #define read_lock(x) do { \
> 	__acquire__(x); \
> 	__read_lock((x)); \
> } while (0)
> 
> but then you'd have different names everywhere, say somebody passed
> '&dev_base_lock' and somebody else used
> 
> readlock_t *dbl = &dev_base_lock;
> read_lock(dbl)
> 
> and you'd end up with one context named "dbl" and another one named
> "&dev_base_lock".

That might still work, depending on how consistently kernel code uses
the same argument.  If you suggest explicitly changing calls to
read_lock to call __acquire__ with the appropriate context, it might
prove equally easy to make the argument of read_lock that context.

> If you have suggestions on how to solve this I'm all ears, so far I
> decided it wasn't worth it and opted for explicitly naming all the
> contexts.
> 
> (with my patch the above would just create a context called "x")

That doesn't make sense to me; after preprocessing, x no longer
exists, so I don't see how you could pick up the identifier "x".  I
can understand that you might pick up two different expressions in
place of x which you can't easily compare, though.

And as for how to solve it: I think alias analysis might work.

- Josh Triplett


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

  reply	other threads:[~2008-04-21 18:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-10 13:25 [PATCH 0/3] improve context handling Johannes Berg
2008-04-10 13:25 ` [PATCH 1/3] make sparse keep its promise about context tracking Johannes Berg
2008-04-10 15:24   ` Philipp Reisner
2008-04-10 15:30     ` Johannes Berg
2008-04-10 15:46       ` Philipp Reisner
2008-04-10 15:51         ` Johannes Berg
2008-04-10 16:05           ` Philipp Reisner
2008-04-10 16:12             ` Johannes Berg
2008-04-10 21:21               ` Philipp Reisner
2008-04-11 19:53                 ` Josh Triplett
2008-04-18 12:35                   ` Johannes Berg
2008-04-11 11:06             ` Johannes Berg
2008-04-21 19:34             ` Josh Triplett
2008-04-21 19:37               ` Johannes Berg
2008-04-10 15:54         ` Johannes Berg
2008-04-21 19:22       ` Josh Triplett
2008-04-21 18:04   ` Josh Triplett
2008-04-21 18:11     ` Johannes Berg
2008-04-21 18:26       ` Josh Triplett [this message]
2008-04-21 18:30         ` Johannes Berg
2008-04-21 18:51           ` Josh Triplett
2008-04-10 13:25 ` [PATCH 2/3] sparse test suite: add test mixing __context__ and __attribute__((context(...))) Johannes Berg
2008-04-10 13:25 ` [PATCH 3/3] sparse: simple conditional context tracking Johannes Berg
2008-04-11 11:07 ` [PATCH 4/3] inlined call bugfix & test Johannes Berg
2008-04-11 11:08 ` [PATCH 5/3] improve -Wcontext code and messages Johannes Berg
2008-04-21 18:37 ` [PATCH 0/3] improve context handling Josh Triplett

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=480CDC3C.4040808@freedesktop.org \
    --to=josh@freedesktop.org \
    --cc=johannes@sipsolutions.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 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.