ClearPageReserved(virt_to_page(start));
                init_page_count(virt_to_page(start));
                free_page(start);
-               totalram_pages++;
+               totalram_pages_inc();
        }
 }
 #endif
                ClearPageReserved(virt_to_page(addr));
                init_page_count(virt_to_page(addr));
                free_page(addr);
-               totalram_pages++;
+               totalram_pages_inc();
                addr += PAGE_SIZE;
        }
 
 
 
                pa->page[pa->index++] = addr;
                loaned_pages++;
-               totalram_pages--;
+               totalram_pages_dec();
                spin_unlock(&cmm_lock);
                nr--;
        }
                free_page(addr);
                loaned_pages--;
                nr--;
-               totalram_pages++;
+               totalram_pages_inc();
        }
        spin_unlock(&cmm_lock);
        cmm_dbg("End request with %ld pages unfulfilled\n", nr);
        int rc;
        struct hvcall_mpp_data mpp_data;
        signed long active_pages_target, page_loan_request, target;
-       signed long total_pages = totalram_pages + loaned_pages;
+       signed long total_pages = totalram_pages() + loaned_pages;
        signed long min_mem_pages = (min_mem_mb * 1024 * 1024) / PAGE_SIZE;
 
        rc = h_get_mpp(&mpp_data);
 
        cmm_dbg("delta = %ld, loaned = %lu, target = %lu, oom = %lu, totalram = %lu\n",
                page_loan_request, loaned_pages, loaned_pages_target,
-               oom_freed_pages, totalram_pages);
+               oom_freed_pages, totalram_pages());
 }
 
 static struct notifier_block cmm_oom_nb = {
                        free_page(pa_curr->page[idx]);
                        freed++;
                        loaned_pages--;
-                       totalram_pages++;
+                       totalram_pages_inc();
                        pa_curr->page[idx] = pa_last->page[--pa_last->index];
                        if (pa_last->index == 0) {
                                if (pa_curr == pa_last)
 
        order = 7;
 
        /* Limit number of empty zero pages for small memory sizes */
-       while (order > 2 && (totalram_pages >> 10) < (1UL << order))
+       while (order > 2 && (totalram_pages() >> 10) < (1UL << order))
                order--;
 
        empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 
 
        /* this will put all low memory onto the freelists */
        memblock_free_all();
-       max_low_pfn = totalram_pages;
+       max_low_pfn = totalram_pages();
        max_pfn = max_low_pfn;
        mem_init_print_info(NULL);
        kmalloc_ok = 1;
 
                               size_t len, loff_t *ppos)
 {
        ssize_t ret = -EINVAL;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
 
        if ((len >> PAGE_SHIFT) > nr_pages) {
                pr_err("too much data (max %ld pages)\n", nr_pages);
 
        long memory, index, result;
 
 #if PAGE_SHIFT < 20
-       memory = totalram_pages >> (20 - PAGE_SHIFT);
+       memory = totalram_pages() >> (20 - PAGE_SHIFT);
 #else
-       memory = totalram_pages << (PAGE_SHIFT - 20);
+       memory = totalram_pages() << (PAGE_SHIFT - 20);
 #endif
        index = 1;
 
 
         * If there's no chance of allocating enough pages for the whole
         * object, bail early.
         */
-       if (page_count > totalram_pages)
+       if (page_count > totalram_pages())
                return -ENOMEM;
 
        st = kmalloc(sizeof(*st), GFP_KERNEL);
 
         * This should ensure that we do not run into the oomkiller during
         * the test and take down the machine wilfully.
         */
-       limit = totalram_pages << PAGE_SHIFT;
+       limit = totalram_pages() << PAGE_SHIFT;
        limit = min(ppgtt->vm.total, limit);
 
        /* Check we can allocate the entire range */
                                     u64 hole_start, u64 hole_end,
                                     unsigned long end_time))
 {
-       const u64 limit = totalram_pages << PAGE_SHIFT;
+       const u64 limit = totalram_pages() << PAGE_SHIFT;
        struct i915_gem_context *ctx;
        struct i915_hw_ppgtt *ppgtt;
        IGT_TIMEOUT(end_time);
 
 static unsigned long compute_balloon_floor(void)
 {
        unsigned long min_pages;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
 #define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
        /* Simple continuous piecewiese linear function:
         *  max MiB -> min MiB  gradient
 
        dm_bufio_allocated_vmalloc = 0;
        dm_bufio_current_allocated = 0;
 
-       mem = (__u64)mult_frac(totalram_pages - totalhigh_pages,
+       mem = (__u64)mult_frac(totalram_pages() - totalhigh_pages(),
                               DM_BUFIO_MEMORY_PERCENT, 100) << PAGE_SHIFT;
 
        if (mem > ULONG_MAX)
 
 
 static void crypt_calculate_pages_per_client(void)
 {
-       unsigned long pages = (totalram_pages - totalhigh_pages) * DM_CRYPT_MEMORY_PERCENT / 100;
+       unsigned long pages = (totalram_pages() - totalhigh_pages()) * DM_CRYPT_MEMORY_PERCENT / 100;
 
        if (!dm_crypt_clients_n)
                return;
 
        journal_pages = roundup((__u64)ic->journal_sections * ic->journal_section_sectors,
                                PAGE_SIZE >> SECTOR_SHIFT) >> (PAGE_SHIFT - SECTOR_SHIFT);
        journal_desc_size = journal_pages * sizeof(struct page_list);
-       if (journal_pages >= totalram_pages - totalhigh_pages || journal_desc_size > ULONG_MAX) {
+       if (journal_pages >= totalram_pages() - totalhigh_pages() || journal_desc_size > ULONG_MAX) {
                *error = "Journal doesn't fit into memory";
                r = -ENOMEM;
                goto bad;
 
        a = shared_memory_amount + alloc_size;
        if (a < shared_memory_amount)
                return false;
-       if (a >> PAGE_SHIFT > totalram_pages / DM_STATS_MEMORY_FACTOR)
+       if (a >> PAGE_SHIFT > totalram_pages() / DM_STATS_MEMORY_FACTOR)
                return false;
 #ifdef CONFIG_MMU
        if (a > (VMALLOC_END - VMALLOC_START) / DM_STATS_VMALLOC_FACTOR)
 
        /* Set PTCM to 96K and DTCM to 32K */
        vpu_cfg_writel(vpu, 0x2, VPU_TCM_CFG);
 
-       vpu->enable_4GB = !!(totalram_pages > (SZ_2G >> PAGE_SHIFT));
+       vpu->enable_4GB = !!(totalram_pages() > (SZ_2G >> PAGE_SHIFT));
        dev_info(dev, "4GB mode %u\n", vpu->enable_4GB);
 
        if (vpu->enable_4GB) {
 
        unsigned long status;
        unsigned long limit;
 
-       limit = totalram_pages;
+       limit = totalram_pages();
 
        /* Ensure limit fits in 32-bits */
        if (limit != (u32)limit)
 
        ** Hot-Plug/Removal of PCI cards. (aka PCI OLARD).
        */
 
-       iova_space_size = (u32) (totalram_pages / count_parisc_driver(&ccio_driver));
+       iova_space_size = (u32) (totalram_pages() / count_parisc_driver(&ccio_driver));
 
        /* limit IOVA space size to 1MB-1GB */
 
 
        DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n",
                        __func__, ioc->ioc_regs,
-                       (unsigned long) totalram_pages >> (20 - PAGE_SHIFT),
+                       (unsigned long) totalram_pages() >> (20 - PAGE_SHIFT),
                        iova_space_size>>20,
                        iov_order + PAGE_SHIFT);
 
 
        ** for DMA hints - ergo only 30 bits max.
        */
 
-       iova_space_size = (u32) (totalram_pages/global_ioc_cnt);
+       iova_space_size = (u32) (totalram_pages()/global_ioc_cnt);
 
        /* limit IOVA space size to 1MB-1GB */
        if (iova_space_size < (1 << (20 - PAGE_SHIFT))) {
        DBG_INIT("%s() hpa 0x%lx mem %ldMB IOV %dMB (%d bits)\n",
                        __func__,
                        ioc->ioc_hpa,
-                       (unsigned long) totalram_pages >> (20 - PAGE_SHIFT),
+                       (unsigned long) totalram_pages() >> (20 - PAGE_SHIFT),
                        iova_space_size>>20,
                        iov_order + PAGE_SHIFT);
 
 
        unsigned long size_remaining = PAGE_ALIGN(size);
        unsigned int max_order = orders[0];
 
-       if (size / PAGE_SIZE > totalram_pages / 2)
+       if (size / PAGE_SIZE > totalram_pages() / 2)
                return -ENOMEM;
 
        INIT_LIST_HEAD(&pages);
 
        bool reset_timer = false;
 
        if (xen_selfballooning_enabled) {
-               cur_pages = totalram_pages;
+               cur_pages = totalram_pages();
                tgt_pages = cur_pages; /* default is no change */
                goal_pages = vm_memory_committed() +
                                totalreserve_pages +
                if (tgt_pages < floor_pages)
                        tgt_pages = floor_pages;
                balloon_set_new_target(tgt_pages +
-                       balloon_stats.current_pages - totalram_pages);
+                       balloon_stats.current_pages - totalram_pages());
                reset_timer = true;
        }
 #ifdef CONFIG_FRONTSWAP
         * much more reliably and response faster in some cases.
         */
        if (!selfballoon_reserved_mb) {
-               reserve_pages = totalram_pages / 10;
+               reserve_pages = totalram_pages() / 10;
                selfballoon_reserved_mb = PAGES2MB(reserve_pages);
        }
        schedule_delayed_work(&selfballoon_worker, selfballoon_interval * HZ);
 
         * This allows larger machines to have larger/more transfers.
         * Limit the default to 256M
         */
-       congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
+       congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
        if (congestion_kb > 256*1024)
                congestion_kb = 256*1024;
 
 
 void __init files_maxfiles_init(void)
 {
        unsigned long n;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
        unsigned long memreserve = (nr_pages - nr_free_pages()) * 3/2;
 
        memreserve = min(memreserve, nr_pages - 1);
 
 static void sanitize_global_limit(unsigned *limit)
 {
        if (*limit == 0)
-               *limit = ((totalram_pages << PAGE_SHIFT) >> 13) /
+               *limit = ((totalram_pages() << PAGE_SHIFT) >> 13) /
                         sizeof(struct fuse_req);
 
        if (*limit >= 1 << 16)
 
         * This allows larger machines to have larger/more transfers.
         * Limit the default to 256M
         */
-       nfs_congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
+       nfs_congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
        if (nfs_congestion_kb > 256*1024)
                nfs_congestion_kb = 256*1024;
 
 
 nfsd_cache_size_limit(void)
 {
        unsigned int limit;
-       unsigned long low_pages = totalram_pages - totalhigh_pages;
+       unsigned long low_pages = totalram_pages() - totalhigh_pages();
 
        limit = (16 * int_sqrt(low_pages)) << (PAGE_SHIFT-10);
        return min_t(unsigned int, limit, 256*1024);
 
                return kmalloc(PAGE_SIZE, gfp_mask & ~__GFP_HIGHMEM);
                /* return (void *)__get_free_page(gfp_mask); */
        }
-       if (likely((size >> PAGE_SHIFT) < totalram_pages))
+       if (likely((size >> PAGE_SHIFT) < totalram_pages()))
                return __vmalloc(size, gfp_mask, PAGE_KERNEL);
        return NULL;
 }
 
 static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
                          struct pid *pid, struct task_struct *task)
 {
-       unsigned long totalpages = totalram_pages + total_swap_pages;
+       unsigned long totalpages = totalram_pages() + total_swap_pages;
        unsigned long points = 0;
 
        points = oom_badness(task, NULL, NULL, totalpages) *
 
 
 /* declarations for linux/mm/highmem.c */
 unsigned int nr_free_highpages(void);
-extern unsigned long totalhigh_pages;
+extern atomic_long_t _totalhigh_pages;
+static inline unsigned long totalhigh_pages(void)
+{
+       return (unsigned long)atomic_long_read(&_totalhigh_pages);
+}
+
+static inline void totalhigh_pages_inc(void)
+{
+       atomic_long_inc(&_totalhigh_pages);
+}
+
+static inline void totalhigh_pages_dec(void)
+{
+       atomic_long_dec(&_totalhigh_pages);
+}
+
+static inline void totalhigh_pages_add(long count)
+{
+       atomic_long_add(count, &_totalhigh_pages);
+}
+
+static inline void totalhigh_pages_set(long val)
+{
+       atomic_long_set(&_totalhigh_pages, val);
+}
 
 void kmap_flush_unused(void);
 
        return virt_to_page(addr);
 }
 
-#define totalhigh_pages 0UL
+static inline unsigned long totalhigh_pages(void) { return 0UL; }
 
 #ifndef ARCH_HAS_KMAP
 static inline void *kmap(struct page *page)
 
 static inline void set_max_mapnr(unsigned long limit) { }
 #endif
 
-extern unsigned long totalram_pages;
+extern atomic_long_t _totalram_pages;
+static inline unsigned long totalram_pages(void)
+{
+       return (unsigned long)atomic_long_read(&_totalram_pages);
+}
+
+static inline void totalram_pages_inc(void)
+{
+       atomic_long_inc(&_totalram_pages);
+}
+
+static inline void totalram_pages_dec(void)
+{
+       atomic_long_dec(&_totalram_pages);
+}
+
+static inline void totalram_pages_add(long count)
+{
+       atomic_long_add(count, &_totalram_pages);
+}
+
+static inline void totalram_pages_set(long val)
+{
+       atomic_long_set(&_totalram_pages, val);
+}
+
 extern void * high_memory;
 extern int page_cluster;
 
 
 } while (0)
 
 /* linux/mm/page_alloc.c */
-extern unsigned long totalram_pages;
 extern unsigned long totalreserve_pages;
 extern unsigned long nr_free_buffer_pages(void);
 extern unsigned long nr_free_pagecache_pages(void);
 
 static void set_max_threads(unsigned int max_threads_suggested)
 {
        u64 threads;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
 
        /*
         * The number of threads shall be limited such that the thread
 
        int i;
        unsigned long nr_segments = image->nr_segments;
        unsigned long total_pages = 0;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
 
        /*
         * Verify we have good destination addresses.  The caller is
 
 
 void __init hibernate_image_size_init(void)
 {
-       image_size = ((totalram_pages * 2) / 5) * PAGE_SIZE;
+       image_size = ((totalram_pages() * 2) / 5) * PAGE_SIZE;
 }
 
 /*
 
 }
 #endif
 
-unsigned long totalhigh_pages __read_mostly;
-EXPORT_SYMBOL(totalhigh_pages);
-
+atomic_long_t _totalhigh_pages __read_mostly;
+EXPORT_SYMBOL(_totalhigh_pages);
 
 EXPORT_PER_CPU_SYMBOL(__kmap_atomic_idx);
 
 
         * where the extra memory used could hurt more than TLB overhead
         * is likely to save.  The admin can still enable it through /sys.
         */
-       if (totalram_pages < (512 << (20 - PAGE_SHIFT))) {
+       if (totalram_pages() < (512 << (20 - PAGE_SHIFT))) {
                transparent_hugepage_flags = 0;
                return 0;
        }
 
         * Update quarantine size in case of hotplug. Allocate a fraction of
         * the installed memory to quarantine minus per-cpu queue limits.
         */
-       total_size = (READ_ONCE(totalram_pages) << PAGE_SHIFT) /
+       total_size = (totalram_pages() << PAGE_SHIFT) /
                QUARANTINE_FRACTION;
        percpu_quarantines = QUARANTINE_PERCPU_SIZE * num_online_cpus();
        new_quarantine_size = (total_size < percpu_quarantines) ?
 
 
        for (; cursor < end; cursor++) {
                memblock_free_pages(pfn_to_page(cursor), cursor, 0);
-               totalram_pages++;
+               totalram_pages_inc();
        }
 }
 
        reset_all_zones_managed_pages();
 
        pages = free_low_memory_core_early();
-       totalram_pages += pages;
+       totalram_pages_add(pages);
 
        return pages;
 }
 
        s32 batch = max_t(s32, nr*2, 32);
 
        /* batch size set to 0.4% of (total memory/#cpus), or max int32 */
-       memsized_batch = min_t(u64, (totalram_pages/nr)/256, 0x7fffffff);
+       memsized_batch = min_t(u64, (totalram_pages()/nr)/256, 0x7fffffff);
 
        vm_committed_as_batch = max_t(s32, memsized_batch, batch);
 }
 
        }
 
        /* Default to all available memory */
