Whamcloud - gitweb
LU-13783 libcfs: add cfs_kallsyms_lookup_name()
authorJian Yu <yujian@whamcloud.com>
Tue, 11 May 2021 06:51:33 +0000 (23:51 -0700)
committerLi Xi <lixi@ddn.com>
Tue, 18 May 2021 01:47:20 +0000 (01:47 +0000)
The inline kallsyms_lookup_name() added by
commit d7249d9d70a caused the following failures:

libcfs/include/libcfs/linux/linux-misc.h:150:21:
error: conflicting types for ‘kallsyms_lookup_name’
  150 | static inline void *kallsyms_lookup_name(char *func)
      |                     ^~~~~~~~~~~~~~~~~~~~

include/linux/kallsyms.h:76:15:
note: previous declaration of ‘kallsyms_lookup_name’ was here
   76 | unsigned long kallsyms_lookup_name(const char *name);
      |               ^~~~~~~~~~~~~~~~~~~~

This patch removes the inline kallsyms_lookup_name() definition
from linux-misc.h and adds cfs_kallsyms_lookup_name() to wrap
kallsyms_lookup_name() if it is exported or return NULL in case of
kallsyms_lookup_name() is not exported.

Lustre-change: https://review.whamcloud.com/43296
Lustre-commit: 783002035ae9612b5b0aa80f2342a2ee9e81c374

Fixes: d7249d9d70a ("LU-13783 libcfs: provide fallback kallsyms_lookup_name()")
Change-Id: I4b2d4499948a8586b48db68484491ec76c3a609d
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/43648
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/include/libcfs/linux/linux-misc.h
libcfs/libcfs/debug.c
libcfs/libcfs/linux/linux-prim.c
lustre/llite/vvp_dev.c
lustre/llite/vvp_io.c
lustre/osd-ldiskfs/osd_handler.c

index e547ce4..bbe1a61 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/mutex.h>
 #include <linux/user_namespace.h>
 #include <linux/uio.h>
+#include <linux/kallsyms.h>
 
 #ifndef HAVE_IOV_ITER_TYPE
 #ifdef HAVE_IOV_ITER_HAS_TYPE_MEMBER
@@ -148,8 +149,13 @@ void cfs_arch_init(void);
 #define sizeof_field(type, member)     FIELD_SIZEOF(type, member)
 #endif
 
-#ifndef HAVE_KALLSYMS_LOOKUP_NAME
-static inline void *kallsyms_lookup_name(char *func)
+#ifdef HAVE_KALLSYMS_LOOKUP_NAME
+static inline void *cfs_kallsyms_lookup_name(const char *name)
+{
+       return (void *)kallsyms_lookup_name(name);
+}
+#else
+static inline void *cfs_kallsyms_lookup_name(const char *name)
 {
        return NULL;
 }
index b11f4b0..997f3bd 100644 (file)
@@ -516,7 +516,7 @@ void __init cfs_debug_init(void)
 {
 #ifdef CONFIG_ARCH_STACKWALK
        task_dump_stack = (void *)
-                       kallsyms_lookup_name("stack_trace_save_tsk");
+                       cfs_kallsyms_lookup_name("stack_trace_save_tsk");
 
 #endif
 }
index 0940c80..aa5430a 100644 (file)
@@ -32,7 +32,6 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <linux/kallsyms.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -48,6 +47,7 @@
 
 #include <libcfs/linux/linux-time.h>
 #include <libcfs/linux/linux-wait.h>
+#include <libcfs/linux/linux-misc.h>
 
 #ifndef HAVE_KTIME_GET_TS64
 void ktime_get_ts64(struct timespec64 *ts)
@@ -125,10 +125,10 @@ void __init cfs_arch_init(void)
        wait_bit_init();
 #endif
        cfs_apply_workqueue_attrs_t =
-               (void *)kallsyms_lookup_name("apply_workqueue_attrs");
+               (void *)cfs_kallsyms_lookup_name("apply_workqueue_attrs");
 #ifndef HAVE_XARRAY_SUPPORT
        radix_tree_node_cachep =
-               (void *)kallsyms_lookup_name("radix_tree_node_cachep");
+               (void *)cfs_kallsyms_lookup_name("radix_tree_node_cachep");
 #endif
 }
 
index b9daf52..2eb0de5 100644 (file)
@@ -292,8 +292,7 @@ int vvp_global_init(void)
         * Kernel v5.2-5678-gac1c3e4 no longer exports account_page_dirtied
         */
        vvp_account_page_dirtied = (void *)
-               kallsyms_lookup_name("account_page_dirtied");
-       BUG_ON(!vvp_account_page_dirtied);
+               cfs_kallsyms_lookup_name("account_page_dirtied");
 #endif
 
        return 0;
index 727a01a..abfa5be 100644 (file)
@@ -950,7 +950,8 @@ static inline void ll_account_page_dirtied(struct page *page,
 #elif defined(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT)
        account_page_dirtied(page, mapping);
 #else
-       vvp_account_page_dirtied(page, mapping);
+       if (vvp_account_page_dirtied)
+               vvp_account_page_dirtied(page, mapping);
 #endif
 }
 
index 8ba2fde..68b256e 100644 (file)
@@ -8401,7 +8401,7 @@ static int __init osd_init(void)
 
 #ifdef CONFIG_KALLSYMS
        priv_security_file_alloc =
-               (void *)kallsyms_lookup_name("security_file_alloc");
+               (void *)cfs_kallsyms_lookup_name("security_file_alloc");
 #endif
 
        rc = class_register_type(&osd_obd_device_ops, NULL, true, NULL,