Lines Matching refs:tbl
38 const struct bucket_table *tbl, in head_hashfn() argument
41 return rht_head_hashfn(ht, tbl, he, ht->p); in head_hashfn()
53 int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash) in lockdep_rht_bucket_is_held() argument
57 if (unlikely(tbl->nest)) in lockdep_rht_bucket_is_held()
59 return bit_spin_is_locked(0, (unsigned long *)&tbl->buckets[hash]); in lockdep_rht_bucket_is_held()
67 const struct bucket_table *tbl) in nested_table_top() argument
72 return (void *)rcu_dereference_protected(tbl->buckets[0], 1); in nested_table_top()
94 static void nested_bucket_table_free(const struct bucket_table *tbl) in nested_bucket_table_free() argument
96 unsigned int size = tbl->size >> tbl->nest; in nested_bucket_table_free()
97 unsigned int len = 1 << tbl->nest; in nested_bucket_table_free()
101 ntbl = nested_table_top(tbl); in nested_bucket_table_free()
109 static void bucket_table_free(const struct bucket_table *tbl) in bucket_table_free() argument
111 if (tbl->nest) in bucket_table_free()
112 nested_bucket_table_free(tbl); in bucket_table_free()
114 kvfree(tbl); in bucket_table_free()
152 struct bucket_table *tbl; in nested_bucket_table_alloc() local
158 size = sizeof(*tbl) + sizeof(tbl->buckets[0]); in nested_bucket_table_alloc()
160 tbl = kzalloc(size, gfp); in nested_bucket_table_alloc()
161 if (!tbl) in nested_bucket_table_alloc()
164 if (!nested_table_alloc(ht, (union nested_table __rcu **)tbl->buckets, in nested_bucket_table_alloc()
166 kfree(tbl); in nested_bucket_table_alloc()
170 tbl->nest = (ilog2(nbuckets) - 1) % shift + 1; in nested_bucket_table_alloc()
172 return tbl; in nested_bucket_table_alloc()
179 struct bucket_table *tbl = NULL; in bucket_table_alloc() local
184 tbl = kvzalloc(struct_size(tbl, buckets, nbuckets), gfp); in bucket_table_alloc()
188 if (tbl == NULL && (gfp & ~__GFP_NOFAIL) != GFP_KERNEL) { in bucket_table_alloc()
189 tbl = nested_bucket_table_alloc(ht, nbuckets, gfp); in bucket_table_alloc()
193 if (tbl == NULL) in bucket_table_alloc()
196 lockdep_init_map(&tbl->dep_map, "rhashtable_bucket", &__key, 0); in bucket_table_alloc()
198 tbl->size = size; in bucket_table_alloc()
200 rcu_head_init(&tbl->rcu); in bucket_table_alloc()
201 INIT_LIST_HEAD(&tbl->walkers); in bucket_table_alloc()
203 tbl->hash_rnd = get_random_u32(); in bucket_table_alloc()
206 INIT_RHT_NULLS_HEAD(tbl->buckets[i]); in bucket_table_alloc()
208 return tbl; in bucket_table_alloc()
212 struct bucket_table *tbl) in rhashtable_last_table() argument
217 new_tbl = tbl; in rhashtable_last_table()
218 tbl = rht_dereference_rcu(tbl->future_tbl, ht); in rhashtable_last_table()
219 } while (tbl); in rhashtable_last_table()
228 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); in rhashtable_rehash_one()
279 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); in rhashtable_rehash_chain()
317 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); in rhashtable_rehash_table()
335 rcu_assign_pointer(ht->tbl, new_tbl); in rhashtable_rehash_table()
339 walker->tbl = NULL; in rhashtable_rehash_table()
392 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); in rhashtable_shrink()
413 struct bucket_table *tbl; in rht_deferred_worker() local
419 tbl = rht_dereference(ht->tbl, ht); in rht_deferred_worker()
420 tbl = rhashtable_last_table(ht, tbl); in rht_deferred_worker()
422 if (rht_grow_above_75(ht, tbl)) in rht_deferred_worker()
423 err = rhashtable_rehash_alloc(ht, tbl, tbl->size * 2); in rht_deferred_worker()
424 else if (ht->p.automatic_shrinking && rht_shrink_below_30(ht, tbl)) in rht_deferred_worker()
426 else if (tbl->nest) in rht_deferred_worker()
427 err = rhashtable_rehash_alloc(ht, tbl, tbl->size); in rht_deferred_worker()
443 struct bucket_table *tbl) in rhashtable_insert_rehash() argument
450 old_tbl = rht_dereference_rcu(ht->tbl, ht); in rhashtable_insert_rehash()
452 size = tbl->size; in rhashtable_insert_rehash()
456 if (rht_grow_above_75(ht, tbl)) in rhashtable_insert_rehash()
459 else if (old_tbl != tbl) in rhashtable_insert_rehash()
468 err = rhashtable_rehash_attach(ht, tbl, new_tbl); in rhashtable_insert_rehash()
480 if (likely(rcu_access_pointer(tbl->future_tbl))) in rhashtable_insert_rehash()
492 struct bucket_table *tbl, unsigned int hash, in rhashtable_lookup_one() argument
504 rht_for_each_from(head, rht_ptr(bkt, tbl, hash), tbl, hash) { in rhashtable_lookup_one()
524 head = rht_dereference_bucket(head->next, tbl, hash); in rhashtable_lookup_one()
543 struct bucket_table *tbl, unsigned int hash, struct rhash_head *obj, in rhashtable_insert_one() argument
555 new_tbl = rht_dereference_rcu(tbl->future_tbl, ht); in rhashtable_insert_one()
562 if (unlikely(rht_grow_above_max(ht, tbl))) in rhashtable_insert_one()
565 if (unlikely(rht_grow_above_100(ht, tbl))) in rhashtable_insert_one()
568 head = rht_ptr(bkt, tbl, hash); in rhashtable_insert_one()
584 if (rht_grow_above_75(ht, tbl)) in rhashtable_insert_one()
594 struct bucket_table *tbl; in rhashtable_try_insert() local
600 new_tbl = rcu_dereference(ht->tbl); in rhashtable_try_insert()
603 tbl = new_tbl; in rhashtable_try_insert()
604 hash = rht_head_hashfn(ht, tbl, obj, ht->p); in rhashtable_try_insert()
605 if (rcu_access_pointer(tbl->future_tbl)) in rhashtable_try_insert()
607 bkt = rht_bucket_var(tbl, hash); in rhashtable_try_insert()
609 bkt = rht_bucket_insert(ht, tbl, hash); in rhashtable_try_insert()
611 new_tbl = rht_dereference_rcu(tbl->future_tbl, ht); in rhashtable_try_insert()
614 flags = rht_lock(tbl, bkt); in rhashtable_try_insert()
615 data = rhashtable_lookup_one(ht, bkt, tbl, in rhashtable_try_insert()
617 new_tbl = rhashtable_insert_one(ht, bkt, tbl, in rhashtable_try_insert()
622 rht_unlock(tbl, bkt, flags); in rhashtable_try_insert()
627 data = ERR_PTR(rhashtable_insert_rehash(ht, tbl) ?: in rhashtable_try_insert()
678 iter->walker.tbl = in rhashtable_walk_enter()
679 rcu_dereference_protected(ht->tbl, lockdep_is_held(&ht->lock)); in rhashtable_walk_enter()
680 list_add(&iter->walker.list, &iter->walker.tbl->walkers); in rhashtable_walk_enter()
694 if (iter->walker.tbl) in rhashtable_walk_exit()
727 if (iter->walker.tbl) in rhashtable_walk_start_check()
733 if (!iter->walker.tbl) { in rhashtable_walk_start_check()
734 iter->walker.tbl = rht_dereference_rcu(ht->tbl, ht); in rhashtable_walk_start_check()
747 rht_for_each_rcu(p, iter->walker.tbl, iter->slot) { in rhashtable_walk_start_check()
762 rht_for_each_rcu(p, iter->walker.tbl, iter->slot) { in rhashtable_walk_start_check()
793 struct bucket_table *tbl = iter->walker.tbl; in __rhashtable_walk_find_next() local
799 if (!tbl) in __rhashtable_walk_find_next()
802 for (; iter->slot < tbl->size; iter->slot++) { in __rhashtable_walk_find_next()
805 rht_for_each_rcu(p, tbl, iter->slot) { in __rhashtable_walk_find_next()
839 iter->walker.tbl = rht_dereference_rcu(tbl->future_tbl, ht); in __rhashtable_walk_find_next()
840 if (iter->walker.tbl) { in __rhashtable_walk_find_next()
938 struct bucket_table *tbl = iter->walker.tbl; in rhashtable_walk_stop() local
940 if (!tbl) in rhashtable_walk_stop()
946 if (rcu_head_after_call_rcu(&tbl->rcu, bucket_table_free_rcu)) in rhashtable_walk_stop()
948 iter->walker.tbl = NULL; in rhashtable_walk_stop()
950 list_add(&iter->walker.list, &tbl->walkers); in rhashtable_walk_stop()
1022 struct bucket_table *tbl; in rhashtable_init() local
1065 tbl = bucket_table_alloc(ht, size, GFP_KERNEL); in rhashtable_init()
1066 if (unlikely(tbl == NULL)) { in rhashtable_init()
1068 tbl = bucket_table_alloc(ht, size, GFP_KERNEL | __GFP_NOFAIL); in rhashtable_init()
1073 RCU_INIT_POINTER(ht->tbl, tbl); in rhashtable_init()
1138 struct bucket_table *tbl, *next_tbl; in rhashtable_free_and_destroy() local
1144 tbl = rht_dereference(ht->tbl, ht); in rhashtable_free_and_destroy()
1147 for (i = 0; i < tbl->size; i++) { in rhashtable_free_and_destroy()
1151 for (pos = rht_ptr_exclusive(rht_bucket(tbl, i)), in rhashtable_free_and_destroy()
1162 next_tbl = rht_dereference(tbl->future_tbl, ht); in rhashtable_free_and_destroy()
1163 bucket_table_free(tbl); in rhashtable_free_and_destroy()
1165 tbl = next_tbl; in rhashtable_free_and_destroy()
1179 const struct bucket_table *tbl, unsigned int hash) in __rht_bucket_nested() argument
1182 unsigned int index = hash & ((1 << tbl->nest) - 1); in __rht_bucket_nested()
1183 unsigned int size = tbl->size >> tbl->nest; in __rht_bucket_nested()
1187 ntbl = nested_table_top(tbl); in __rht_bucket_nested()
1188 ntbl = rht_dereference_bucket_rcu(ntbl[index].table, tbl, hash); in __rht_bucket_nested()
1189 subhash >>= tbl->nest; in __rht_bucket_nested()
1194 tbl, hash); in __rht_bucket_nested()
1208 const struct bucket_table *tbl, unsigned int hash) in rht_bucket_nested() argument
1214 return __rht_bucket_nested(tbl, hash) ?: &rhnull; in rht_bucket_nested()
1219 struct rhashtable *ht, struct bucket_table *tbl, unsigned int hash) in rht_bucket_nested_insert() argument
1222 unsigned int index = hash & ((1 << tbl->nest) - 1); in rht_bucket_nested_insert()
1223 unsigned int size = tbl->size >> tbl->nest; in rht_bucket_nested_insert()
1226 ntbl = nested_table_top(tbl); in rht_bucket_nested_insert()
1227 hash >>= tbl->nest; in rht_bucket_nested_insert()