提交 5beb5c90 编写于 作者: E Eric Dumazet 提交者: David S. Miller

rhashtable: use cond_resched()

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: NEric Dumazet <edumazet@google.com>
Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 061c1a6e
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/mm.h> #include <linux/mm.h>
...@@ -412,6 +413,7 @@ int rhashtable_expand(struct rhashtable *ht) ...@@ -412,6 +413,7 @@ int rhashtable_expand(struct rhashtable *ht)
} }
} }
unlock_buckets(new_tbl, old_tbl, new_hash); unlock_buckets(new_tbl, old_tbl, new_hash);
cond_resched();
} }
/* Unzip interleaved hash chains */ /* Unzip interleaved hash chains */
...@@ -435,6 +437,7 @@ int rhashtable_expand(struct rhashtable *ht) ...@@ -435,6 +437,7 @@ int rhashtable_expand(struct rhashtable *ht)
complete = false; complete = false;
unlock_buckets(new_tbl, old_tbl, old_hash); unlock_buckets(new_tbl, old_tbl, old_hash);
cond_resched();
} }
} }
...@@ -493,6 +496,7 @@ int rhashtable_shrink(struct rhashtable *ht) ...@@ -493,6 +496,7 @@ int rhashtable_shrink(struct rhashtable *ht)
tbl->buckets[new_hash + new_tbl->size]); tbl->buckets[new_hash + new_tbl->size]);
unlock_buckets(new_tbl, tbl, new_hash); unlock_buckets(new_tbl, tbl, new_hash);
cond_resched();
} }
/* Publish the new, valid hash table */ /* Publish the new, valid hash table */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册