Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

+24 -7
+4 -1
include/linux/rhashtable.h
··· 65 65 size_t new_size); 66 66 bool (*shrink_decision)(const struct rhashtable *ht, 67 67 size_t new_size); 68 - int (*mutex_is_held)(void); 68 + #ifdef CONFIG_PROVE_LOCKING 69 + int (*mutex_is_held)(void *parent); 70 + void *parent; 71 + #endif 69 72 }; 70 73 71 74 /**
+10 -2
lib/rhashtable.c
··· 32 32 #ifdef CONFIG_PROVE_LOCKING 33 33 int lockdep_rht_mutex_is_held(const struct rhashtable *ht) 34 34 { 35 - return ht->p.mutex_is_held(); 35 + return ht->p.mutex_is_held(ht->p.parent); 36 36 } 37 37 EXPORT_SYMBOL_GPL(lockdep_rht_mutex_is_held); 38 38 #endif ··· 532 532 * .key_offset = offsetof(struct test_obj, key), 533 533 * .key_len = sizeof(int), 534 534 * .hashfn = arch_fast_hash, 535 + * #ifdef CONFIG_PROVE_LOCKING 535 536 * .mutex_is_held = &my_mutex_is_held, 537 + * #endif 536 538 * }; 537 539 * 538 540 * Configuration Example 2: Variable length keys ··· 554 552 * .head_offset = offsetof(struct test_obj, node), 555 553 * .hashfn = arch_fast_hash, 556 554 * .obj_hashfn = my_hash_fn, 555 + * #ifdef CONFIG_PROVE_LOCKING 557 556 * .mutex_is_held = &my_mutex_is_held, 557 + * #endif 558 558 * }; 559 559 */ 560 560 int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params) ··· 617 613 #define TEST_PTR ((void *) 0xdeadbeef) 618 614 #define TEST_NEXPANDS 4 619 615 620 - static int test_mutex_is_held(void) 616 + #ifdef CONFIG_PROVE_LOCKING 617 + static int test_mutex_is_held(void *parent) 621 618 { 622 619 return 1; 623 620 } 621 + #endif 624 622 625 623 struct test_obj { 626 624 void *ptr; ··· 773 767 .key_offset = offsetof(struct test_obj, value), 774 768 .key_len = sizeof(int), 775 769 .hashfn = arch_fast_hash, 770 + #ifdef CONFIG_PROVE_LOCKING 776 771 .mutex_is_held = &test_mutex_is_held, 772 + #endif 777 773 .grow_decision = rht_grow_above_75, 778 774 .shrink_decision = rht_shrink_below_30, 779 775 };
+5 -1
net/netfilter/nft_hash.c
··· 153 153 return sizeof(struct rhashtable); 154 154 } 155 155 156 - static int lockdep_nfnl_lock_is_held(void) 156 + #ifdef CONFIG_PROVE_LOCKING 157 + static int lockdep_nfnl_lock_is_held(void *parent) 157 158 { 158 159 return lockdep_nfnl_is_held(NFNL_SUBSYS_NFTABLES); 159 160 } 161 + #endif 160 162 161 163 static int nft_hash_init(const struct nft_set *set, 162 164 const struct nft_set_desc *desc, ··· 173 171 .hashfn = jhash, 174 172 .grow_decision = rht_grow_above_75, 175 173 .shrink_decision = rht_shrink_below_30, 174 + #ifdef CONFIG_PROVE_LOCKING 176 175 .mutex_is_held = lockdep_nfnl_lock_is_held, 176 + #endif 177 177 }; 178 178 179 179 return rhashtable_init(priv, &params);
+5 -3
net/netlink/af_netlink.c
··· 114 114 DEFINE_MUTEX(nl_sk_hash_lock); 115 115 EXPORT_SYMBOL_GPL(nl_sk_hash_lock); 116 116 117 - static int lockdep_nl_sk_hash_is_held(void) 117 + #ifdef CONFIG_PROVE_LOCKING 118 + static int lockdep_nl_sk_hash_is_held(void *parent) 118 119 { 119 - #ifdef CONFIG_LOCKDEP 120 120 if (debug_locks) 121 121 return lockdep_is_held(&nl_sk_hash_lock) || lockdep_is_held(&nl_table_lock); 122 - #endif 123 122 return 1; 124 123 } 124 + #endif 125 125 126 126 static ATOMIC_NOTIFIER_HEAD(netlink_chain); 127 127 ··· 3133 3133 .max_shift = 16, /* 64K */ 3134 3134 .grow_decision = rht_grow_above_75, 3135 3135 .shrink_decision = rht_shrink_below_30, 3136 + #ifdef CONFIG_PROVE_LOCKING 3136 3137 .mutex_is_held = lockdep_nl_sk_hash_is_held, 3138 + #endif 3137 3139 }; 3138 3140 3139 3141 if (err != 0)