aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugh Dickins <hugh@veritas.com>2009-01-06 17:39:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:04 -0500
commitb962716b459505a8d83aea313fea0abe76749f42 (patch)
treeb401e882f2ee8ff5a11209057496e603c211e8fe
parent60371d971a3d01afd102f0bbf2681f32ecc31d78 (diff)
mm: optimize get_scan_ratio for no swap
Rik suggests a simplified get_scan_ratio() for !CONFIG_SWAP. Yes, the gcc optimizer gives us that, when nr_swap_pages is #defined as 0L. Move usual declaration to swapfile.c: it never belonged in page_alloc.c. Signed-off-by: Hugh Dickins <hugh@veritas.com> Cc: Lee Schermerhorn <lee.schermerhorn@hp.com> Acked-by: Rik van Riel <riel@redhat.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Robin Holt <holt@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/swap.h5
-rw-r--r--mm/page_alloc.c1
-rw-r--r--mm/swapfile.c1
-rw-r--r--mm/vmscan.c12
4 files changed, 10 insertions, 9 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index c0d23ac710d5..3a31cc25bd2c 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -163,7 +163,6 @@ struct swap_list_t {
163/* linux/mm/page_alloc.c */ 163/* linux/mm/page_alloc.c */
164extern unsigned long totalram_pages; 164extern unsigned long totalram_pages;
165extern unsigned long totalreserve_pages; 165extern unsigned long totalreserve_pages;
166extern long nr_swap_pages;
167extern unsigned int nr_free_buffer_pages(void); 166extern unsigned int nr_free_buffer_pages(void);
168extern unsigned int nr_free_pagecache_pages(void); 167extern unsigned int nr_free_pagecache_pages(void);
169 168
@@ -291,6 +290,7 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
291 struct vm_area_struct *vma, unsigned long addr); 290 struct vm_area_struct *vma, unsigned long addr);
292 291
293/* linux/mm/swapfile.c */ 292/* linux/mm/swapfile.c */
293extern long nr_swap_pages;
294extern long total_swap_pages; 294extern long total_swap_pages;
295extern void si_swapinfo(struct sysinfo *); 295extern void si_swapinfo(struct sysinfo *);
296extern swp_entry_t get_swap_page(void); 296extern swp_entry_t get_swap_page(void);
@@ -331,7 +331,8 @@ static inline void disable_swap_token(void)
331 331
332#else /* CONFIG_SWAP */ 332#else /* CONFIG_SWAP */
333 333
334#define total_swap_pages 0 334#define nr_swap_pages 0L
335#define total_swap_pages 0L
335#define total_swapcache_pages 0UL 336#define total_swapcache_pages 0UL
336 337
337#define si_swapinfo(val) \ 338#define si_swapinfo(val) \
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ce2a026219bc..65133436fe3d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -69,7 +69,6 @@ EXPORT_SYMBOL(node_states);
69 69
70unsigned long totalram_pages __read_mostly; 70unsigned long totalram_pages __read_mostly;
71unsigned long totalreserve_pages __read_mostly; 71unsigned long totalreserve_pages __read_mostly;
72long nr_swap_pages;
73int percpu_pagelist_fraction; 72int percpu_pagelist_fraction;
74 73
75#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE 74#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 9ce7f81c8abc..725e56c362de 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -35,6 +35,7 @@
35 35
36static DEFINE_SPINLOCK(swap_lock); 36static DEFINE_SPINLOCK(swap_lock);
37static unsigned int nr_swapfiles; 37static unsigned int nr_swapfiles;
38long nr_swap_pages;
38long total_swap_pages; 39long total_swap_pages;
39static int swap_overflow; 40static int swap_overflow;
40static int least_priority; 41static int least_priority;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index f350523a8eee..d500b906746c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1327,12 +1327,6 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
1327 unsigned long anon_prio, file_prio; 1327 unsigned long anon_prio, file_prio;
1328 unsigned long ap, fp; 1328 unsigned long ap, fp;
1329 1329
1330 anon = zone_page_state(zone, NR_ACTIVE_ANON) +
1331 zone_page_state(zone, NR_INACTIVE_ANON);
1332 file = zone_page_state(zone, NR_ACTIVE_FILE) +
1333 zone_page_state(zone, NR_INACTIVE_FILE);
1334 free = zone_page_state(zone, NR_FREE_PAGES);
1335
1336 /* If we have no swap space, do not bother scanning anon pages. */ 1330 /* If we have no swap space, do not bother scanning anon pages. */
1337 if (nr_swap_pages <= 0) { 1331 if (nr_swap_pages <= 0) {
1338 percent[0] = 0; 1332 percent[0] = 0;
@@ -1340,6 +1334,12 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
1340 return; 1334 return;
1341 } 1335 }
1342 1336
1337 anon = zone_page_state(zone, NR_ACTIVE_ANON) +
1338 zone_page_state(zone, NR_INACTIVE_ANON);
1339 file = zone_page_state(zone, NR_ACTIVE_FILE) +
1340 zone_page_state(zone, NR_INACTIVE_FILE);
1341 free = zone_page_state(zone, NR_FREE_PAGES);
1342
1343 /* If we have very few page cache pages, force-scan anon pages. */ 1343 /* If we have very few page cache pages, force-scan anon pages. */
1344 if (unlikely(file + free <= zone->pages_high)) { 1344 if (unlikely(file + free <= zone->pages_high)) {
1345 percent[0] = 100; 1345 percent[0] = 100;