Skip to content

Commit ae6da1f

Browse files
edumazetdavem330
authored andcommitted
rhashtable: add schedule points
Rehashing and destroying large hash table takes a lot of time, and happens in process context. It is safe to add cond_resched() in rhashtable_rehash_table() and rhashtable_free_and_destroy() Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 483a6e4 commit ae6da1f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/rhashtable.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ static int rhashtable_rehash_table(struct rhashtable *ht)
333333
err = rhashtable_rehash_chain(ht, old_hash);
334334
if (err)
335335
return err;
336+
cond_resched();
336337
}
337338

338339
/* Publish the new table pointer. */
@@ -1112,6 +1113,7 @@ void rhashtable_free_and_destroy(struct rhashtable *ht,
11121113
for (i = 0; i < tbl->size; i++) {
11131114
struct rhash_head *pos, *next;
11141115

1116+
cond_resched();
11151117
for (pos = rht_dereference(*rht_bucket(tbl, i), ht),
11161118
next = !rht_is_a_nulls(pos) ?
11171119
rht_dereference(pos->next, ht) : NULL;

0 commit comments

Comments
 (0)