aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang Yanfei <zhangyanfei@cn.fujitsu.com>2013-02-22 19:35:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 20:50:21 -0500
commitebec3862fd6eefe8301aa55ed2e30c685d831842 (patch)
treedda7828d852e384a382b277be0ec80b21ff38c72
parent1081312f95be1a0fc093556d789e482d3ab0f5b0 (diff)
mm: fix return type for functions nr_free_*_pages
Currently, the amount of RAM that functions nr_free_*_pages return is held in unsigned int. But in machines with big memory (exceeding 16TB), the amount may be incorrect because of overflow, so fix it. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Cc: Simon Horman <horms@verge.net.au> Cc: Julian Anastasov <ja@ssi.bg> Cc: David Miller <davem@davemloft.net> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.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.h4
-rw-r--r--mm/page_alloc.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index a3e22d357e91..8a15f38ebc5c 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -225,8 +225,8 @@ struct swap_list_t {
225extern unsigned long totalram_pages; 225extern unsigned long totalram_pages;
226extern unsigned long totalreserve_pages; 226extern unsigned long totalreserve_pages;
227extern unsigned long dirty_balance_reserve; 227extern unsigned long dirty_balance_reserve;
228extern unsigned int nr_free_buffer_pages(void); 228extern unsigned long nr_free_buffer_pages(void);
229extern unsigned int nr_free_pagecache_pages(void); 229extern unsigned long nr_free_pagecache_pages(void);
230 230
231/* Definition of global_page_state not available yet */ 231/* Definition of global_page_state not available yet */
232#define nr_free_pages() global_page_state(NR_FREE_PAGES) 232#define nr_free_pages() global_page_state(NR_FREE_PAGES)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 159f81577774..276140654305 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2813,13 +2813,13 @@ void free_pages_exact(void *virt, size_t size)
2813} 2813}
2814EXPORT_SYMBOL(free_pages_exact); 2814EXPORT_SYMBOL(free_pages_exact);
2815 2815
2816static unsigned int nr_free_zone_pages(int offset) 2816static unsigned long nr_free_zone_pages(int offset)
2817{ 2817{
2818 struct zoneref *z; 2818 struct zoneref *z;
2819 struct zone *zone; 2819 struct zone *zone;
2820 2820
2821 /* Just pick one node, since fallback list is circular */ 2821 /* Just pick one node, since fallback list is circular */
2822 unsigned int sum = 0; 2822 unsigned long sum = 0;
2823 2823
2824 struct zonelist *zonelist = node_zonelist(numa_node_id(), GFP_KERNEL); 2824 struct zonelist *zonelist = node_zonelist(numa_node_id(), GFP_KERNEL);
2825 2825
@@ -2836,7 +2836,7 @@ static unsigned int nr_free_zone_pages(int offset)
2836/* 2836/*
2837 * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL 2837 * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
2838 */ 2838 */
2839unsigned int nr_free_buffer_pages(void) 2839unsigned long nr_free_buffer_pages(void)
2840{ 2840{
2841 return nr_free_zone_pages(gfp_zone(GFP_USER)); 2841 return nr_free_zone_pages(gfp_zone(GFP_USER));
2842} 2842}
@@ -2845,7 +2845,7 @@ EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
2845/* 2845/*
2846 * Amount of free RAM allocatable within all zones 2846 * Amount of free RAM allocatable within all zones
2847 */ 2847 */
2848unsigned int nr_free_pagecache_pages(void) 2848unsigned long nr_free_pagecache_pages(void)
2849{ 2849{
2850 return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER_MOVABLE)); 2850 return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER_MOVABLE));
2851} 2851}