Skip to contentSkip to conversation

Revert lockdep check in raw_seqcount_begin

PATCH In review Trond Myklebust 3 participants 4 messages Jun 5, 2014 – Jun 11, 2014 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert lockdep check in raw_seqcount_begin

This commit reverts the addition of lockdep checking to raw_seqcount_begin for the following reasons:

1) It violates the naming convention that raw_* functions should not do lockdep checks (a convention that is also followed by the other raw_*_seqcount_begin functions).
2) raw_seqcount_begin does not spin, so it can only be part of an ABBA deadlock in very special circumstances (for instance if a lock is held across the entire raw_seqcount_begin()+read_seqcount_retry() loop while also being taken inside the write_seqcount protected area).
3) It is causing false positives with some existing callers, and there is no non-lockdep alternative for those callers to use.

None of the three existing callers (__d_lookup_rcu, netdev_get_name, and the NFS state code) appear to use the function in a manner that is ABBA deadlock prone.

Fixes 1ca7d67cf5d5: seqcount: Add lockdep functionality to seqcount/seqlock
Cc John Stultz <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Al Viro <[email protected]>
---
 include/linux/seqlock.h | 2 --
 1 file changed, 2 deletions(-)
include/linux/seqlock.h +0 -2
index 535f158977b9..8cf350325dc6 100644
@@ -164,8 +164,6 @@ static inline unsigned read_seqcount_begin(const seqcount_t *s)
 static inline unsigned raw_seqcount_begin(const seqcount_t *s)
 {
 	unsigned ret = ACCESS_ONCE(s->sequence);
-
-	seqcount_lockdep_reader_access(s);
 	smp_rmb();
 	return ret & ~1;
 }
Signature · 1 line
1.9.3
maintainer
#1 lore raw
Quoted 17 lines · Trond Myklebust

This commit reverts the addition of lockdep checking to raw_seqcount_begin for the following reasons:

1) It violates the naming convention that raw_* functions should not do lockdep checks (a convention that is also followed by the other raw_*_seqcount_begin functions).
2) raw_seqcount_begin does not spin, so it can only be part of an ABBA deadlock in very special circumstances (for instance if a lock is held across the entire raw_seqcount_begin()+read_seqcount_retry() loop while also being taken inside the write_seqcount protected area).
3) It is causing false positives with some existing callers, and there is no non-lockdep alternative for those callers to use.

None of the three existing callers (__d_lookup_rcu, netdev_get_name, and the NFS state code) appear to use the function in a manner that is ABBA deadlock prone.

Quoted 8 lines
Fixes 1ca7d67cf5d5: seqcount: Add lockdep functionality to seqcount/seqlock
Cc John Stultz <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Al Viro <[email protected]>

Thanks Trond!

Acked-by on v1 1/1
#2 lore raw
In reply to Trond Myklebust
Quoted 34 lines · Trond Myklebust

This commit reverts the addition of lockdep checking to raw_seqcount_begin for the following reasons:

1) It violates the naming convention that raw_* functions should not do lockdep checks (a convention that is also followed by the other raw_*_seqcount_begin functions).
2) raw_seqcount_begin does not spin, so it can only be part of an ABBA deadlock in very special circumstances (for instance if a lock is held across the entire raw_seqcount_begin()+read_seqcount_retry() loop while also being taken inside the write_seqcount protected area).
3) It is causing false positives with some existing callers, and there is no non-lockdep alternative for those callers to use.

None of the three existing callers (__d_lookup_rcu, netdev_get_name, and the NFS state code) appear to use the function in a manner that is ABBA deadlock prone.

Fixes 1ca7d67cf5d5: seqcount: Add lockdep functionality to seqcount/seqlock
Cc John Stultz <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Al Viro <[email protected]>
---
 include/linux/seqlock.h | 2 --
 1 file changed, 2 deletions(-)
include/linux/seqlock.h +0 -0
index 535f158977b9..8cf350325dc6 100644

include/linux/seqlock.h static inline unsigned read_seqcount_begin(const seqcount_t *s) · line 169

Quoted 8 lines
include/linux/seqlock.h +0 -2
@@ -164,8 +164,6 @@ static inline unsigned read_seqcount_begin(const seqcount_t *s)
 static inline unsigned raw_seqcount_begin(const seqcount_t *s)
 {
        unsigned ret = ACCESS_ONCE(s->sequence);
-
-       seqcount_lockdep_reader_access(s);
        smp_rmb();
        return ret & ~1;
 }

Just back from vacation, sorry for the slow response. Thanks for submitting this! Also sorry for my confusion mixing raw_seqcount_begin() and raw_seqlock_begin() in our earlier discussion (I blame the hectic vacation prep ;).

thanks
-john

#3 lore raw
Quoted 3 lines · John Stultz

Just back from vacation, sorry for the slow response. Thanks for submitting this! Also sorry for my confusion mixing raw_seqcount_begin() and raw_seqlock_begin() in our earlier discussion

Bah. Not raw_seqlock_begin.. I meant raw_read_seqcount_begin(). -john