rhashtable: Add parent argument to mutex_is_held
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Nov 2014 10:11:22 +0000 (18:11 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Nov 2014 20:13:05 +0000 (15:13 -0500)
Currently mutex_is_held can only test locks in the that are global
since it takes no arguments.  This prevents rhashtable from being
used in places where locks are lock, e.g., per-namespace locks.

This patch adds a parent field to mutex_is_held and rhashtable_params
so that local locks can be used (and tested).

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/rhashtable.h
lib/rhashtable.c
net/netfilter/nft_hash.c
net/netlink/af_netlink.c

index 96ce8ceff554956fe30421b76cd3d3a7113460a0..473e26bdb91d59f4feabc7b06440d3279c54750a 100644 (file)
@@ -66,7 +66,8 @@ struct rhashtable_params {
        bool                    (*shrink_decision)(const struct rhashtable *ht,
                                                   size_t new_size);
 #ifdef CONFIG_PROVE_LOCKING
-       int                     (*mutex_is_held)(void);
+       int                     (*mutex_is_held)(void *parent);
+       void                    *parent;
 #endif
 };
 
index c7654b6f5f64e9ba6eb7c49770b456067f0ccd3f..4b4b53bfa08b23dff3ed9689fca1ce46c1295f12 100644 (file)
@@ -32,7 +32,7 @@
 #ifdef CONFIG_PROVE_LOCKING
 int lockdep_rht_mutex_is_held(const struct rhashtable *ht)
 {
-       return ht->p.mutex_is_held();
+       return ht->p.mutex_is_held(ht->p.parent);
 }
 EXPORT_SYMBOL_GPL(lockdep_rht_mutex_is_held);
 #endif
@@ -618,7 +618,7 @@ EXPORT_SYMBOL_GPL(rhashtable_destroy);
 #define TEST_NEXPANDS  4
 
 #ifdef CONFIG_PROVE_LOCKING
-static int test_mutex_is_held(void)
+static int test_mutex_is_held(void *parent)
 {
        return 1;
 }
index b86305c86048b4c97118b92abedaa97b8f5096b6..3f75aaaf9d06fc14c242ac7d1a1e02de33923098 100644 (file)
@@ -154,7 +154,7 @@ static unsigned int nft_hash_privsize(const struct nlattr * const nla[])
 }
 
 #ifdef CONFIG_PROVE_LOCKING
-static int lockdep_nfnl_lock_is_held(void)
+static int lockdep_nfnl_lock_is_held(void *parent)
 {
        return lockdep_nfnl_is_held(NFNL_SUBSYS_NFTABLES);
 }
index 53b8ea793191b01e0376f31d4b8bd0337e377659..9e0628cfdf679e7b2b26614c17bcbfcc1b365c49 100644 (file)
@@ -115,7 +115,7 @@ DEFINE_MUTEX(nl_sk_hash_lock);
 EXPORT_SYMBOL_GPL(nl_sk_hash_lock);
 
 #ifdef CONFIG_PROVE_LOCKING
-static int lockdep_nl_sk_hash_is_held(void)
+static int lockdep_nl_sk_hash_is_held(void *parent)
 {
        if (debug_locks)
                return lockdep_is_held(&nl_sk_hash_lock) || lockdep_is_held(&nl_table_lock);