提交 b962716b 编写于 作者: H Hugh Dickins 提交者: Linus Torvalds

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: NHugh Dickins <hugh@veritas.com>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Acked-by: NRik 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 60371d97
...@@ -163,7 +163,6 @@ struct swap_list_t { ...@@ -163,7 +163,6 @@ struct swap_list_t {
/* linux/mm/page_alloc.c */ /* linux/mm/page_alloc.c */
extern unsigned long totalram_pages; extern unsigned long totalram_pages;
extern unsigned long totalreserve_pages; extern unsigned long totalreserve_pages;
extern long nr_swap_pages;
extern unsigned int nr_free_buffer_pages(void); extern unsigned int nr_free_buffer_pages(void);
extern unsigned int nr_free_pagecache_pages(void); extern unsigned int nr_free_pagecache_pages(void);
...@@ -291,6 +290,7 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t, ...@@ -291,6 +290,7 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
struct vm_area_struct *vma, unsigned long addr); struct vm_area_struct *vma, unsigned long addr);
/* linux/mm/swapfile.c */ /* linux/mm/swapfile.c */
extern long nr_swap_pages;
extern long total_swap_pages; extern long total_swap_pages;
extern void si_swapinfo(struct sysinfo *); extern void si_swapinfo(struct sysinfo *);
extern swp_entry_t get_swap_page(void); extern swp_entry_t get_swap_page(void);
...@@ -331,7 +331,8 @@ static inline void disable_swap_token(void) ...@@ -331,7 +331,8 @@ static inline void disable_swap_token(void)
#else /* CONFIG_SWAP */ #else /* CONFIG_SWAP */
#define total_swap_pages 0 #define nr_swap_pages 0L
#define total_swap_pages 0L
#define total_swapcache_pages 0UL #define total_swapcache_pages 0UL
#define si_swapinfo(val) \ #define si_swapinfo(val) \
......
...@@ -69,7 +69,6 @@ EXPORT_SYMBOL(node_states); ...@@ -69,7 +69,6 @@ EXPORT_SYMBOL(node_states);
unsigned long totalram_pages __read_mostly; unsigned long totalram_pages __read_mostly;
unsigned long totalreserve_pages __read_mostly; unsigned long totalreserve_pages __read_mostly;
long nr_swap_pages;
int percpu_pagelist_fraction; int percpu_pagelist_fraction;
#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
static DEFINE_SPINLOCK(swap_lock); static DEFINE_SPINLOCK(swap_lock);
static unsigned int nr_swapfiles; static unsigned int nr_swapfiles;
long nr_swap_pages;
long total_swap_pages; long total_swap_pages;
static int swap_overflow; static int swap_overflow;
static int least_priority; static int least_priority;
......
...@@ -1327,12 +1327,6 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc, ...@@ -1327,12 +1327,6 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
unsigned long anon_prio, file_prio; unsigned long anon_prio, file_prio;
unsigned long ap, fp; unsigned long ap, fp;
anon = zone_page_state(zone, NR_ACTIVE_ANON) +
zone_page_state(zone, NR_INACTIVE_ANON);
file = zone_page_state(zone, NR_ACTIVE_FILE) +
zone_page_state(zone, NR_INACTIVE_FILE);
free = zone_page_state(zone, NR_FREE_PAGES);
/* If we have no swap space, do not bother scanning anon pages. */ /* If we have no swap space, do not bother scanning anon pages. */
if (nr_swap_pages <= 0) { if (nr_swap_pages <= 0) {
percent[0] = 0; percent[0] = 0;
...@@ -1340,6 +1334,12 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc, ...@@ -1340,6 +1334,12 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
return; return;
} }
anon = zone_page_state(zone, NR_ACTIVE_ANON) +
zone_page_state(zone, NR_INACTIVE_ANON);
file = zone_page_state(zone, NR_ACTIVE_FILE) +
zone_page_state(zone, NR_INACTIVE_FILE);
free = zone_page_state(zone, NR_FREE_PAGES);
/* If we have very few page cache pages, force-scan anon pages. */ /* If we have very few page cache pages, force-scan anon pages. */
if (unlikely(file + free <= zone->pages_high)) { if (unlikely(file + free <= zone->pages_high)) {
percent[0] = 100; percent[0] = 100;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册