summaryrefslogtreecommitdiff
path: root/patches/lib-bucket_locks.patch
blob: df7420de06fce9df6a54cf2ee3cbc6ea57394c27 (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
diff --git a/compat/lib-bucket_locks.c b/compat/lib-bucket_locks.c
index 266a97c5708b..405b52ca5708 100644
--- a/compat/lib-bucket_locks.c
+++ b/compat/lib-bucket_locks.c
@@ -30,10 +30,24 @@ int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *locks_mask,
 	}
 
 	if (sizeof(spinlock_t) != 0) {
+#if LINUX_VERSION_IS_LESS(4,12,0)
+#ifdef CONFIG_NUMA
+		if (size * sizeof(spinlock_t) > PAGE_SIZE &&
+		    gfp == GFP_KERNEL)
+			tlocks = vmalloc(size * sizeof(spinlock_t));
+#endif
+		if (gfp != GFP_KERNEL)
+			gfp |= __GFP_NOWARN | __GFP_NORETRY;
+
+		if (!tlocks)
+			tlocks = kmalloc_array(size, sizeof(spinlock_t),
+						   gfp);
+#else
 		if (gfpflags_allow_blocking(gfp))
 			tlocks = kvmalloc(size * sizeof(spinlock_t), gfp);
 		else
 			tlocks = kmalloc_array(size, sizeof(spinlock_t), gfp);
+#endif
 		if (!tlocks)
 			return -ENOMEM;
 		for (i = 0; i < size; i++)