summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorArun KS <arunks@codeaurora.org>2018-12-28 03:34:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 15:11:47 -0500
commitca79b0c211af63fa3276f0e3fd7dd9ada2439839 (patch)
treea9198e85582744619903c85349583bb453fe36cb /fs
parent9705bea5f833f4fc21d5bef5fce7348427f76ea4 (diff)
mm: convert totalram_pages and totalhigh_pages variables to atomic
totalram_pages and totalhigh_pages are made static inline function. Main motivation was that managed_page_count_lock handling was complicating things. It was discussed in length here, https://lore.kernel.org/patchwork/patch/995739/#1181785 So it seemes better to remove the lock and convert variables to atomic, with preventing poteintial store-to-read tearing as a bonus. [akpm@linux-foundation.org: coding style fixes] Link: http://lkml.kernel.org/r/1542090790-21750-4-git-send-email-arunks@codeaurora.org Signed-off-by: Arun KS <arunks@codeaurora.org> Suggested-by: Michal Hocko <mhocko@suse.com> Suggested-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Reviewed-by: Pavel Tatashin <pasha.tatashin@soleen.com> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: David Hildenbrand <david@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/super.h2
-rw-r--r--fs/file_table.c2
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/nfsd/nfscache.c2
-rw-r--r--fs/ntfs/malloc.h2
-rw-r--r--fs/proc/base.c2
7 files changed, 7 insertions, 7 deletions
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 79a265ba9200..dfb64a5211b6 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -810,7 +810,7 @@ static inline int default_congestion_kb(void)
810 * This allows larger machines to have larger/more transfers. 810 * This allows larger machines to have larger/more transfers.
811 * Limit the default to 256M 811 * Limit the default to 256M
812 */ 812 */
813 congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10); 813 congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
814 if (congestion_kb > 256*1024) 814 if (congestion_kb > 256*1024)
815 congestion_kb = 256*1024; 815 congestion_kb = 256*1024;
816 816
diff --git a/fs/file_table.c b/fs/file_table.c
index b6e9587f05c7..5679e7fcb6b0 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -380,7 +380,7 @@ void __init files_init(void)
380void __init files_maxfiles_init(void) 380void __init files_maxfiles_init(void)
381{ 381{
382 unsigned long n; 382 unsigned long n;
383 unsigned long nr_pages = totalram_pages; 383 unsigned long nr_pages = totalram_pages();
384 unsigned long memreserve = (nr_pages - nr_free_pages()) * 3/2; 384 unsigned long memreserve = (nr_pages - nr_free_pages()) * 3/2;
385 385
386 memreserve = min(memreserve, nr_pages - 1); 386 memreserve = min(memreserve, nr_pages - 1);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 568abed20eb2..76baaa6be393 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -824,7 +824,7 @@ static const struct super_operations fuse_super_operations = {
824static void sanitize_global_limit(unsigned *limit) 824static void sanitize_global_limit(unsigned *limit)
825{ 825{
826 if (*limit == 0) 826 if (*limit == 0)
827 *limit = ((totalram_pages << PAGE_SHIFT) >> 13) / 827 *limit = ((totalram_pages() << PAGE_SHIFT) >> 13) /
828 sizeof(struct fuse_req); 828 sizeof(struct fuse_req);
829 829
830 if (*limit >= 1 << 16) 830 if (*limit >= 1 << 16)
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 586726a590d8..4f15665f0ad1 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -2121,7 +2121,7 @@ int __init nfs_init_writepagecache(void)
2121 * This allows larger machines to have larger/more transfers. 2121 * This allows larger machines to have larger/more transfers.
2122 * Limit the default to 256M 2122 * Limit the default to 256M
2123 */ 2123 */
2124 nfs_congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10); 2124 nfs_congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
2125 if (nfs_congestion_kb > 256*1024) 2125 if (nfs_congestion_kb > 256*1024)
2126 nfs_congestion_kb = 256*1024; 2126 nfs_congestion_kb = 256*1024;
2127 2127
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index e2fe0e9ce0df..da52b594362a 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -99,7 +99,7 @@ static unsigned int
99nfsd_cache_size_limit(void) 99nfsd_cache_size_limit(void)
100{ 100{
101 unsigned int limit; 101 unsigned int limit;
102 unsigned long low_pages = totalram_pages - totalhigh_pages; 102 unsigned long low_pages = totalram_pages() - totalhigh_pages();
103 103
104 limit = (16 * int_sqrt(low_pages)) << (PAGE_SHIFT-10); 104 limit = (16 * int_sqrt(low_pages)) << (PAGE_SHIFT-10);
105 return min_t(unsigned int, limit, 256*1024); 105 return min_t(unsigned int, limit, 256*1024);
diff --git a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h
index ab172e5f51d9..5becc8acc8f4 100644
--- a/fs/ntfs/malloc.h
+++ b/fs/ntfs/malloc.h
@@ -47,7 +47,7 @@ static inline void *__ntfs_malloc(unsigned long size, gfp_t gfp_mask)
47 return kmalloc(PAGE_SIZE, gfp_mask & ~__GFP_HIGHMEM); 47 return kmalloc(PAGE_SIZE, gfp_mask & ~__GFP_HIGHMEM);
48 /* return (void *)__get_free_page(gfp_mask); */ 48 /* return (void *)__get_free_page(gfp_mask); */
49 } 49 }
50 if (likely((size >> PAGE_SHIFT) < totalram_pages)) 50 if (likely((size >> PAGE_SHIFT) < totalram_pages()))
51 return __vmalloc(size, gfp_mask, PAGE_KERNEL); 51 return __vmalloc(size, gfp_mask, PAGE_KERNEL);
52 return NULL; 52 return NULL;
53} 53}
diff --git a/fs/proc/base.c b/fs/proc/base.c
index ce3465479447..d7fd1ca807d2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -530,7 +530,7 @@ static const struct file_operations proc_lstats_operations = {
530static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns, 530static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
531 struct pid *pid, struct task_struct *task) 531 struct pid *pid, struct task_struct *task)
532{ 532{
533 unsigned long totalpages = totalram_pages + total_swap_pages; 533 unsigned long totalpages = totalram_pages() + total_swap_pages;
534 unsigned long points = 0; 534 unsigned long points = 0;
535 535
536 points = oom_badness(task, NULL, NULL, totalpages) * 536 points = oom_badness(task, NULL, NULL, totalpages) *