Skip to content

Commit

Permalink
Linux 5.8 __vmalloc compat
Browse files Browse the repository at this point in the history
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 <s.gottschall@dd-wrt.com>
Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
  • Loading branch information
BrainSlayer and c0d3z3r0 committed Jun 8, 2020
1 parent c9e319f commit cbc8971
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions config/kernel-kmem.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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 <linux/mm.h>
#include <linux/vmalloc.h>
],[
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)
])
])
-
2 changes: 2 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions module/os/linux/spl/spl-kmem-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 8 additions & 0 deletions module/os/linux/spl/spl-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/*
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit cbc8971

Please sign in to comment.