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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
From 35f75553b720037eb7ef6ac9954c14f7d9c1b4e5 Mon Sep 17 00:00:00 2001
From: Richard Yao <ryao@cs.stonybrook.edu>
Date: Wed, 6 Jun 2012 22:38:12 -0400
Subject: [PATCH] Detect kernels that honor gfp flags passed to vmalloc()
zfsonlinux/spl@2092cf68d89a51eb0d6193aeadabb579dfc4b4a0 used PF_MEMALLOC
to workaround a bug in the Linux kernel where allocations did not honor
the gfp flags passed to vmalloc(). Unfortunately, PF_MEMALLOC has the
side effect of permitting allocations to allocate pages outside of
ZONE_NORMAL. This has been observed to result in the depletion of
ZONE_DMA32 on Gentoo Linux. A kernel patch is available in the Gentoo
bug tracker for this issue:
https://bugs.gentoo.org/show_bug.cgi?id=416685
This negates any benefit PF_MEMALLOC provides, so we introduce an
autotools check to disable the use of PF_MEMALLOC on systems with
patched kernels.
Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
---
config/spl-build.m4 | 26 ++++++++++++++++++++++++++
module/spl/spl-kmem.c | 4 ++++
2 files changed, 30 insertions(+)
diff --git a/config/spl-build.m4 b/config/spl-build.m4
index 6605b82..29c7ae4 100644
--- a/config/spl-build.m4
+++ b/config/spl-build.m4
@@ -87,6 +87,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
SPL_AC_SHRINK_CONTROL_STRUCT
SPL_AC_RWSEM_SPINLOCK_IS_RAW
+ SPL_AC_PMD_ALLOC_WITH_MASK
])
AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
@@ -2056,3 +2057,28 @@ AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
])
EXTRA_KCFLAGS="$tmp_flags"
])
+
+dnl #
+dnl # 2.6.20 API change,
+dnl # INIT_WORK use 2 args and not store data inside
+dnl #
+AC_DEFUN([SPL_AC_PMD_ALLOC_WITH_MASK],
+ [AC_MSG_CHECKING([whether pmd_alloc_with_mask exists])
+ SPL_LINUX_TRY_COMPILE([
+ #define CONFIG_MMU
+ #undef RCH_HAS_4LEVEL_HACK
+ #include <linux/mm.h>
+ ],[
+ struct mm_struct init_mm;
+ pud_t pud;
+ unsigned long addr;
+ gfp_t gfp_mask;
+ pmd_alloc_with_mask(&init_mm, &pud, addr, gfp_mask);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_PMD_ALLOC_WITH_MASK, 1,
+ [pmd_alloc_with_mask exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
index e1d74d3..c640779 100644
--- a/module/spl/spl-kmem.c
+++ b/module/spl/spl-kmem.c
@@ -843,6 +843,9 @@ static int spl_cache_flush(spl_kmem_cache_t *skc,
if (skc->skc_flags & KMC_KMEM) {
ptr = (void *)__get_free_pages(flags, get_order(size));
} else {
+#ifdef HAVE_PMD_ALLOC_WITH_MASK
+ ptr = __vmalloc(size, flags|__GFP_HIGHMEM, PAGE_KERNEL);
+#else
/*
* As part of vmalloc() an __pte_alloc_kernel() allocation
* may occur. This internal allocation does not honor the
@@ -866,6 +869,7 @@ static int spl_cache_flush(spl_kmem_cache_t *skc,
} else {
ptr = __vmalloc(size, flags|__GFP_HIGHMEM, PAGE_KERNEL);
}
+#endif
}
/* Resulting allocated memory will be page aligned */
--
1.7.10
|