Skip to contentSkip to conversation

net: add sparse annotation to ptype_seq_start/stop

PATCH In review Stephen Hemminger 5 participants 6 messages Jan 20, 2008 – Jan 21, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: add sparse annotation to ptype_seq_start/stop

Get rid of some more sparse warnings.

net/core/dev.c +2 -0
@@ -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();
 }
#1 lore raw
Quoted 3 lines · Stephen Hemminger

Get rid of some more sparse warnings.

Adding Josh to CC -- is __acquires() case-insensitive? If not, this needs to be __acquires(RCU) and __releases(RCU).

Thanx, Paul

Quoted 22 lines
net/core/dev.c +2 -1
@@ -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();
 }
--

To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 7 lines · Paul E. McKenney
Quoted 3 lines · Stephen Hemminger

Get rid of some more sparse warnings.

Adding Josh to CC -- is __acquires() case-insensitive? If not, this needs to be __acquires(RCU) and __releases(RCU).

__acquires(whatever_the_helk_you_put_as_its_argument) is all the same.

#3 lore raw
Quoted 10 lines · Al Viro
Quoted 7 lines · Paul E. McKenney
Quoted 3 lines · Stephen Hemminger

Get rid of some more sparse warnings.

Adding Josh to CC -- is __acquires() case-insensitive? If not, this needs to be __acquires(RCU) and __releases(RCU).

__acquires(whatever_the_helk_you_put_as_its_argument) is all the same.

The existing calls are __acquires(RCU) and __releases(RCU). I suppose that one -could- use __acquires(RCU) in some places and __acquires(rcu) in others, but that sounds like it would eventually bite us...

Thanx, Paul

#4 lore raw
In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney
Quoted 3 lines · Stephen Hemminger

Get rid of some more sparse warnings.

Adding Josh to CC -- is __acquires() case-insensitive? If not, this needs to be __acquires(RCU) and __releases(RCU).

[...]

Quoted 13 lines
Quoted 13 lines
net/core/dev.c +1 -0
@@ -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:
 }
 
Quoted 5 lines

net/core/dev.c found: · line 2585

Quoted 5 lines
net/core/dev.c +1 -0
 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

maintainer
#5 lore raw

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

Quoted 8 lines

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".

Thus, I've checked in Stephen's patch with __acquires(RCU) and __releases(RCU).

Thanks.