Whamcloud - gitweb
LU-13288 llite: Find account_page_dirtied on module init 86/37686/3
authorShaun Tancheff <shaun.tancheff@hpe.com>
Mon, 24 Feb 2020 19:11:03 +0000 (13:11 -0600)
committerOleg Drokin <green@whamcloud.com>
Sun, 1 Mar 2020 05:36:07 +0000 (05:36 +0000)
Kernel v5.2-5678-gac1c3e4 no longer exports account_page_dirtied
Use kallsyms_lookup_name to find and use it as
vvp_account_page_dirtied on module init to avoid any
performance regressions due to symbol_get.

Test-Parameters: clientdistro=el8.1
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: Ie27abb07ffbf9e5be67fe64601ebc62409f829fd
Reviewed-on: https://review.whamcloud.com/37686
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Shuichi Ihara <sihara@ddn.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/llite/vvp_dev.c
lustre/llite/vvp_internal.h
lustre/llite/vvp_io.c

index d609a4c..8dc06cb 100644 (file)
@@ -2120,15 +2120,9 @@ EXTRA_KCFLAGS="$tmp_flags"
 # After 5.2 kernel page dirtied is not exported
 #
 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED], [
-LB_CHECK_COMPILE([if 'account_page_dirtied' is exported],
-account_page_dirtied, [
-       #include <linux/mm.h>
-],[
-       account_page_dirtied(NULL, NULL);
-],[
-       AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED, 1,
-               [account_page_dirtied is available])
-])
+LB_CHECK_EXPORT([account_page_dirtied], [mm/page-writeback.c],
+       [AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT, 1,
+                       [account_page_dirtied is exported])])
 ]) # LC_ACCOUNT_PAGE_DIRTIED
 
 #
index d36aed3..bec0f9e 100644 (file)
@@ -40,6 +40,7 @@
 #include <obd.h>
 #include "llite_internal.h"
 #include "vvp_internal.h"
+#include <linux/kallsyms.h>
 
 /*****************************************************************************
  *
@@ -281,6 +282,15 @@ int vvp_global_init(void)
        if (rc != 0)
                goto out_kmem;
 
+#ifndef HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT
+       /*
+        * 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);
+#endif
+
        return 0;
 
 out_kmem:
index 5384e0e..2302957 100644 (file)
@@ -319,6 +319,11 @@ struct lu_object *vvp_object_alloc(const struct lu_env *env,
 int vvp_global_init(void);
 void vvp_global_fini(void);
 
+#ifndef HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT
+typedef unsigned int (*vvp_account_page_dirtied)(struct page *page,
+                                                struct address_space *mapping);
+#endif
+
 extern const struct file_operations vvp_dump_pgcache_file_ops;
 
 #endif /* VVP_INTERNAL_H */
index c29c51a..94f9899 100644 (file)
@@ -929,7 +929,7 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io,
 
 /*
  * Kernels 4.2 - 4.5 pass memcg argument to account_page_dirtied()
- * Kernel v5.2-5678-gac1c3e4 no longer exports account_page_dirtied 
+ * Kernel v5.2-5678-gac1c3e4 no longer exports account_page_dirtied
  */
 static inline void ll_account_page_dirtied(struct page *page,
                                           struct address_space *mapping)
@@ -939,19 +939,10 @@ static inline void ll_account_page_dirtied(struct page *page,
 
        account_page_dirtied(page, mapping, memcg);
        mem_cgroup_end_page_stat(memcg);
-#elif defined HAVE_ACCOUNT_PAGE_DIRTIED
-       account_page_dirtied(page, mapping, memcg);
+#elif defined(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT)
+       account_page_dirtied(page, mapping);
 #else
-       typedef unsigned int (dirtied_t)(struct page *pg,
-                                        struct address_space *as);
-       const char *symbol = "account_page_dirtied";
-       static dirtied_t *dirtied = NULL;
-
-       if (!dirtied)
-               dirtied = (dirtied_t *)symbol_get(symbol);
-
-       if (dirtied)
-               dirtied(page, mapping);
+       vvp_account_page_dirtied(page, mapping);
 #endif
 }