compat: avoid usage of kvzalloc() in rhashtable.c
authorHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Aug 2017 22:28:08 +0000 (00:28 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 8 Sep 2017 13:23:13 +0000 (15:23 +0200)
This reverts commit 12e8fd6fd3802 ("lib/rhashtable.c: use kvzalloc() in
bucket_table_alloc() when possible") from upstream kernel.
Kernel versions older that 4.12 do not have kvzalloc() try to avoid the
usage of this.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
patches/lib-rhashtable.patch

index 9c262b02831cc68e311f2815836dda99afa657e3..35424efbdb54c32562f2205d425e05cb6bad7162 100644 (file)
                if (!tbl->locks)
                        return -ENOMEM;
                for (i = 0; i < size; i++)
--- 
-1.9.1
+@@ -226,10 +226,11 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
+       int i;
+       size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]);
+-      if (gfp != GFP_KERNEL)
++      if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) ||
++          gfp != GFP_KERNEL)
+               tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY);
+-      else
+-              tbl = kvzalloc(size, gfp);
++      if (tbl == NULL && gfp == GFP_KERNEL)
++              tbl = vzalloc(size);
+       size = nbuckets;