summaryrefslogtreecommitdiff
path: root/patches/lib-rhashtable.patch
blob: 9c262b02831cc68e311f2815836dda99afa657e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- a/compat/lib-rhashtable.c
+++ b/compat/lib-rhashtable.c
@@ -86,11 +86,26 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl,
 		size = min(size, 1U << tbl->nest);
 
 	if (sizeof(spinlock_t) != 0) {
+#if LINUX_VERSION_IS_LESS(4,12,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)
+			tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
+						   gfp);
+#else
 		if (gfpflags_allow_blocking(gfp))
 			tbl->locks = kvmalloc(size * sizeof(spinlock_t), gfp);
 		else
 			tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
 						   gfp);
+#endif
 		if (!tbl->locks)
 			return -ENOMEM;
 		for (i = 0; i < size; i++)
-- 
1.9.1