Subject: Re: [PATCH] net: add sparse annotation to ptype_seq_start/stop

From: Josh Triplett <[email-masked]>
Date: Sun, 20 Jan 2008 23:29:32 -0800

Paul E. McKenney wrote:
> On Sun, Jan 20, 2008 at 03:21:46PM -0800, Stephen Hemminger wrote:
>> Get rid of some more sparse warnings.
>>
>> Signed-off-by: Stephen Hemminger <[email-masked]>
> 
> Adding Josh to CC -- is __acquires() case-insensitive?  If not, this
> needs to be __acquires(RCU) and __releases(RCU).
[...]
>> --- a/net/core/dev.c	2008-01-20 14:25:00.000000000 -0800
>> +++ b/net/core/dev.c	2008-01-20 14:25:48.000000000 -0800
>> @@ -2543,6 +2543,7 @@ static void *ptype_get_idx(loff_t pos)
>>  }
>>
>>  static void *ptype_seq_start(struct seq_file *seq, loff_t *pos)
>> +	__acquires(rcu)
>>  {
>>  	rcu_read_lock();
>>  	return *pos ? ptype_get_idx(*pos - 1) : SEQ_START_TOKEN;
>> @@ -2578,6 +2579,7 @@ found:
>>  }
>>
>>  static void ptype_seq_stop(struct seq_file *seq, void *v)
>> +	__releases(rcu)
>>  {
>>  	rcu_read_unlock();
>>  }

At the moment, Sparse doesn't actually use the context expression.  In
the ideal case when it does, all references to the same lock should
use a context expression which resolves to that lock (whatever that
may mean; hence why Sparse doesn't handle it yet).  For mechanisms
like RCU without a lock variable, this will likely entail some sort of
fake lock expression, which again needs to match between all users of
the same mechanism.  Like any expression in C, case matters; thus,
please match the existing references to "RCU" rather than "rcu".

- Josh Triplett