From: Shaun Tancheff Date: Sat, 15 Jun 2019 19:32:26 +0000 (-0500) Subject: LU-12355 llite: totalram_pages changed to atomic_long_t X-Git-Tag: 2.12.56~14 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5ca5b19e8efdfede8ec3405eaced7202984f396b LU-12355 llite: totalram_pages changed to atomic_long_t Kernel 5.0 changed totalram_pages to atomic_long_t Provide an abstracted accessor now that totalram_pages is now a function Linux-commit: ca79b0c211af63fa3276f0e3fd7dd9ada2439839 Test-Parameters: trivial Change-Id: I558e42074004e2ee5f79deea0d363e5bea332729 Signed-off-by: Shaun Tancheff Reviewed-on: https://review.whamcloud.com/35025 Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: Oleg Drokin --- diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 3116431..9f72305 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1072,6 +1072,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 +],[ + 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_NEW_KERNEL_WRITE # # 4.14 commit bdd1d2d3d251c65b74ac4493e08db18971c09240 changed @@ -1299,6 +1320,8 @@ LIBCFS_TIMER_SETUP LIBCFS_WAIT_VAR_EVENT # 4.17 LIBCFS_CLEAR_AND_WAKE_UP_BIT +# 5.0 +LIBCFS_MM_TOTALRAM_PAGES_FUNC ]) # LIBCFS_PROG_LINUX # diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index bec5974..b0b3af9 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -68,6 +68,16 @@ # endif /* !__CHECKER__ */ #endif /* !__must_hold */ +#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 diff --git a/libcfs/include/libcfs/libcfs_prim.h b/libcfs/include/libcfs/libcfs_prim.h index 6ad1ecb..1001362 100644 --- a/libcfs/include/libcfs/libcfs_prim.h +++ b/libcfs/include/libcfs/libcfs_prim.h @@ -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) diff --git a/libcfs/libcfs/linux/linux-tracefile.c b/libcfs/libcfs/linux/linux-tracefile.c index bb776a7..3bdfab4 100644 --- a/libcfs/libcfs/linux/linux-tracefile.c +++ b/libcfs/libcfs/linux/linux-tracefile.c @@ -305,7 +305,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); } diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 4d2f08c..7c572cb 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1268,8 +1268,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 diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 268f77a..6faf0b8 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -443,11 +443,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)) diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index e6fc27e..2376f62 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -351,11 +351,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", sbi->ll_fsname, PAGES_TO_MiB(pages_number), - PAGES_TO_MiB(totalram_pages)); + PAGES_TO_MiB(cfs_totalram_pages())); return -ERANGE; } @@ -521,10 +521,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", sbi->ll_fsname, - PAGES_TO_MiB(totalram_pages)); + PAGES_TO_MiB(cfs_totalram_pages())); RETURN(-ERANGE); } /* Allow enough cache so clients can make well-formed RPCs */ diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index 601806a..0c2e79a 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -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); diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 0945292..0b6c161 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -656,10 +656,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) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 519ef62..0af0a10 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -907,7 +907,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 */ diff --git a/lustre/obdclass/obd_sysfs.c b/lustre/obdclass/obd_sysfs.c index 7e1b277..35e4cd5 100644 --- a/lustre/obdclass/obd_sysfs.c +++ b/lustre/obdclass/obd_sysfs.c @@ -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; } diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index 46eae66..b4c0e35 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -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); diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 4e009e0..5929fe3 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -309,6 +309,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; @@ -326,8 +327,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; diff --git a/lustre/ptlrpc/sec_bulk.c b/lustre/ptlrpc/sec_bulk.c index 062de26..1dbf059 100644 --- a/lustre/ptlrpc/sec_bulk.c +++ b/lustre/ptlrpc/sec_bulk.c @@ -147,7 +147,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, @@ -772,9 +772,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);