aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-02-19 18:53:38 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-20 17:38:09 -0500
commiteb6d1abf1bd8bf1beb45b5401c8324bdb8f893c4 (patch)
tree75f3fee2718ab7194dca0153ff765484b412401a
parent342100d937ed6e5faf1e7ee7dcd7b3935fec8877 (diff)
rhashtable: better high order allocation attempts
When trying to allocate future tables via bucket_table_alloc(), it seems overkill on large table shifts that we probe for kzalloc() unconditionally first, as it's likely to fail. Only probe with kzalloc() for more reasonable table sizes and use vzalloc() either as a fallback on failure or directly in case of large table sizes. Fixes: 7e1e77636e36 ("lib: Resizable, Scalable, Concurrent Hash Table") Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--lib/rhashtable.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 38f7879df0d8..b41a5c09832a 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -217,15 +217,15 @@ static void bucket_table_free(const struct bucket_table *tbl)
217static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, 217static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
218 size_t nbuckets) 218 size_t nbuckets)
219{ 219{
220 struct bucket_table *tbl; 220 struct bucket_table *tbl = NULL;
221 size_t size; 221 size_t size;
222 int i; 222 int i;
223 223
224 size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); 224 size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]);
225 tbl = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); 225 if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
226 tbl = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
226 if (tbl == NULL) 227 if (tbl == NULL)
227 tbl = vzalloc(size); 228 tbl = vzalloc(size);
228
229 if (tbl == NULL) 229 if (tbl == NULL)
230 return NULL; 230 return NULL;
231 231