Gentoo Archives: gentoo-commits

From: "Richard Yao (ryao)" <ryao@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-kernel/spl/files: spl-0.6.0_rc9-detect-kernel-honors-gfp-flags.patch
Date: Sun, 17 Jun 2012 17:03:32
Message-Id: 20120617170312.E9DB12004B@flycatcher.gentoo.org
1 ryao 12/06/17 17:03:12
2
3 Added: spl-0.6.0_rc9-detect-kernel-honors-gfp-flags.patch
4 Log:
5 Add patch to take advantage of kernel change from bug #416685
6
7 (Portage version: 2.1.10.49/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 sys-kernel/spl/files/spl-0.6.0_rc9-detect-kernel-honors-gfp-flags.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-kernel/spl/files/spl-0.6.0_rc9-detect-kernel-honors-gfp-flags.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-kernel/spl/files/spl-0.6.0_rc9-detect-kernel-honors-gfp-flags.patch?rev=1.1&content-type=text/plain
14
15 Index: spl-0.6.0_rc9-detect-kernel-honors-gfp-flags.patch
16 ===================================================================
17 From 35f75553b720037eb7ef6ac9954c14f7d9c1b4e5 Mon Sep 17 00:00:00 2001
18 From: Richard Yao <ryao@×××××××××××××.edu>
19 Date: Wed, 6 Jun 2012 22:38:12 -0400
20 Subject: [PATCH] Detect kernels that honor gfp flags passed to vmalloc()
21
22 zfsonlinux/spl@2092cf68d89a51eb0d6193aeadabb579dfc4b4a0 used PF_MEMALLOC
23 to workaround a bug in the Linux kernel where allocations did not honor
24 the gfp flags passed to vmalloc(). Unfortunately, PF_MEMALLOC has the
25 side effect of permitting allocations to allocate pages outside of
26 ZONE_NORMAL. This has been observed to result in the depletion of
27 ZONE_DMA32 on Gentoo Linux. A kernel patch is available in the Gentoo
28 bug tracker for this issue:
29
30 https://bugs.gentoo.org/show_bug.cgi?id=416685
31
32 This negates any benefit PF_MEMALLOC provides, so we introduce an
33 autotools check to disable the use of PF_MEMALLOC on systems with
34 patched kernels.
35
36 Signed-off-by: Richard Yao <ryao@×××××××××××××.edu>
37 ---
38 config/spl-build.m4 | 26 ++++++++++++++++++++++++++
39 module/spl/spl-kmem.c | 4 ++++
40 2 files changed, 30 insertions(+)
41
42 diff --git a/config/spl-build.m4 b/config/spl-build.m4
43 index 6605b82..29c7ae4 100644
44 --- a/config/spl-build.m4
45 +++ b/config/spl-build.m4
46 @@ -87,6 +87,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
47 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
48 SPL_AC_SHRINK_CONTROL_STRUCT
49 SPL_AC_RWSEM_SPINLOCK_IS_RAW
50 + SPL_AC_PMD_ALLOC_WITH_MASK
51 ])
52
53 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
54 @@ -2056,3 +2057,28 @@ AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
55 ])
56 EXTRA_KCFLAGS="$tmp_flags"
57 ])
58 +
59 +dnl #
60 +dnl # 2.6.20 API change,
61 +dnl # INIT_WORK use 2 args and not store data inside
62 +dnl #
63 +AC_DEFUN([SPL_AC_PMD_ALLOC_WITH_MASK],
64 + [AC_MSG_CHECKING([whether pmd_alloc_with_mask exists])
65 + SPL_LINUX_TRY_COMPILE([
66 + #define CONFIG_MMU
67 + #undef RCH_HAS_4LEVEL_HACK
68 + #include <linux/mm.h>
69 + ],[
70 + struct mm_struct init_mm;
71 + pud_t pud;
72 + unsigned long addr;
73 + gfp_t gfp_mask;
74 + pmd_alloc_with_mask(&init_mm, &pud, addr, gfp_mask);
75 + ],[
76 + AC_MSG_RESULT(yes)
77 + AC_DEFINE(HAVE_PMD_ALLOC_WITH_MASK, 1,
78 + [pmd_alloc_with_mask exists])
79 + ],[
80 + AC_MSG_RESULT(no)
81 + ])
82 +])
83 diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
84 index e1d74d3..c640779 100644
85 --- a/module/spl/spl-kmem.c
86 +++ b/module/spl/spl-kmem.c
87 @@ -843,6 +843,9 @@ static int spl_cache_flush(spl_kmem_cache_t *skc,
88 if (skc->skc_flags & KMC_KMEM) {
89 ptr = (void *)__get_free_pages(flags, get_order(size));
90 } else {
91 +#ifdef HAVE_PMD_ALLOC_WITH_MASK
92 + ptr = __vmalloc(size, flags|__GFP_HIGHMEM, PAGE_KERNEL);
93 +#else
94 /*
95 * As part of vmalloc() an __pte_alloc_kernel() allocation
96 * may occur. This internal allocation does not honor the
97 @@ -866,6 +869,7 @@ static int spl_cache_flush(spl_kmem_cache_t *skc,
98 } else {
99 ptr = __vmalloc(size, flags|__GFP_HIGHMEM, PAGE_KERNEL);
100 }
101 +#endif
102 }
103
104 /* Resulting allocated memory will be page aligned */
105 --
106 1.7.10