From: Christoph Lameter Move totalhigh_pages and nr_free_highpages() into highmem.c/.h Move the totalhigh_pages definition into highmem.c/.h. Move the nr_free_highpages function into highmem.c Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton --- arch/um/kernel/mem.c | 2 ++ include/linux/highmem.h | 3 +++ include/linux/swap.h | 1 - mm/highmem.c | 13 +++++++++++++ mm/page_alloc.c | 15 --------------- mm/shmem.c | 1 + 6 files changed, 19 insertions(+), 16 deletions(-) diff -puN arch/um/kernel/mem.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h arch/um/kernel/mem.c --- a/arch/um/kernel/mem.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h +++ a/arch/um/kernel/mem.c @@ -79,8 +79,10 @@ void mem_init(void) /* this will put all low memory onto the freelists */ totalram_pages = free_all_bootmem(); +#ifdef CONFIG_HIGHMEM totalhigh_pages = highmem >> PAGE_SHIFT; totalram_pages += totalhigh_pages; +#endif num_physpages = totalram_pages; max_pfn = totalram_pages; printk(KERN_INFO "Memory: %luk available\n", diff -puN include/linux/highmem.h~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h include/linux/highmem.h --- a/include/linux/highmem.h~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h +++ a/include/linux/highmem.h @@ -24,11 +24,14 @@ static inline void flush_kernel_dcache_p /* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages(void); +extern unsigned long totalhigh_pages; #else /* CONFIG_HIGHMEM */ static inline unsigned int nr_free_highpages(void) { return 0; } +#define totalhigh_pages 0 + static inline void *kmap(struct page *page) { might_sleep(); diff -puN include/linux/swap.h~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h include/linux/swap.h --- a/include/linux/swap.h~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h +++ a/include/linux/swap.h @@ -162,7 +162,6 @@ extern void swapin_readahead(swp_entry_t /* linux/mm/page_alloc.c */ extern unsigned long totalram_pages; -extern unsigned long totalhigh_pages; extern unsigned long totalreserve_pages; extern long nr_swap_pages; extern unsigned int nr_free_pages(void); diff -puN mm/highmem.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h mm/highmem.c --- a/mm/highmem.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h +++ a/mm/highmem.c @@ -46,6 +46,19 @@ static void *mempool_alloc_pages_isa(gfp */ #ifdef CONFIG_HIGHMEM +unsigned long totalhigh_pages __read_mostly; + +unsigned int nr_free_highpages (void) +{ + pg_data_t *pgdat; + unsigned int pages = 0; + + for_each_online_pgdat(pgdat) + pages += pgdat->node_zones[ZONE_HIGHMEM].free_pages; + + return pages; +} + static int pkmap_count[LAST_PKMAP]; static unsigned int last_pkmap_nr; static __cacheline_aligned_in_smp DEFINE_SPINLOCK(kmap_lock); diff -puN mm/page_alloc.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h mm/page_alloc.c --- a/mm/page_alloc.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h +++ a/mm/page_alloc.c @@ -51,7 +51,6 @@ EXPORT_SYMBOL(node_online_map); nodemask_t node_possible_map __read_mostly = NODE_MASK_ALL; EXPORT_SYMBOL(node_possible_map); unsigned long totalram_pages __read_mostly; -unsigned long totalhigh_pages __read_mostly; unsigned long totalreserve_pages __read_mostly; long nr_swap_pages; int percpu_pagelist_fraction; @@ -1185,20 +1184,6 @@ unsigned int nr_free_pagecache_pages(voi { return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER)); } - -#ifdef CONFIG_HIGHMEM -unsigned int nr_free_highpages (void) -{ - pg_data_t *pgdat; - unsigned int pages = 0; - - for_each_online_pgdat(pgdat) - pages += pgdat->node_zones[ZONE_HIGHMEM].free_pages; - - return pages; -} -#endif - #ifdef CONFIG_NUMA static void show_node(struct zone *zone) { diff -puN mm/shmem.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h mm/shmem.c --- a/mm/shmem.c~reduce-max_nr_zones-move-highmem-counters-into-highmemc-h +++ a/mm/shmem.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include _