-       oc->totalpages = totalram_pages + total_swap_pages;
+       oc->totalpages = totalram_pages() + total_swap_pages;
 
        if (!IS_ENABLED(CONFIG_NUMA))
                return CONSTRAINT_NONE;
 
 
 #include <linux/stddef.h>
 #include <linux/mm.h>
+#include <linux/highmem.h>
 #include <linux/swap.h>
 #include <linux/interrupt.h>
 #include <linux/pagemap.h>
 /* Protect totalram_pages and zone->managed_pages */
 static DEFINE_SPINLOCK(managed_page_count_lock);
 
-unsigned long totalram_pages __read_mostly;
+atomic_long_t _totalram_pages __read_mostly;
+EXPORT_SYMBOL(_totalram_pages);
 unsigned long totalreserve_pages __read_mostly;
 unsigned long totalcma_pages __read_mostly;
 
 
 void si_meminfo(struct sysinfo *val)
 {
-       val->totalram = totalram_pages;
+       val->totalram = totalram_pages();
        val->sharedram = global_node_page_state(NR_SHMEM);
        val->freeram = global_zone_page_state(NR_FREE_PAGES);
        val->bufferram = nr_blockdev_pages();
-       val->totalhigh = totalhigh_pages;
+       val->totalhigh = totalhigh_pages();
        val->freehigh = nr_free_highpages();
        val->mem_unit = PAGE_SIZE;
 }
 {
        spin_lock(&managed_page_count_lock);
        atomic_long_add(count, &page_zone(page)->managed_pages);
-       totalram_pages += count;
+       totalram_pages_add(count);
 #ifdef CONFIG_HIGHMEM
        if (PageHighMem(page))
-               totalhigh_pages += count;
+               totalhigh_pages_add(count);
 #endif
        spin_unlock(&managed_page_count_lock);
 }
 void free_highmem_page(struct page *page)
 {
        __free_reserved_page(page);
-       totalram_pages++;
+       totalram_pages_inc();
        atomic_long_inc(&page_zone(page)->managed_pages);
-       totalhigh_pages++;
+       totalhigh_pages_inc();
 }
 #endif
 
                physpages << (PAGE_SHIFT - 10),
                codesize >> 10, datasize >> 10, rosize >> 10,
                (init_data_size + init_code_size) >> 10, bss_size >> 10,
