Commit 40c99aae authored by Chandra Seetharaman's avatar Chandra Seetharaman Committed by Linus Torvalds

[PATCH] remove static variable mm/page-writeback.c:total_pages

page-writeback.c has a static local variable "total_pages", which is the
total number of pages in the system.

There is a global variable "vm_total_pages", which is the total number of
pages the VM controls.

Both are assigned from the return value of nr_free_pagecache_pages().

This patch removes the local variable and uses the global variable in that
place.

One more issue with the local static variable "total_pages" is that it is
not updated when new pages are hot-added.  Since vm_total_pages is updated
when new pages are hot-added, this patch fixes that problem too.
Signed-off-by: default avatarChandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 153dcc54
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
*/ */
static long ratelimit_pages = 32; static long ratelimit_pages = 32;
static long total_pages; /* The total number of pages in the machine. */
static int dirty_exceeded __cacheline_aligned_in_smp; /* Dirty mem may be over limit */ static int dirty_exceeded __cacheline_aligned_in_smp; /* Dirty mem may be over limit */
/* /*
...@@ -126,7 +125,7 @@ get_dirty_limits(long *pbackground, long *pdirty, ...@@ -126,7 +125,7 @@ get_dirty_limits(long *pbackground, long *pdirty,
int unmapped_ratio; int unmapped_ratio;
long background; long background;
long dirty; long dirty;
unsigned long available_memory = total_pages; unsigned long available_memory = vm_total_pages;
struct task_struct *tsk; struct task_struct *tsk;
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
...@@ -141,7 +140,7 @@ get_dirty_limits(long *pbackground, long *pdirty, ...@@ -141,7 +140,7 @@ get_dirty_limits(long *pbackground, long *pdirty,
unmapped_ratio = 100 - ((global_page_state(NR_FILE_MAPPED) + unmapped_ratio = 100 - ((global_page_state(NR_FILE_MAPPED) +
global_page_state(NR_ANON_PAGES)) * 100) / global_page_state(NR_ANON_PAGES)) * 100) /
total_pages; vm_total_pages;
dirty_ratio = vm_dirty_ratio; dirty_ratio = vm_dirty_ratio;
if (dirty_ratio > unmapped_ratio / 2) if (dirty_ratio > unmapped_ratio / 2)
...@@ -504,7 +503,7 @@ void laptop_sync_completion(void) ...@@ -504,7 +503,7 @@ void laptop_sync_completion(void)
static void set_ratelimit(void) static void set_ratelimit(void)
{ {
ratelimit_pages = total_pages / (num_online_cpus() * 32); ratelimit_pages = vm_total_pages / (num_online_cpus() * 32);
if (ratelimit_pages < 16) if (ratelimit_pages < 16)
ratelimit_pages = 16; ratelimit_pages = 16;
if (ratelimit_pages * PAGE_CACHE_SIZE > 4096 * 1024) if (ratelimit_pages * PAGE_CACHE_SIZE > 4096 * 1024)
...@@ -533,9 +532,7 @@ void __init page_writeback_init(void) ...@@ -533,9 +532,7 @@ void __init page_writeback_init(void)
long buffer_pages = nr_free_buffer_pages(); long buffer_pages = nr_free_buffer_pages();
long correction; long correction;
total_pages = nr_free_pagecache_pages(); correction = (100 * 4 * buffer_pages) / vm_total_pages;
correction = (100 * 4 * buffer_pages) / total_pages;
if (correction < 100) { if (correction < 100) {
dirty_background_ratio *= correction; dirty_background_ratio *= correction;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment