Whamcloud - gitweb
LU-12355 llite: totalram_pages changed to atomic_long_t 76/40376/3
authorShaun Tancheff <stancheff@cray.com>
Sat, 15 Jun 2019 19:32:26 +0000 (14:32 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jun 2021 22:26:11 +0000 (22:26 +0000)
Kernel 5.0 changed totalram_pages to atomic_long_t
Provide an abstracted accessor now that totalram_pages
is now a function

Conflicts:
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/libcfs.h
lustre/llite/lproc_llite.c

Lustre-commit: 5ca5b19e8efdfede8ec3405eaced7202984f396b
Lustre-change: https://review.whamcloud.com/35025

Linux-commit: ca79b0c211af63fa3276f0e3fd7dd9ada2439839

Test-Parameters: trivial
Change-Id: I558e42074004e2ee5f79deea0d363e5bea332729
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-on: https://review.whamcloud.com/40376
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_prim.h
libcfs/libcfs/linux/linux-tracefile.c
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/llite/lproc_llite.c
lustre/mdc/lproc_mdc.c
lustre/obdclass/class_obd.c
lustre/obdclass/lu_object.c
lustre/obdclass/obd_sysfs.c
lustre/osc/lproc_osc.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/sec_bulk.c

index 2e42cc8..e367e21 100644 (file)
@@ -1019,6 +1019,27 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_NEW_KERNEL_WRITE
 
 #
+# LIBCFS_MM_TOTALRAM_PAGES_FUNC
+#
+# kernel 5.0 commit ca79b0c211af63fa3276f0e3fd7dd9ada2439839
+# mm: convert totalram_pages and totalhigh_pages variables to atomic
+#
+AC_DEFUN([LIBCFS_MM_TOTALRAM_PAGES_FUNC], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if totalram_pages is a function],
+totalram_pages, [
+       #include <linux/mm.h>
+],[
+       totalram_pages_inc();
+],[
+       AC_DEFINE(HAVE_TOTALRAM_PAGES_AS_FUNC, 1,
+               [if totalram_pages is a function])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_MM_TOTALRAM_PAGES_FUNC
+
+#
 # LIBCFS_DEFINE_TIMER
 #
 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
@@ -1323,6 +1344,7 @@ LIBCFS_CLEAR_AND_WAKE_UP_BIT
 # 4.20
 LIBCFS_HAVE_IOV_ITER_TYPE
 # 5.0
+LIBCFS_MM_TOTALRAM_PAGES_FUNC
 LIBCFS_GET_REQUEST_KEY_AUTH
 # 5.3
 LIBCFS_LOOKUP_USER_KEY
index 2747f97..b372eea 100644 (file)
@@ -88,6 +88,16 @@ void lc_watchdog_disable(struct lc_watchdog *lcw);
 /* Clean up the watchdog */
 void lc_watchdog_delete(struct lc_watchdog *lcw);
 
+#ifdef HAVE_TOTALRAM_PAGES_AS_FUNC
+ #ifndef cfs_totalram_pages
+  #define cfs_totalram_pages() totalram_pages()
+ #endif
+#else
+ #ifndef cfs_totalram_pages
+  #define cfs_totalram_pages() totalram_pages
+ #endif
+#endif
+
 /* need both kernel and user-land acceptor */
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT    512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT    1023
index 6ad1ecb..1001362 100644 (file)
@@ -45,9 +45,9 @@
 #if BITS_PER_LONG == 32
 /* limit to lowmem on 32-bit systems */
 # define NUM_CACHEPAGES \
-       min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
+       min(cfs_totalram_pages(), 1UL << (30 - PAGE_SHIFT) * 3 / 4)
 #else
-# define NUM_CACHEPAGES totalram_pages
+# define NUM_CACHEPAGES cfs_totalram_pages()
 #endif
 
 static inline unsigned int memory_pressure_get(void)
index 54f1121..9685296 100644 (file)
@@ -267,7 +267,7 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
 
 int cfs_trace_max_debug_mb(void)
 {
-       int  total_mb = (totalram_pages >> (20 - PAGE_SHIFT));
+       int  total_mb = (cfs_totalram_pages() >> (20 - PAGE_SHIFT));
 
        return MAX(512, (total_mb * 80)/100);
 }
index 25b29fe..e4534a8 100644 (file)
@@ -1274,8 +1274,8 @@ static inline void client_adjust_max_dirty(struct client_obd *cli)
                        cli->cl_dirty_max_pages = dirty_max;
        }
 
-       if (cli->cl_dirty_max_pages > totalram_pages / 8)
-               cli->cl_dirty_max_pages = totalram_pages / 8;
+       if (cli->cl_dirty_max_pages > cfs_totalram_pages() / 8)
+               cli->cl_dirty_max_pages = cfs_totalram_pages() / 8;
 
        /* This value is exported to userspace through the max_dirty_mb
         * parameter.  So we round up the number of pages to make it a round
index af6577c..222457c 100644 (file)
@@ -426,11 +426,11 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
 
        if (!strcmp(name, LUSTRE_MDC_NAME)) {
                cli->cl_max_rpcs_in_flight = OBD_MAX_RIF_DEFAULT;
-       } else if (totalram_pages >> (20 - PAGE_SHIFT) <= 128 /* MB */) {
+       } else if (cfs_totalram_pages() >> (20 - PAGE_SHIFT) <= 128 /* MB */) {
                cli->cl_max_rpcs_in_flight = 2;
-       } else if (totalram_pages >> (20 - PAGE_SHIFT) <= 256 /* MB */) {
+       } else if (cfs_totalram_pages() >> (20 - PAGE_SHIFT) <= 256 /* MB */) {
                cli->cl_max_rpcs_in_flight = 3;
-       } else if (totalram_pages >> (20 - PAGE_SHIFT) <= 512 /* MB */) {
+       } else if (cfs_totalram_pages() >> (20 - PAGE_SHIFT) <= 512 /* MB */) {
                cli->cl_max_rpcs_in_flight = 4;
        } else {
                if (osc_on_mdt(obddev->obd_name))
index 7327ff7..765c4f5 100644 (file)
@@ -336,11 +336,11 @@ ll_max_readahead_mb_seq_write(struct file *file, const char __user *buffer,
                return rc;
 
        pages_number = round_up(ra_max_mb, 1024 * 1024) >> PAGE_SHIFT;
-       if (pages_number < 0 || pages_number > totalram_pages / 2) {
+       if (pages_number < 0 || pages_number > cfs_totalram_pages() / 2) {
                /* 1/2 of RAM */
                CERROR("%s: can't set max_readahead_mb=%llu > %luMB\n",
                       ll_get_fsname(sb, NULL, 0), PAGES_TO_MiB(pages_number),
-                      PAGES_TO_MiB(totalram_pages));
+                      PAGES_TO_MiB(cfs_totalram_pages()));
                return -ERANGE;
        }
 
@@ -506,10 +506,10 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file,
 
        pages_number >>= PAGE_SHIFT;
 
-       if (pages_number < 0 || pages_number > totalram_pages) {
+       if (pages_number < 0 || pages_number > cfs_totalram_pages()) {
                CERROR("%s: can't set max cache more than %lu MB\n",
                       ll_get_fsname(sb, NULL, 0),
-                      PAGES_TO_MiB(totalram_pages));
+                      PAGES_TO_MiB(cfs_totalram_pages()));
                RETURN(-ERANGE);
        }
        /* Allow enough cache so clients can make well-formed RPCs */
index 601806a..0c2e79a 100644 (file)
@@ -177,7 +177,7 @@ static ssize_t mdc_max_dirty_mb_seq_write(struct file *file,
        pages_number = round_up(pages_number, 1024 * 1024) >> PAGE_SHIFT;
        if (pages_number <= 0 ||
            pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
-           pages_number > totalram_pages / 4) /* 1/4 of RAM */
+           pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
                return -ERANGE;
 
        spin_lock(&cli->cl_loi_list_lock);
index 43eb96c..3cf9b86 100644 (file)
@@ -659,10 +659,10 @@ static int __init obdclass_init(void)
        /* Default the dirty page cache cap to 1/2 of system memory.
         * For clients with less memory, a larger fraction is needed
         * for other purposes (mostly for BGL). */
-       if (totalram_pages <= 512 << (20 - PAGE_SHIFT))
-               obd_max_dirty_pages = totalram_pages / 4;
+       if (cfs_totalram_pages() <= 512 << (20 - PAGE_SHIFT))
+               obd_max_dirty_pages = cfs_totalram_pages() / 4;
        else
-               obd_max_dirty_pages = totalram_pages / 2;
+               obd_max_dirty_pages = cfs_totalram_pages() / 2;
 
        err = obd_init_caches();
        if (err)
index 3fdb95a..42e880e 100644 (file)
@@ -978,7 +978,7 @@ static unsigned long lu_htable_order(struct lu_device *top)
          *
          * Size of lu_object is (arbitrary) taken as 1K (together with inode).
          */
-       cache_size = totalram_pages;
+       cache_size = cfs_totalram_pages();
 
 #if BITS_PER_LONG == 32
         /* limit hashtable size for lowmem systems to low RAM */
index 32f3a13..53b0b31 100644 (file)
@@ -161,7 +161,7 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
 
        val *= 1 << (20 - PAGE_SHIFT); /* convert to pages */
 
-       if (val > ((totalram_pages / 10) * 9)) {
+       if (val > ((cfs_totalram_pages() / 10) * 9)) {
                /* Somebody wants to assign too much memory to dirty pages */
                return -EINVAL;
        }
index c657da2..ab8cfca 100644 (file)
@@ -171,7 +171,7 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj,
        pages_number = MiB_TO_PAGES(max_dirty_mb);
 
        if (pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
-           pages_number > totalram_pages / 4) /* 1/4 of RAM */
+           pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
                return -ERANGE;
 
        spin_lock(&cli->cl_loi_list_lock);
index 90ed28e..546aa3c 100644 (file)
@@ -310,6 +310,7 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct ptlrpc_service *svc = m->private;
        unsigned long long val;
+       unsigned long long limit;
        int bufpages;
        int rc;
 
@@ -327,8 +328,9 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
         * will be upgraded */
        bufpages = (roundup_pow_of_two(svc->srv_buf_size) + PAGE_SIZE - 1) >>
                                                        PAGE_SHIFT;
+       limit = cfs_totalram_pages() / (2 * bufpages);
        /* do not allow history to consume more than half max number of rqbds */
-       if ((svc->srv_nrqbds_max == 0 && val > totalram_pages / (2 * bufpages)) ||
+       if ((svc->srv_nrqbds_max == 0 && val > limit) ||
            (svc->srv_nrqbds_max != 0 && val > svc->srv_nrqbds_max / 2))
                return -ERANGE;
 
index db87414..216c2f2 100644 (file)
@@ -155,7 +155,7 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
                   "max waitqueue depth:     %u\n"
                   "max wait time ms:        %lld\n"
                   "out of mem:              %lu\n",
-                  totalram_pages, PAGES_PER_POOL,
+                  cfs_totalram_pages(), PAGES_PER_POOL,
                   page_pools.epp_max_pages,
                   page_pools.epp_max_pools,
                   page_pools.epp_total_pages,
@@ -775,9 +775,9 @@ int sptlrpc_enc_pool_init(void)
        DEF_SHRINKER_VAR(shvar, enc_pools_shrink,
                         enc_pools_shrink_count, enc_pools_shrink_scan);
 
-       page_pools.epp_max_pages = totalram_pages / 8;
+       page_pools.epp_max_pages = cfs_totalram_pages() / 8;
        if (enc_pool_max_memory_mb > 0 &&
-           enc_pool_max_memory_mb <= (totalram_pages >> mult))
+           enc_pool_max_memory_mb <= (cfs_totalram_pages() >> mult))
                page_pools.epp_max_pages = enc_pool_max_memory_mb << mult;
 
        page_pools.epp_max_pools = npages_to_npools(page_pools.epp_max_pages);