-               (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT - 10),
+               (physpages - totalram_pages() - totalcma_pages) << (PAGE_SHIFT - 10),
                totalcma_pages << (PAGE_SHIFT - 10),
 #ifdef CONFIG_HIGHMEM
-               totalhigh_pages << (PAGE_SHIFT - 10),
+               totalhigh_pages() << (PAGE_SHIFT - 10),
 #endif
                str ? ", " : "", str ? str : "");
 }
 
 #ifdef CONFIG_TMPFS
 static unsigned long shmem_default_max_blocks(void)
 {
-       return totalram_pages / 2;
+       return totalram_pages() / 2;
 }
 
 static unsigned long shmem_default_max_inodes(void)
 {
-       unsigned long nr_pages = totalram_pages;
-       return min(nr_pages - totalhigh_pages, nr_pages / 2);
+       unsigned long nr_pages = totalram_pages();
+
+       return min(nr_pages - totalhigh_pages(), nr_pages / 2);
 }
 #endif
 
                        size = memparse(value,&rest);
                        if (*rest == '%') {
                                size <<= PAGE_SHIFT;
-                               size *= totalram_pages;
+                               size *= totalram_pages();
                                do_div(size, 100);
                                rest++;
                        }
 
         * page orders on machines with more than 32MB of memory if
         * not overridden on the command line.
         */
