From 788e464a7215e09987e05eeeeac107642e80cea5 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Mon, 24 Feb 2020 13:11:03 -0600 Subject: [PATCH] LU-13288 llite: Find account_page_dirtied on module init 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 Change-Id: Ie27abb07ffbf9e5be67fe64601ebc62409f829fd Reviewed-on: https://review.whamcloud.com/37686 Tested-by: jenkins Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: Shuichi Ihara Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 12 +++--------- lustre/llite/vvp_dev.c | 10 ++++++++++ lustre/llite/vvp_internal.h | 5 +++++ lustre/llite/vvp_io.c | 17 ++++------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index d609a4c..8dc06cb 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 -],[ - 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 # diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index d36aed3..bec0f9e 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -40,6 +40,7 @@ #include #include "llite_internal.h" #include "vvp_internal.h" +#include /***************************************************************************** * @@ -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: diff --git a/lustre/llite/vvp_internal.h b/lustre/llite/vvp_internal.h index 5384e0e..2302957 100644 --- a/lustre/llite/vvp_internal.h +++ b/lustre/llite/vvp_internal.h @@ -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 */ diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index c29c51a..94f9899 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -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 } -- 1.8.3.1