From: Jian Yu Date: Tue, 11 May 2021 06:51:33 +0000 (-0700) Subject: LU-13783 libcfs: add cfs_kallsyms_lookup_name() X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=0188b3e75d232759081b05027e349e425677201a;p=fs%2Flustre-release.git LU-13783 libcfs: add cfs_kallsyms_lookup_name() 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 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-on: https://review.whamcloud.com/43648 Tested-by: jenkins Tested-by: Maloo --- diff --git a/libcfs/include/libcfs/linux/linux-misc.h b/libcfs/include/libcfs/linux/linux-misc.h index e547ce4..bbe1a61 100644 --- a/libcfs/include/libcfs/linux/linux-misc.h +++ b/libcfs/include/libcfs/linux/linux-misc.h @@ -41,6 +41,7 @@ #include #include #include +#include #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; } diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index b11f4b0..997f3bd 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -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 } diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index 0940c80..aa5430a 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -32,7 +32,6 @@ #define DEBUG_SUBSYSTEM S_LNET -#include #include #include #include @@ -48,6 +47,7 @@ #include #include +#include #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 } diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index b9daf524..2eb0de5 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -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; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 727a01a..abfa5be 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -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 } diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 8ba2fde..68b256e 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -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,