-       if (!slab_max_order_set && totalram_pages > (32 << 20) >> PAGE_SHIFT)
+       if (!slab_max_order_set && totalram_pages() > (32 << 20) >> PAGE_SHIFT)
                slab_max_order = SLAB_MAX_ORDER_HI;
 
        /* Bootstrap is tricky, because several objects are allocated
 
  */
 void __init swap_setup(void)
 {
-       unsigned long megs = totalram_pages >> (20 - PAGE_SHIFT);
+       unsigned long megs = totalram_pages() >> (20 - PAGE_SHIFT);
 
        /* Use a smaller cluster for small-memory machines */
        if (megs < 16)
 
        if (sysctl_overcommit_kbytes)
                allowed = sysctl_overcommit_kbytes >> (PAGE_SHIFT - 10);
        else
-               allowed = ((totalram_pages - hugetlb_total_pages())
+               allowed = ((totalram_pages() - hugetlb_total_pages())
                           * sysctl_overcommit_ratio / 100);
        allowed += total_swap_pages;
 
 
 
        might_sleep();
 
-       if (count > totalram_pages)
+       if (count > totalram_pages())
                return NULL;
 
        size = (unsigned long)count << PAGE_SHIFT;
        unsigned long real_size = size;
 
        size = PAGE_ALIGN(size);
-       if (!size || (size >> PAGE_SHIFT) > totalram_pages)
+       if (!size || (size >> PAGE_SHIFT) > totalram_pages())
                goto fail;
 
        area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |
 
         * double the initial memory by using totalram_pages as-is.
         */
        timestamp_bits = BITS_PER_LONG - EVICTION_SHIFT;
-       max_order = fls_long(totalram_pages - 1);
+       max_order = fls_long(totalram_pages() - 1);
        if (max_order > timestamp_bits)
                bucket_order = max_order - timestamp_bits;
        pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n",
 
 
 static bool zswap_is_full(void)
 {
-       return totalram_pages * zswap_max_pool_percent / 100 <
-               DIV_ROUND_UP(zswap_pool_total_size, PAGE_SIZE);
+       return totalram_pages() * zswap_max_pool_percent / 100 <
+                       DIV_ROUND_UP(zswap_pool_total_size, PAGE_SIZE);
 }
 
 static void zswap_update_total_size(void)
 
 static int __init dccp_init(void)
 {
        unsigned long goal;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
        int ehash_order, bhash_order, i;
        int rc;
 
 
        dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ;
        add_timer(&dn_route_timer);
 
-       goal = totalram_pages >> (26 - PAGE_SHIFT);
+       goal = totalram_pages() >> (26 - PAGE_SHIFT);
 
        for(order = 0; (1UL << order) < goal; order++)
                /* NOTHING */;
 
 
        slots = tcpmhash_entries;
        if (!slots) {
-               if (totalram_pages >= 128 * 1024)
+               if (totalram_pages() >= 128 * 1024)
                        slots = 16 * 1024;
                else
                        slots = 8 * 1024;
 
 
 int nf_conntrack_init_start(void)
 {
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
        int max_factor = 8;
        int ret = -ENOMEM;
        int i;
 
        struct xt_hashlimit_htable *hinfo;
        const struct seq_operations *ops;
        unsigned int size, i;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
        int ret;
 
        if (cfg->size) {
 
        int status = -EINVAL;
        unsigned long goal;
        unsigned long limit;
-       unsigned long nr_pages = totalram_pages;
+       unsigned long nr_pages = totalram_pages();
        int max_share;
        int order;
        int num_entries;
 
                kexec_segment_size = ALIGN(ima_get_binary_runtime_size() +
                                           PAGE_SIZE / 2, PAGE_SIZE);
        if ((kexec_segment_size == ULONG_MAX) ||
-           ((kexec_segment_size >> PAGE_SHIFT) > totalram_pages / 2)) {
+           ((kexec_segment_size >> PAGE_SHIFT) > totalram_pages() / 2)) {
                pr_err("Binary measurement list too large.\n");
                return;
        }