Skip to content

Commit

Permalink
rhashtable: Add parent argument to mutex_is_held
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Nov 13, 2014
1 parent 1b2f309 commit 7b4ce23
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/linux/rhashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
4 changes: 2 additions & 2 deletions lib/rhashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nft_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7b4ce23

Please sign in to comment.