aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rhashtable.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-03-13 22:57:23 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-15 01:35:34 -0400
commit9d901bc05153bbf33b5da2cd6266865e531f0545 (patch)
tree57518695b14d3f67e66c6e25ab2878f04158bf25 /lib/rhashtable.c
parent5269b53da4d432b0fbf755bd423c807bf6bd4aa0 (diff)
rhashtable: Free bucket tables asynchronously after rehash
There is in fact no need to wait for an RCU grace period in the rehash function, since all insertions are guaranteed to go into the new table through spin locks. This patch uses call_rcu to free the old/rehashed table at our leisure. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/rhashtable.c')
-rw-r--r--lib/rhashtable.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index e55bbc84c449..36fb0910bec2 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -141,6 +141,11 @@ static void bucket_table_free(const struct bucket_table *tbl)
141 kvfree(tbl); 141 kvfree(tbl);
142} 142}
143 143
144static void bucket_table_free_rcu(struct rcu_head *head)
145{
146 bucket_table_free(container_of(head, struct bucket_table, rcu));
147}
148
144static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, 149static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
145 size_t nbuckets) 150 size_t nbuckets)
146{ 151{
@@ -288,9 +293,7 @@ static void rhashtable_rehash(struct rhashtable *ht,
288 * table, and thus no references to the old table will 293 * table, and thus no references to the old table will
289 * remain. 294 * remain.
290 */ 295 */
291 synchronize_rcu(); 296 call_rcu(&old_tbl->rcu, bucket_table_free_rcu);
292
293 bucket_table_free(old_tbl);
294} 297}
295 298
296/** 299/**