]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/rhashtable.c
Merge tag '4.13-fixes' of git://git.lwn.net/linux
[karo-tx-linux.git] / lib / rhashtable.c
index a930e436db5d8ff6b3e4959ae60761607bcd47cc..42466c167257cc08183357116e0c26c20f7dec3e 100644 (file)
@@ -86,16 +86,9 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl,
                size = min(size, 1U << tbl->nest);
 
        if (sizeof(spinlock_t) != 0) {
-               tbl->locks = NULL;
-#ifdef CONFIG_NUMA
-               if (size * sizeof(spinlock_t) > PAGE_SIZE &&
-                   gfp == GFP_KERNEL)
-                       tbl->locks = vmalloc(size * sizeof(spinlock_t));
-#endif
-               if (gfp != GFP_KERNEL)
-                       gfp |= __GFP_NOWARN | __GFP_NORETRY;
-
-               if (!tbl->locks)
+               if (gfpflags_allow_blocking(gfp))
+                       tbl->locks = kvmalloc(size * sizeof(spinlock_t), gfp);
+               else
                        tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
                                                   gfp);
                if (!tbl->locks)
@@ -218,11 +211,10 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
        int i;
 
        size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]);
-       if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) ||
-           gfp != GFP_KERNEL)
+       if (gfp != GFP_KERNEL)
                tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY);
-       if (tbl == NULL && gfp == GFP_KERNEL)
-               tbl = vzalloc(size);
+       else
+               tbl = kvzalloc(size, gfp);
 
        size = nbuckets;