Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Resizable, Scalable, Concurrent Hash Table |
| 3 | * |
| 4 | * Copyright (c) 2014 Thomas Graf <tgraf@suug.ch> |
| 5 | * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net> |
| 6 | * |
| 7 | * Based on the following paper by Josh Triplett, Paul E. McKenney |
| 8 | * and Jonathan Walpole: |
| 9 | * https://www.usenix.org/legacy/event/atc11/tech/final_files/Triplett.pdf |
| 10 | * |
| 11 | * Code partially derived from nft_hash |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License version 2 as |
| 15 | * published by the Free Software Foundation. |
| 16 | */ |
| 17 | |
| 18 | #ifndef _LINUX_RHASHTABLE_H |
| 19 | #define _LINUX_RHASHTABLE_H |
| 20 | |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 21 | #include <linux/list_nulls.h> |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 22 | #include <linux/workqueue.h> |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 23 | |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 24 | /* |
| 25 | * The end of the chain is marked with a special nulls marks which has |
| 26 | * the following format: |
| 27 | * |
| 28 | * +-------+-----------------------------------------------------+-+ |
| 29 | * | Base | Hash |1| |
| 30 | * +-------+-----------------------------------------------------+-+ |
| 31 | * |
| 32 | * Base (4 bits) : Reserved to distinguish between multiple tables. |
| 33 | * Specified via &struct rhashtable_params.nulls_base. |
| 34 | * Hash (27 bits): Full hash (unmasked) of first element added to bucket |
| 35 | * 1 (1 bit) : Nulls marker (always set) |
| 36 | * |
| 37 | * The remaining bits of the next pointer remain unused for now. |
| 38 | */ |
| 39 | #define RHT_BASE_BITS 4 |
| 40 | #define RHT_HASH_BITS 27 |
| 41 | #define RHT_BASE_SHIFT RHT_HASH_BITS |
| 42 | |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 43 | struct rhash_head { |
Thomas Graf | 5300fdc | 2014-08-13 16:38:29 +0200 | [diff] [blame] | 44 | struct rhash_head __rcu *next; |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 45 | }; |
| 46 | |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 47 | /** |
| 48 | * struct bucket_table - Table of hash buckets |
| 49 | * @size: Number of hash buckets |
| 50 | * @locks_mask: Mask to apply before accessing locks[] |
| 51 | * @locks: Array of spinlocks protecting individual buckets |
| 52 | * @buckets: size * hash buckets |
| 53 | */ |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 54 | struct bucket_table { |
| 55 | size_t size; |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 56 | unsigned int locks_mask; |
| 57 | spinlock_t *locks; |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 58 | struct rhash_head __rcu *buckets[]; |
| 59 | }; |
| 60 | |
| 61 | typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed); |
| 62 | typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 seed); |
| 63 | |
| 64 | struct rhashtable; |
| 65 | |
| 66 | /** |
| 67 | * struct rhashtable_params - Hash table construction parameters |
| 68 | * @nelem_hint: Hint on number of elements, should be 75% of desired size |
| 69 | * @key_len: Length of key |
| 70 | * @key_offset: Offset of key in struct to be hashed |
| 71 | * @head_offset: Offset of rhash_head in struct to be hashed |
| 72 | * @hash_rnd: Seed to use while hashing |
| 73 | * @max_shift: Maximum number of shifts while expanding |
Ying Xue | 9400017 | 2014-09-03 09:22:36 +0800 | [diff] [blame] | 74 | * @min_shift: Minimum number of shifts while shrinking |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 75 | * @nulls_base: Base value to generate nulls marker |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 76 | * @locks_mul: Number of bucket locks to allocate per cpu (default: 128) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 77 | * @hashfn: Function to hash key |
| 78 | * @obj_hashfn: Function to hash object |
| 79 | * @grow_decision: If defined, may return true if table should expand |
| 80 | * @shrink_decision: If defined, may return true if table should shrink |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 81 | */ |
| 82 | struct rhashtable_params { |
| 83 | size_t nelem_hint; |
| 84 | size_t key_len; |
| 85 | size_t key_offset; |
| 86 | size_t head_offset; |
| 87 | u32 hash_rnd; |
| 88 | size_t max_shift; |
Ying Xue | 9400017 | 2014-09-03 09:22:36 +0800 | [diff] [blame] | 89 | size_t min_shift; |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 90 | u32 nulls_base; |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 91 | size_t locks_mul; |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 92 | rht_hashfn_t hashfn; |
| 93 | rht_obj_hashfn_t obj_hashfn; |
| 94 | bool (*grow_decision)(const struct rhashtable *ht, |
| 95 | size_t new_size); |
| 96 | bool (*shrink_decision)(const struct rhashtable *ht, |
| 97 | size_t new_size); |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | /** |
| 101 | * struct rhashtable - Hash table handle |
| 102 | * @tbl: Bucket table |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 103 | * @future_tbl: Table under construction during expansion/shrinking |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 104 | * @nelems: Number of elements in table |
| 105 | * @shift: Current size (1 << shift) |
| 106 | * @p: Configuration parameters |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 107 | * @run_work: Deferred worker to expand/shrink asynchronously |
| 108 | * @mutex: Mutex to protect current/future table swapping |
| 109 | * @being_destroyed: True if table is set up for destruction |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 110 | */ |
| 111 | struct rhashtable { |
| 112 | struct bucket_table __rcu *tbl; |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 113 | struct bucket_table __rcu *future_tbl; |
| 114 | atomic_t nelems; |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 115 | size_t shift; |
| 116 | struct rhashtable_params p; |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 117 | struct delayed_work run_work; |
| 118 | struct mutex mutex; |
| 119 | bool being_destroyed; |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 120 | }; |
| 121 | |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 122 | static inline unsigned long rht_marker(const struct rhashtable *ht, u32 hash) |
| 123 | { |
| 124 | return NULLS_MARKER(ht->p.nulls_base + hash); |
| 125 | } |
| 126 | |
| 127 | #define INIT_RHT_NULLS_HEAD(ptr, ht, hash) \ |
| 128 | ((ptr) = (typeof(ptr)) rht_marker(ht, hash)) |
| 129 | |
| 130 | static inline bool rht_is_a_nulls(const struct rhash_head *ptr) |
| 131 | { |
| 132 | return ((unsigned long) ptr & 1); |
| 133 | } |
| 134 | |
| 135 | static inline unsigned long rht_get_nulls_value(const struct rhash_head *ptr) |
| 136 | { |
| 137 | return ((unsigned long) ptr) >> 1; |
| 138 | } |
| 139 | |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 140 | #ifdef CONFIG_PROVE_LOCKING |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 141 | int lockdep_rht_mutex_is_held(struct rhashtable *ht); |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 142 | int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash); |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 143 | #else |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 144 | static inline int lockdep_rht_mutex_is_held(struct rhashtable *ht) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 145 | { |
| 146 | return 1; |
| 147 | } |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 148 | |
| 149 | static inline int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, |
| 150 | u32 hash) |
| 151 | { |
| 152 | return 1; |
| 153 | } |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 154 | #endif /* CONFIG_PROVE_LOCKING */ |
| 155 | |
| 156 | int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params); |
| 157 | |
Thomas Graf | 6eba822 | 2014-11-13 13:45:46 +0100 | [diff] [blame] | 158 | void rhashtable_insert(struct rhashtable *ht, struct rhash_head *node); |
| 159 | bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *node); |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 160 | |
| 161 | bool rht_grow_above_75(const struct rhashtable *ht, size_t new_size); |
| 162 | bool rht_shrink_below_30(const struct rhashtable *ht, size_t new_size); |
| 163 | |
Thomas Graf | 6eba822 | 2014-11-13 13:45:46 +0100 | [diff] [blame] | 164 | int rhashtable_expand(struct rhashtable *ht); |
| 165 | int rhashtable_shrink(struct rhashtable *ht); |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 166 | |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 167 | void *rhashtable_lookup(struct rhashtable *ht, const void *key); |
| 168 | void *rhashtable_lookup_compare(struct rhashtable *ht, const void *key, |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 169 | bool (*compare)(void *, void *), void *arg); |
| 170 | |
Thomas Graf | 97defe1 | 2015-01-02 23:00:20 +0100 | [diff] [blame] | 171 | void rhashtable_destroy(struct rhashtable *ht); |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 172 | |
| 173 | #define rht_dereference(p, ht) \ |
| 174 | rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht)) |
| 175 | |
| 176 | #define rht_dereference_rcu(p, ht) \ |
| 177 | rcu_dereference_check(p, lockdep_rht_mutex_is_held(ht)) |
| 178 | |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 179 | #define rht_dereference_bucket(p, tbl, hash) \ |
| 180 | rcu_dereference_protected(p, lockdep_rht_bucket_is_held(tbl, hash)) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 181 | |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 182 | #define rht_dereference_bucket_rcu(p, tbl, hash) \ |
| 183 | rcu_dereference_check(p, lockdep_rht_bucket_is_held(tbl, hash)) |
| 184 | |
| 185 | #define rht_entry(tpos, pos, member) \ |
| 186 | ({ tpos = container_of(pos, typeof(*tpos), member); 1; }) |
| 187 | |
| 188 | /** |
| 189 | * rht_for_each_continue - continue iterating over hash chain |
| 190 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 191 | * @head: the previous &struct rhash_head to continue from |
| 192 | * @tbl: the &struct bucket_table |
| 193 | * @hash: the hash value / bucket index |
| 194 | */ |
| 195 | #define rht_for_each_continue(pos, head, tbl, hash) \ |
| 196 | for (pos = rht_dereference_bucket(head, tbl, hash); \ |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 197 | !rht_is_a_nulls(pos); \ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 198 | pos = rht_dereference_bucket((pos)->next, tbl, hash)) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * rht_for_each - iterate over hash chain |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 202 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 203 | * @tbl: the &struct bucket_table |
| 204 | * @hash: the hash value / bucket index |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 205 | */ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 206 | #define rht_for_each(pos, tbl, hash) \ |
| 207 | rht_for_each_continue(pos, (tbl)->buckets[hash], tbl, hash) |
| 208 | |
| 209 | /** |
| 210 | * rht_for_each_entry_continue - continue iterating over hash chain |
| 211 | * @tpos: the type * to use as a loop cursor. |
| 212 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 213 | * @head: the previous &struct rhash_head to continue from |
| 214 | * @tbl: the &struct bucket_table |
| 215 | * @hash: the hash value / bucket index |
| 216 | * @member: name of the &struct rhash_head within the hashable struct. |
| 217 | */ |
| 218 | #define rht_for_each_entry_continue(tpos, pos, head, tbl, hash, member) \ |
| 219 | for (pos = rht_dereference_bucket(head, tbl, hash); \ |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 220 | (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 221 | pos = rht_dereference_bucket((pos)->next, tbl, hash)) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 222 | |
| 223 | /** |
| 224 | * rht_for_each_entry - iterate over hash chain of given type |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 225 | * @tpos: the type * to use as a loop cursor. |
| 226 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 227 | * @tbl: the &struct bucket_table |
| 228 | * @hash: the hash value / bucket index |
| 229 | * @member: name of the &struct rhash_head within the hashable struct. |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 230 | */ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 231 | #define rht_for_each_entry(tpos, pos, tbl, hash, member) \ |
| 232 | rht_for_each_entry_continue(tpos, pos, (tbl)->buckets[hash], \ |
| 233 | tbl, hash, member) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 234 | |
| 235 | /** |
| 236 | * rht_for_each_entry_safe - safely iterate over hash chain of given type |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 237 | * @tpos: the type * to use as a loop cursor. |
| 238 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 239 | * @next: the &struct rhash_head to use as next in loop cursor. |
| 240 | * @tbl: the &struct bucket_table |
| 241 | * @hash: the hash value / bucket index |
| 242 | * @member: name of the &struct rhash_head within the hashable struct. |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 243 | * |
| 244 | * This hash chain list-traversal primitive allows for the looped code to |
| 245 | * remove the loop cursor from the list. |
| 246 | */ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 247 | #define rht_for_each_entry_safe(tpos, pos, next, tbl, hash, member) \ |
| 248 | for (pos = rht_dereference_bucket((tbl)->buckets[hash], tbl, hash), \ |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 249 | next = !rht_is_a_nulls(pos) ? \ |
| 250 | rht_dereference_bucket(pos->next, tbl, hash) : NULL; \ |
| 251 | (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 252 | pos = next) |
| 253 | |
| 254 | /** |
| 255 | * rht_for_each_rcu_continue - continue iterating over rcu hash chain |
| 256 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 257 | * @head: the previous &struct rhash_head to continue from |
| 258 | * @tbl: the &struct bucket_table |
| 259 | * @hash: the hash value / bucket index |
| 260 | * |
| 261 | * This hash chain list-traversal primitive may safely run concurrently with |
| 262 | * the _rcu mutation primitives such as rhashtable_insert() as long as the |
| 263 | * traversal is guarded by rcu_read_lock(). |
| 264 | */ |
| 265 | #define rht_for_each_rcu_continue(pos, head, tbl, hash) \ |
| 266 | for (({barrier(); }), \ |
| 267 | pos = rht_dereference_bucket_rcu(head, tbl, hash); \ |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 268 | !rht_is_a_nulls(pos); \ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 269 | pos = rcu_dereference_raw(pos->next)) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 270 | |
| 271 | /** |
| 272 | * rht_for_each_rcu - iterate over rcu hash chain |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 273 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 274 | * @tbl: the &struct bucket_table |
| 275 | * @hash: the hash value / bucket index |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 276 | * |
| 277 | * This hash chain list-traversal primitive may safely run concurrently with |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 278 | * the _rcu mutation primitives such as rhashtable_insert() as long as the |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 279 | * traversal is guarded by rcu_read_lock(). |
| 280 | */ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 281 | #define rht_for_each_rcu(pos, tbl, hash) \ |
| 282 | rht_for_each_rcu_continue(pos, (tbl)->buckets[hash], tbl, hash) |
| 283 | |
| 284 | /** |
| 285 | * rht_for_each_entry_rcu_continue - continue iterating over rcu hash chain |
| 286 | * @tpos: the type * to use as a loop cursor. |
| 287 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 288 | * @head: the previous &struct rhash_head to continue from |
| 289 | * @tbl: the &struct bucket_table |
| 290 | * @hash: the hash value / bucket index |
| 291 | * @member: name of the &struct rhash_head within the hashable struct. |
| 292 | * |
| 293 | * This hash chain list-traversal primitive may safely run concurrently with |
| 294 | * the _rcu mutation primitives such as rhashtable_insert() as long as the |
| 295 | * traversal is guarded by rcu_read_lock(). |
| 296 | */ |
| 297 | #define rht_for_each_entry_rcu_continue(tpos, pos, head, tbl, hash, member) \ |
| 298 | for (({barrier(); }), \ |
| 299 | pos = rht_dereference_bucket_rcu(head, tbl, hash); \ |
Thomas Graf | f89bd6f | 2015-01-02 23:00:21 +0100 | [diff] [blame^] | 300 | (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 301 | pos = rht_dereference_bucket_rcu(pos->next, tbl, hash)) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 302 | |
| 303 | /** |
| 304 | * rht_for_each_entry_rcu - iterate over rcu hash chain of given type |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 305 | * @tpos: the type * to use as a loop cursor. |
| 306 | * @pos: the &struct rhash_head to use as a loop cursor. |
| 307 | * @tbl: the &struct bucket_table |
| 308 | * @hash: the hash value / bucket index |
| 309 | * @member: name of the &struct rhash_head within the hashable struct. |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 310 | * |
| 311 | * This hash chain list-traversal primitive may safely run concurrently with |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 312 | * the _rcu mutation primitives such as rhashtable_insert() as long as the |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 313 | * traversal is guarded by rcu_read_lock(). |
| 314 | */ |
Thomas Graf | 88d6ed1 | 2015-01-02 23:00:16 +0100 | [diff] [blame] | 315 | #define rht_for_each_entry_rcu(tpos, pos, tbl, hash, member) \ |
| 316 | rht_for_each_entry_rcu_continue(tpos, pos, (tbl)->buckets[hash],\ |
| 317 | tbl, hash, member) |
Thomas Graf | 7e1e776 | 2014-08-02 11:47:44 +0200 | [diff] [blame] | 318 | |
| 319 | #endif /* _LINUX_RHASHTABLE_H */ |