Whamcloud - gitweb
LU-13783 libcfs: add cfs_kallsyms_lookup_name() 96/43296/3
authorJian Yu <yujian@whamcloud.com>
Tue, 13 Apr 2021 05:12:27 +0000 (22:12 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 28 Apr 2021 02:11:20 +0000 (02:11 +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.

Fixes: d7249d9d70a ("LU-13783 libcfs: provide fallback kallsyms_lookup_name()")
Change-Id: I4b2d4499948a8586b48db68484491ec76c3a609d
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43296
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@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 282e6ab..242105b 100644 (file)
@@ -40,6 +40,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
@@ -145,8 +146,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 52e3bde..10e3eee 100644 (file)
@@ -515,7 +515,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 7a7a534..c5918ad 100644 (file)
@@ -31,7 +31,6 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <linux/kallsyms.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -47,6 +46,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)
@@ -124,10 +124,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 272437d..4ded8b4 100644 (file)
@@ -291,8 +291,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 297d7ba..c001d85 100644 (file)
@@ -959,7 +959,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 03dee69..2971dec 100644 (file)
@@ -8406,7 +8406,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,