Whamcloud - gitweb
LU-13783 libcfs: provide fallback kallsyms_lookup_name() 26/40826/6
authorMr NeilBrown <neilb@suse.de>
Tue, 2 Mar 2021 00:49:01 +0000 (11:49 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 6 Apr 2021 03:02:15 +0000 (03:02 +0000)
Since Linux 5.7, kallsyms_lookup_name() is no longer exported, so we
cannot rely on it.

So test for this, and when not available provide a fallback which just
returns NULL.

As this was the only way to access apply_workqueue_attrs() in recent
kernels, we need to cope with the absence of that function.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I09cc00047ec163a9395c5acd415505a8586e4e99
Reviewed-on: https://review.whamcloud.com/40826
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-misc.h
libcfs/libcfs/linux/linux-prim.c

index 6b20241..d3dcc6c 100644 (file)
@@ -1290,6 +1290,17 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_CACHE_DETAIL_WRITERS
 
 #
 ]) # LIBCFS_CACHE_DETAIL_WRITERS
 
 #
+# LIBCFS_KALLSYMS_LOOKUP
+#
+# kernel v5.6-11591-g0bd476e6c671
+# kallsyms: unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()
+AC_DEFUN([LIBCFS_KALLSYMS_LOOKUP], [
+LB_CHECK_EXPORT([kallsyms_lookup_name], [kernel/kallsyms.c],
+       [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
+               [kallsyms_lookup_name is exported by kernel])])
+]) # LIBCFS_KALLSYMS_LOOKUP
+
+#
 # LIBCFS_VMALLOC_2ARGS
 #
 # kernel v5.8-rc1~201^2~19
 # LIBCFS_VMALLOC_2ARGS
 #
 # kernel v5.8-rc1~201^2~19
@@ -1475,6 +1486,8 @@ LIBCFS_LOOKUP_USER_KEY
 LIBCFS_FORCE_SIG_WITH_TASK
 LIBCFS_CACHE_DETAIL_WRITERS
 LIBCFS_HAVE_NR_UNSTABLE_NFS
 LIBCFS_FORCE_SIG_WITH_TASK
 LIBCFS_CACHE_DETAIL_WRITERS
 LIBCFS_HAVE_NR_UNSTABLE_NFS
+# 5.7
+LIBCFS_KALLSYMS_LOOKUP
 # 5.8
 LIBCFS_HAVE_MMAP_LOCK
 LIBCFS_KERNEL_SETSOCKOPT
 # 5.8
 LIBCFS_HAVE_MMAP_LOCK
 LIBCFS_KERNEL_SETSOCKOPT
index 2309c6d..1db78bb 100644 (file)
@@ -146,4 +146,11 @@ void cfs_arch_init(void);
 #define sizeof_field(type, member)     FIELD_SIZEOF(type, member)
 #endif
 
 #define sizeof_field(type, member)     FIELD_SIZEOF(type, member)
 #endif
 
+#ifndef HAVE_KALLSYMS_LOOKUP_NAME
+static inline void *kallsyms_lookup_name(char *func)
+{
+       return NULL;
+}
+#endif
+
 #endif /* __LIBCFS_LINUX_MISC_H__ */
 #endif /* __LIBCFS_LINUX_MISC_H__ */
index 7fe3df3..0940c80 100644 (file)
@@ -109,7 +109,9 @@ static int (*cfs_apply_workqueue_attrs_t)(struct workqueue_struct *wq,
 int cfs_apply_workqueue_attrs(struct workqueue_struct *wq,
                              const struct workqueue_attrs *attrs)
 {
 int cfs_apply_workqueue_attrs(struct workqueue_struct *wq,
                              const struct workqueue_attrs *attrs)
 {
-       return cfs_apply_workqueue_attrs_t(wq, attrs);
+       if (cfs_apply_workqueue_attrs_t)
+               return cfs_apply_workqueue_attrs_t(wq, attrs);
+       return 0;
 }
 EXPORT_SYMBOL_GPL(cfs_apply_workqueue_attrs);
 
 }
 EXPORT_SYMBOL_GPL(cfs_apply_workqueue_attrs);