From cbc89715a06cc4a059ba4e51d2f26e8c37556381 Mon Sep 17 00:00:00 2001 From: Sebastian Gottschall Date: Sat, 6 Jun 2020 15:57:13 +0400 Subject: [PATCH] Linux 5.8 __vmalloc compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pgprot argument has been removed from __vmalloc in Linux 5.8 [1], being `PAGE_KERNEL` always now. Detect this during configure to use the right function call in spl. [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/mm/vmalloc.c?h=next-20200605&id=88dca4ca5a93d2c09e5bbc6a62fbfc3af83c4fca Co-authored-by: Sebastian Gottschall Co-authored-by: Michael Niewöhner Signed-off-by: Sebastian Gottschall Signed-off-by: Michael Niewöhner --- config/kernel-kmem.m4 | 26 ++++++++++++++++++++++++++ config/kernel.m4 | 2 ++ module/os/linux/spl/spl-kmem-cache.c | 4 ++++ module/os/linux/spl/spl-kmem.c | 8 ++++++++ 4 files changed, 40 insertions(+) diff --git a/config/kernel-kmem.m4 b/config/kernel-kmem.m4 index 2862299168c1..43f9e72f88d8 100644 --- a/config/kernel-kmem.m4 +++ b/config/kernel-kmem.m4 @@ -80,3 +80,29 @@ AC_DEFUN([ZFS_AC_KERNEL_KVMALLOC], [ AC_MSG_RESULT(no) ]) ]) + +dnl # +dnl # 5.8 API, +dnl # __vmalloc PAGE_KERNEL removal +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL], [ + ZFS_LINUX_TEST_SRC([__vmalloc], [ + #include + #include + ],[ + void *p __attribute__ ((unused)); + + p = __vmalloc(0, GFP_KERNEL, PAGE_KERNEL); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL], [ + AC_MSG_CHECKING([whether __vmalloc(ptr, flags, pageflags) is available]) + ZFS_LINUX_TEST_RESULT([__vmalloc], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_VMALLOC_PAGE_KERNEL, 1, [__vmalloc page flags exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) +- \ No newline at end of file diff --git a/config/kernel.m4 b/config/kernel.m4 index 8cbf4aee9899..78b0ce4d3aa9 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -47,6 +47,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_USLEEP_RANGE ZFS_AC_KERNEL_SRC_KMEM_CACHE ZFS_AC_KERNEL_SRC_KVMALLOC + ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES ZFS_AC_KERNEL_SRC_INODE_LOCK @@ -141,6 +142,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_USLEEP_RANGE ZFS_AC_KERNEL_KMEM_CACHE ZFS_AC_KERNEL_KVMALLOC + ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES ZFS_AC_KERNEL_INODE_LOCK diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c index 2ebbb43d18b7..2f7a5523d15c 100644 --- a/module/os/linux/spl/spl-kmem-cache.c +++ b/module/os/linux/spl/spl-kmem-cache.c @@ -203,7 +203,11 @@ kv_alloc(spl_kmem_cache_t *skc, int size, int flags) ASSERT(ISP2(size)); ptr = (void *)__get_free_pages(lflags, get_order(size)); } else { +#ifdef HAVE_VMALLOC_PAGE_KERNEL ptr = __vmalloc(size, lflags | __GFP_HIGHMEM, PAGE_KERNEL); +#else + ptr = __vmalloc(size, lflags | __GFP_HIGHMEM); +#endif } /* Resulting allocated memory will be page aligned */ diff --git a/module/os/linux/spl/spl-kmem.c b/module/os/linux/spl/spl-kmem.c index b51e203edfe2..23ddefc5c418 100644 --- a/module/os/linux/spl/spl-kmem.c +++ b/module/os/linux/spl/spl-kmem.c @@ -202,7 +202,11 @@ spl_kvmalloc(size_t size, gfp_t lflags) return (ptr); } +#ifdef HAVE_VMALLOC_PAGE_KERNEL return (__vmalloc(size, lflags | __GFP_HIGHMEM, PAGE_KERNEL)); +#else + return (__vmalloc(size, lflags | __GFP_HIGHMEM)); +#endif } /* @@ -251,8 +255,12 @@ spl_kmem_alloc_impl(size_t size, int flags, int node) */ if (size > spl_kmem_alloc_max) { if (flags & KM_VMEM) { +#ifdef HAVE_VMALLOC_PAGE_KERNEL ptr = __vmalloc(size, lflags | __GFP_HIGHMEM, PAGE_KERNEL); +#else + ptr = __vmalloc(size, lflags | __GFP_HIGHMEM); +#endif } else { return (NULL); }