Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cf5476b authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'rhash_prove_locking'



Herbert Xu says:

====================
rhashtable: Allow local locks to be used and tested

This series moves mutex_is_held entirely under PROVE_LOCKING so
there is zero foot print when we're not debugging.  More importantly
it adds a parrent argument to mutex_is_held so that we can test
local locks rather than global ones (e.g., per-namespace locks).
====================

Acked-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9488e1e5 7b4ce235
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -65,7 +65,10 @@ struct rhashtable_params {
						 size_t new_size);
	bool			(*shrink_decision)(const struct rhashtable *ht,
						   size_t new_size);
	int			(*mutex_is_held)(void);
#ifdef CONFIG_PROVE_LOCKING
	int			(*mutex_is_held)(void *parent);
	void			*parent;
#endif
};

/**
+10 −2
Original line number Diff line number Diff line
@@ -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
@@ -532,7 +532,9 @@ static size_t rounded_hashtable_size(struct rhashtable_params *params)
 *	.key_offset = offsetof(struct test_obj, key),
 *	.key_len = sizeof(int),
 *	.hashfn = arch_fast_hash,
 * #ifdef CONFIG_PROVE_LOCKING
 *	.mutex_is_held = &my_mutex_is_held,
 * #endif
 * };
 *
 * Configuration Example 2: Variable length keys
@@ -552,7 +554,9 @@ static size_t rounded_hashtable_size(struct rhashtable_params *params)
 *	.head_offset = offsetof(struct test_obj, node),
 *	.hashfn = arch_fast_hash,
 *	.obj_hashfn = my_hash_fn,
 * #ifdef CONFIG_PROVE_LOCKING
 *	.mutex_is_held = &my_mutex_is_held,
 * #endif
 * };
 */
int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params)
@@ -613,10 +617,12 @@ EXPORT_SYMBOL_GPL(rhashtable_destroy);
#define TEST_PTR	((void *) 0xdeadbeef)
#define TEST_NEXPANDS	4

static int test_mutex_is_held(void)
#ifdef CONFIG_PROVE_LOCKING
static int test_mutex_is_held(void *parent)
{
	return 1;
}
#endif

struct test_obj {
	void			*ptr;
@@ -767,7 +773,9 @@ static int __init test_rht_init(void)
		.key_offset = offsetof(struct test_obj, value),
		.key_len = sizeof(int),
		.hashfn = arch_fast_hash,
#ifdef CONFIG_PROVE_LOCKING
		.mutex_is_held = &test_mutex_is_held,
#endif
		.grow_decision = rht_grow_above_75,
		.shrink_decision = rht_shrink_below_30,
	};
+5 −1
Original line number Diff line number Diff line
@@ -153,10 +153,12 @@ static unsigned int nft_hash_privsize(const struct nlattr * const nla[])
	return sizeof(struct rhashtable);
}

static int lockdep_nfnl_lock_is_held(void)
#ifdef CONFIG_PROVE_LOCKING
static int lockdep_nfnl_lock_is_held(void *parent)
{
	return lockdep_nfnl_is_held(NFNL_SUBSYS_NFTABLES);
}
#endif

static int nft_hash_init(const struct nft_set *set,
			 const struct nft_set_desc *desc,
@@ -171,7 +173,9 @@ static int nft_hash_init(const struct nft_set *set,
		.hashfn = jhash,
		.grow_decision = rht_grow_above_75,
		.shrink_decision = rht_shrink_below_30,
#ifdef CONFIG_PROVE_LOCKING
		.mutex_is_held = lockdep_nfnl_lock_is_held,
#endif
	};

	return rhashtable_init(priv, &params);
+5 −3
Original line number Diff line number Diff line
@@ -114,14 +114,14 @@ static atomic_t nl_table_users = ATOMIC_INIT(0);
DEFINE_MUTEX(nl_sk_hash_lock);
EXPORT_SYMBOL_GPL(nl_sk_hash_lock);

static int lockdep_nl_sk_hash_is_held(void)
#ifdef CONFIG_PROVE_LOCKING
static int lockdep_nl_sk_hash_is_held(void *parent)
{
#ifdef CONFIG_LOCKDEP
	if (debug_locks)
		return lockdep_is_held(&nl_sk_hash_lock) || lockdep_is_held(&nl_table_lock);
#endif
	return 1;
}
#endif

static ATOMIC_NOTIFIER_HEAD(netlink_chain);

@@ -3133,7 +3133,9 @@ static int __init netlink_proto_init(void)
		.max_shift = 16, /* 64K */
		.grow_decision = rht_grow_above_75,
		.shrink_decision = rht_shrink_below_30,
#ifdef CONFIG_PROVE_LOCKING
		.mutex_is_held = lockdep_nl_sk_hash_is_held,
#endif
	};

	if (err != 0)