From 2a32eaa35dd7b96bb29f6a17991f48fe07fa833e Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Wed, 21 Oct 2020 15:26:35 +1100 Subject: [PATCH] LU-13783 libcfs: support __vmalloc with only 2 args. Since v5.8-rc1~201^2~19 Commit 88dca4ca5a93 ("mm: remove the pgprot argument to __vmalloc") __vmalloc only takes 2 arguments. So introduce __ll_vmalloc which takes 2 args, and calls __vmalloc with correct number of args. Test-Parameters: trivial Signed-off-by: Mr NeilBrown Change-Id: I2c89512a12e28b27544a891620e448a9b752b089 Reviewed-on: https://review.whamcloud.com/40328 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Aurelien Degremont Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 18 ++++++++++++++++++ libcfs/include/libcfs/linux/linux-mem.h | 6 ++++++ lnet/klnds/gnilnd/gnilnd.h | 8 +++----- lustre/include/obd_support.h | 3 +-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index c787b14..6b20241 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1290,6 +1290,23 @@ EXTRA_KCFLAGS="$tmp_flags" ]) # LIBCFS_CACHE_DETAIL_WRITERS # +# LIBCFS_VMALLOC_2ARGS +# +# kernel v5.8-rc1~201^2~19 +# mm: remove the pgprot argument to __vmalloc +AC_DEFUN([LIBCFS_VMALLOC_2ARGS], [ +LB_CHECK_COMPILE([if __vmalloc has 2 args], +vmalloc_2args, [ + #include +],[ + __vmalloc(0, 0); +],[ + AC_DEFINE(HAVE_VMALLOC_2ARGS, 1, + [__vmalloc only takes 2 args.]) +]) +]) # LIBCFS_VMALLOC_2ARGS + +# # LIBCFS_HAVE_NR_UNSTABLE_NFS # # kernel v5.8-rc1~201^2~75 @@ -1461,6 +1478,7 @@ LIBCFS_HAVE_NR_UNSTABLE_NFS # 5.8 LIBCFS_HAVE_MMAP_LOCK LIBCFS_KERNEL_SETSOCKOPT +LIBCFS_VMALLOC_2ARGS ]) # LIBCFS_PROG_LINUX # diff --git a/libcfs/include/libcfs/linux/linux-mem.h b/libcfs/include/libcfs/linux/linux-mem.h index 11d8fab..69d027f 100644 --- a/libcfs/include/libcfs/linux/linux-mem.h +++ b/libcfs/include/libcfs/linux/linux-mem.h @@ -131,4 +131,10 @@ static inline void mmap_read_unlock(struct mm_struct *mm) } #endif +#ifdef HAVE_VMALLOC_2ARGS +#define __ll_vmalloc(size, flags) __vmalloc(size, flags) +#else +#define __ll_vmalloc(size, flags) __vmalloc(size, flags, PAGE_KERNEL) +#endif + #endif /* __LINUX_CFS_MEM_H__ */ diff --git a/lnet/klnds/gnilnd/gnilnd.h b/lnet/klnds/gnilnd/gnilnd.h index 03cdd07..3c7f742 100644 --- a/lnet/klnds/gnilnd/gnilnd.h +++ b/lnet/klnds/gnilnd/gnilnd.h @@ -997,12 +997,10 @@ static inline void *kgnilnd_vzalloc(int size) { void *ret; if (*kgnilnd_tunables.kgn_vzalloc_noretry) - ret = __vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_NORETRY | - __GFP_ZERO, - PAGE_KERNEL); + ret = __ll_vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_ZERO | + __GFP_NORETRY); else - ret = __vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_ZERO, - PAGE_KERNEL); + ret = __ll_vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_ZERO); LIBCFS_ALLOC_POST(ret, size); return ret; diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 1b6bba4..f820c87 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -834,8 +834,7 @@ do { \ #define __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size) \ do { \ (ptr) = cptab == NULL ? \ - __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO, \ - PAGE_KERNEL) : \ + __ll_vmalloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO) : \ cfs_cpt_vzalloc(cptab, cpt, size); \ if (unlikely((ptr) == NULL)) { \ CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \ -- 1.8.3.1