Commit ebec3862 authored by Zhang Yanfei's avatar Zhang Yanfei Committed by Linus Torvalds

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: default avatarZhang 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1081312f
...@@ -225,8 +225,8 @@ struct swap_list_t { ...@@ -225,8 +225,8 @@ struct swap_list_t {
extern unsigned long totalram_pages; extern unsigned long totalram_pages;
extern unsigned long totalreserve_pages; extern unsigned long totalreserve_pages;
extern unsigned long dirty_balance_reserve; extern unsigned long dirty_balance_reserve;
extern unsigned int nr_free_buffer_pages(void); extern unsigned long nr_free_buffer_pages(void);
extern unsigned int nr_free_pagecache_pages(void); extern unsigned long nr_free_pagecache_pages(void);
/* Definition of global_page_state not available yet */ /* Definition of global_page_state not available yet */
#define nr_free_pages() global_page_state(NR_FREE_PAGES) #define nr_free_pages() global_page_state(NR_FREE_PAGES)
......
...@@ -2813,13 +2813,13 @@ void free_pages_exact(void *virt, size_t size) ...@@ -2813,13 +2813,13 @@ void free_pages_exact(void *virt, size_t size)
} }
EXPORT_SYMBOL(free_pages_exact); EXPORT_SYMBOL(free_pages_exact);
static unsigned int nr_free_zone_pages(int offset) static unsigned long nr_free_zone_pages(int offset)
{ {
struct zoneref *z; struct zoneref *z;
struct zone *zone; struct zone *zone;
/* Just pick one node, since fallback list is circular */ /* Just pick one node, since fallback list is circular */
unsigned int sum = 0; unsigned long sum = 0;
struct zonelist *zonelist = node_zonelist(numa_node_id(), GFP_KERNEL); struct zonelist *zonelist = node_zonelist(numa_node_id(), GFP_KERNEL);
...@@ -2836,7 +2836,7 @@ static unsigned int nr_free_zone_pages(int offset) ...@@ -2836,7 +2836,7 @@ static unsigned int nr_free_zone_pages(int offset)
/* /*
* Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
*/ */
unsigned int nr_free_buffer_pages(void) unsigned long nr_free_buffer_pages(void)
{ {
return nr_free_zone_pages(gfp_zone(GFP_USER)); return nr_free_zone_pages(gfp_zone(GFP_USER));
} }
...@@ -2845,7 +2845,7 @@ EXPORT_SYMBOL_GPL(nr_free_buffer_pages); ...@@ -2845,7 +2845,7 @@ EXPORT_SYMBOL_GPL(nr_free_buffer_pages);
/* /*
* Amount of free RAM allocatable within all zones * Amount of free RAM allocatable within all zones
*/ */
unsigned int nr_free_pagecache_pages(void) unsigned long nr_free_pagecache_pages(void)
{ {
return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER_MOVABLE)); return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER_MOVABLE));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment