Skip to content

Commit

Permalink
rhashtable: use cond_resched()
Browse files Browse the repository at this point in the history
If a hash table has 128 slots and 16384 elems, expand to 256 slots
takes more than one second. For larger sets, a soft lockup is detected.

Holding cpu for that long, even in a work queue is a show stopper
for non preemptable kernels.

cond_resched() at strategic points to allow process scheduler
to reschedule us.

Signed-off-by: Eric Dumazet <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Feb 27, 2015
1 parent 061c1a6 commit 5beb5c9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rhashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/log2.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
Expand Down Expand Up @@ -412,6 +413,7 @@ int rhashtable_expand(struct rhashtable *ht)
}
}
unlock_buckets(new_tbl, old_tbl, new_hash);
cond_resched();
}

/* Unzip interleaved hash chains */
Expand All @@ -435,6 +437,7 @@ int rhashtable_expand(struct rhashtable *ht)
complete = false;

unlock_buckets(new_tbl, old_tbl, old_hash);
cond_resched();
}
}

Expand Down Expand Up @@ -493,6 +496,7 @@ int rhashtable_shrink(struct rhashtable *ht)
tbl->buckets[new_hash + new_tbl->size]);

unlock_buckets(new_tbl, tbl, new_hash);
cond_resched();
}

/* Publish the new, valid hash table */
Expand Down

0 comments on commit 5beb5c9

Please sign in to comment.