aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-02-10 04:43:03 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:18 -0500
commit96177299416dbccb73b54e6b344260154a445375 (patch)
tree586454851d0fbbb365d6b12c852d5a7dd6b004f4
parent51ed4491271be8c56bdb2a03481ed34ea4984bc2 (diff)
[PATCH] Drop free_pages()
nr_free_pages is now a simple access to a global variable. Make it a macro instead of a function. The nr_free_pages now requires vmstat.h to be included. There is one occurrence in power management where we need to add the include. Directly refrer to global_page_state() there to clarify why the #include was added. [akpm@osdl.org: arm build fix] [akpm@osdl.org: sparc64 build fix] Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/sparc64/mm/init.c4
-rw-r--r--include/linux/swap.h5
-rw-r--r--include/linux/vmstat.h1
-rw-r--r--kernel/power/main.c4
-rw-r--r--mm/page_alloc.c10
5 files changed, 10 insertions, 14 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 054822a3e05e..09d434f41e4b 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -416,7 +416,7 @@ void show_mem(void)
416 printk("Free swap: %6ldkB\n", 416 printk("Free swap: %6ldkB\n",
417 nr_swap_pages << (PAGE_SHIFT-10)); 417 nr_swap_pages << (PAGE_SHIFT-10));
418 printk("%ld pages of RAM\n", num_physpages); 418 printk("%ld pages of RAM\n", num_physpages);
419 printk("%d free pages\n", nr_free_pages()); 419 printk("%lu free pages\n", nr_free_pages());
420} 420}
421 421
422void mmu_info(struct seq_file *m) 422void mmu_info(struct seq_file *m)
@@ -1593,7 +1593,7 @@ void __init mem_init(void)
1593 initpages = (((unsigned long) __init_end) - ((unsigned long) __init_begin)); 1593 initpages = (((unsigned long) __init_end) - ((unsigned long) __init_begin));
1594 initpages = PAGE_ALIGN(initpages) >> PAGE_SHIFT; 1594 initpages = PAGE_ALIGN(initpages) >> PAGE_SHIFT;
1595 1595
1596 printk("Memory: %uk available (%ldk kernel code, %ldk data, %ldk init) [%016lx,%016lx]\n", 1596 printk("Memory: %luk available (%ldk kernel code, %ldk data, %ldk init) [%016lx,%016lx]\n",
1597 nr_free_pages() << (PAGE_SHIFT-10), 1597 nr_free_pages() << (PAGE_SHIFT-10),
1598 codepages << (PAGE_SHIFT-10), 1598 codepages << (PAGE_SHIFT-10),
1599 datapages << (PAGE_SHIFT-10), 1599 datapages << (PAGE_SHIFT-10),
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 5423559a44a6..817e1b47007f 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -170,11 +170,14 @@ extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *
170extern unsigned long totalram_pages; 170extern unsigned long totalram_pages;
171extern unsigned long totalreserve_pages; 171extern unsigned long totalreserve_pages;
172extern long nr_swap_pages; 172extern long nr_swap_pages;
173extern unsigned int nr_free_pages(void);
174extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat); 173extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat);
175extern unsigned int nr_free_buffer_pages(void); 174extern unsigned int nr_free_buffer_pages(void);
176extern unsigned int nr_free_pagecache_pages(void); 175extern unsigned int nr_free_pagecache_pages(void);
177 176
177/* Definition of global_page_state not available yet */
178#define nr_free_pages() global_page_state(NR_FREE_PAGES)
179
180
178/* linux/mm/swap.c */ 181/* linux/mm/swap.c */
179extern void FASTCALL(lru_cache_add(struct page *)); 182extern void FASTCALL(lru_cache_add(struct page *));
180extern void FASTCALL(lru_cache_add_active(struct page *)); 183extern void FASTCALL(lru_cache_add_active(struct page *));
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index c8d55bcc09b9..77caf911969c 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/mm.h>
6#include <linux/mmzone.h> 7#include <linux/mmzone.h>
7#include <asm/atomic.h> 8#include <asm/atomic.h>
8 9
diff --git a/kernel/power/main.c b/kernel/power/main.c
index ff3a6182f5f0..47ca5a2b653b 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -20,6 +20,7 @@
20#include <linux/cpu.h> 20#include <linux/cpu.h>
21#include <linux/resume-trace.h> 21#include <linux/resume-trace.h>
22#include <linux/freezer.h> 22#include <linux/freezer.h>
23#include <linux/vmstat.h>
23 24
24#include "power.h" 25#include "power.h"
25 26
@@ -72,7 +73,8 @@ static int suspend_prepare(suspend_state_t state)
72 goto Thaw; 73 goto Thaw;
73 } 74 }
74 75
75 if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) { 76 if ((free_pages = global_page_state(NR_FREE_PAGES))
77 < FREE_PAGE_NUMBER) {
76 pr_debug("PM: free some memory\n"); 78 pr_debug("PM: free some memory\n");
77 shrink_all_memory(FREE_PAGE_NUMBER - free_pages); 79 shrink_all_memory(FREE_PAGE_NUMBER - free_pages);
78 if (nr_free_pages() < FREE_PAGE_NUMBER) { 80 if (nr_free_pages() < FREE_PAGE_NUMBER) {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ba62d8789f73..f1e320b3a988 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1440,16 +1440,6 @@ fastcall void free_pages(unsigned long addr, unsigned int order)
1440 1440
1441EXPORT_SYMBOL(free_pages); 1441EXPORT_SYMBOL(free_pages);
1442 1442
1443/*
1444 * Total amount of free (allocatable) RAM:
1445 */
1446unsigned int nr_free_pages(void)
1447{
1448 return global_page_state(NR_FREE_PAGES);
1449}
1450
1451EXPORT_SYMBOL(nr_free_pages);
1452
1453#ifdef CONFIG_NUMA 1443#ifdef CONFIG_NUMA
1454unsigned int nr_free_pages_pgdat(pg_data_t *pgdat) 1444unsigned int nr_free_pages_pgdat(pg_data_t *pgdat)
1455{ 1445{