mm: fix types for some functions and variables in case of overflow
Subsystems (11)
cover mm: fix types for some functions and variables in case of overflow
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 this problem.
Also, fix the types of variables that is related to nr_free_*_pages. For these variables are placed in several subsystems, I may be incorrectly fix them, if there is any problem with the fix, please correct me.
Zhang Yanfei (7):
mm: fix return type for functions nr_free_*_pages
ia64: use %ld to print pages calculated in nr_free_buffer_pages fs/buffer.c: change type of max_buffer_heads to unsigned long fs/nfsd: change type of max_delegations, nfsd_drc_max_mem and
nfsd_drc_mem_used
vmscan: change type of vm_total_pages to unsigned long
net: change type of netns_ipvs->sysctl_sync_qlen_max
net: change type of virtio_chan->p9_max_pages
arch/ia64/mm/contig.c | 2 +- arch/ia64/mm/discontig.c | 2 +- fs/buffer.c | 4 ++-- fs/nfsd/nfs4state.c | 6 +++--- fs/nfsd/nfsd.h | 6 +++--- fs/nfsd/nfssvc.c | 6 +++--- include/linux/swap.h | 6 +++--- include/net/ip_vs.h | 2 +- mm/page_alloc.c | 8 ++++---- mm/vmscan.c | 2 +- net/9p/trans_virtio.c | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/7 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.
--- include/linux/swap.h | 4 ++-- mm/page_alloc.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/swap.h +2 -2
@@ -216,8 +216,8 @@ struct swap_list_t {extern unsigned long totalram_pages;extern unsigned long totalreserve_pages;extern unsigned long dirty_balance_reserve; -extern unsigned int nr_free_buffer_pages (void ); -extern unsigned int nr_free_pagecache_pages (void ); +extern unsigned long nr_free_buffer_pages (void ); +extern unsigned long nr_free_pagecache_pages (void );/* Definition of global_page_state not available yet */ #define nr_free_pages () global_page_state(NR_FREE_PAGES)
mm/page_alloc.c +4 -4
@@ -2785,13 +2785,13 @@ void free_pages_exact(void *virt, size_t size) }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 zone *zone;/* 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 );
@@ -2808,7 +2808,7 @@ static unsigned int nr_free_zone_pages(int offset)/* * 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 )); }
@@ -2817,7 +2817,7 @@ EXPORT_SYMBOL_GPL(nr_free_buffer_pages);/* * 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 )); }
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/7 ia64: use %ld to print pages calculated in nr_free_buffer_pages
In reply to Zhang YanfeiNow the function nr_free_buffer_pages returns unsigned long, so use %ld to print its return value.
--- arch/ia64/mm/contig.c | 2 +- arch/ia64/mm/discontig.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/ia64/mm/contig.c +1 -1
@@ -93,7 +93,7 @@ void show_mem(unsigned int filter)printk (KERN_INFO "%d pages swap cached\n" , total_cached);printk (KERN_INFO "Total of %ld pages in page table cache\n" ,quicklist_total_size ()); -printk (KERN_INFO "%d free buffer pages\n" ,nr_free_buffer_pages ()); +printk (KERN_INFO "%ld free buffer pages\n" ,nr_free_buffer_pages ()); }
arch/ia64/mm/discontig.c +1 -1
@@ -666,7 +666,7 @@ void show_mem(unsigned int filter)printk (KERN_INFO "%d pages swap cached\n" , total_cached);printk (KERN_INFO "Total of %ld pages in page table cache\n" ,quicklist_total_size ()); -printk (KERN_INFO "%d free buffer pages\n" ,nr_free_buffer_pages ()); +printk (KERN_INFO "%ld free buffer pages\n" ,nr_free_buffer_pages ()); }/**
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/7 fs/buffer.c: change type of max_buffer_heads to unsigned long
In reply to Zhang Yanfeimax_buffer_heads is calculated from nr_free_buffer_pages(), so change its type to unsigned long in case of overflow.
--- fs/buffer.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/buffer.c +2 -2
@@ -3227,7 +3227,7 @@ static struct kmem_cache *bh_cachep __read_mostly;* Once the number of bh's in the machine exceeds this level, we start * stripping them in writeback. */ -static int max_buffer_heads; +static unsigned long max_buffer_heads;int buffer_heads_over_limit;
@@ -3343,7 +3343,7 @@ EXPORT_SYMBOL(bh_submit_read);void __init buffer_init (void ) { -int nrpages; +unsigned long nrpages; bh_cachep = kmem_cache_create("buffer_head", sizeof(struct buffer_head), 0,
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/7 fs/nfsd: change type of max_delegations, nfsd_drc_max_mem and nfsd_drc_mem_used
In reply to Zhang YanfeiThe three variables are calculated from nr_free_buffer_pages so change their types to unsigned long in case of overflow.
--- fs/nfsd/nfs4state.c | 6 +++--- fs/nfsd/nfsd.h | 6 +++--- fs/nfsd/nfssvc.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
fs/nfsd/nfs4state.c +3 -3
@@ -151,7 +151,7 @@ get_nfs4_file(struct nfs4_file *fi) }static int num_delegations; -unsigned int max_delegations; +unsigned long max_delegations;/* * Open owner state (share locks)
@@ -700,8 +700,8 @@ static int nfsd4_get_drc_mem(int slotsize, u32 num) num =min_t (u32, num,NFSD_MAX_SLOTS_PER_SESSION );spin_lock (&nfsd_drc_lock); - avail =min_t (int,NFSD_MAX_MEM_PER_SESSION , - nfsd_drc_max_mem - nfsd_drc_mem_used); + avail =min ((unsigned long )NFSD_MAX_MEM_PER_SESSION , + nfsd_drc_max_mem - nfsd_drc_mem_used); num =min_t (int, num, avail / slotsize); nfsd_drc_mem_used += num * slotsize;spin_unlock (&nfsd_drc_lock);
fs/nfsd/nfsd.h +3 -3
@@ -56,8 +56,8 @@ extern struct svc_version nfsd_version2, nfsd_version3,extern u32 nfsd_supported_minorversion;extern struct mutex nfsd_mutex;extern spinlock_t nfsd_drc_lock; -extern unsigned int nfsd_drc_max_mem; -extern unsigned int nfsd_drc_mem_used; +extern unsigned long nfsd_drc_max_mem; +extern unsigned long nfsd_drc_mem_used;extern const struct seq_operations nfs_exports_op;
@@ -106,7 +106,7 @@ static inline int nfsd_v4client(struct svc_rqst *rq)* NFSv4 State */ #ifdef CONFIG_NFSD_V4 -extern unsigned int max_delegations; +extern unsigned long max_delegations;void nfs4_state_init (void );int nfsd4_init_slabs (void );void nfsd4_free_slabs (void );
fs/nfsd/nfssvc.c +3 -3
@@ -59,8 +59,8 @@ DEFINE_MUTEX(nfsd_mutex);* nfsd_drc_pages_used tracks the current version 4.1 DRC memory usage. */ spinlock_t nfsd_drc_lock; -unsigned int nfsd_drc_max_mem; -unsigned int nfsd_drc_mem_used; +unsigned long nfsd_drc_max_mem; +unsigned long nfsd_drc_mem_used;#if defined(CONFIG_NFSD_V2_ACL ) || defined(CONFIG_NFSD_V3_ACL )static struct svc_stat nfsd_acl_svcstats;
@@ -342,7 +342,7 @@ static void set_max_drc(void) >> NFSD_DRC_SIZE_SHIFT) * PAGE_SIZE; nfsd_drc_mem_used =0 ;spin_lock_init (&nfsd_drc_lock); -dprintk ("%s nfsd_drc_max_mem %u \n" , __func__, nfsd_drc_max_mem); +dprintk ("%s nfsd_drc_max_mem %lu \n" , __func__, nfsd_drc_max_mem); }static int nfsd_get_default_max_blksize (void )
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/7 vmscan: change type of vm_total_pages to unsigned long
In reply to Zhang YanfeiThis variable is calculated from nr_free_pagecache_pages so change its type to unsigned long.
--- include/linux/swap.h | 2 +- mm/vmscan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/swap.h +1 -1
@@ -266,7 +266,7 @@ extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,extern unsigned long shrink_all_memory (unsigned long nr_pages);extern int vm_swappiness;extern int remove_mapping (struct address_space *mapping,struct page *page); -extern long vm_total_pages; +extern unsigned long vm_total_pages;#ifdef CONFIG_NUMA extern int zone_reclaim_mode;
mm/vmscan.c +1 -1
@@ -128,7 +128,7 @@ struct scan_control {* From 0 .. 100. Higher means more swappy. */ int vm_swappiness =60 ; -long vm_total_pages;/* The total number of pages which the VM controls */ +unsigned long vm_total_pages;/* The total number of pages which the VM controls */ static LIST_HEAD (shrinker_list);static DECLARE_RWSEM (shrinker_rwsem);
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/7 net: change type of netns_ipvs->sysctl_sync_qlen_max
In reply to Zhang YanfeiThis member of struct netns_ipvs is calculated from nr_free_buffer_pages so change its type to unsigned long in case of overflow.
--- include/net/ip_vs.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/net/ip_vs.h +1 -1
@@ -966,7 +966,7 @@ struct netns_ipvs {int sysctl_snat_reroute;int sysctl_sync_ver;int sysctl_sync_ports; -int sysctl_sync_qlen_max; +unsigned long sysctl_sync_qlen_max;int sysctl_sync_sock_size;int sysctl_cache_bypass;int sysctl_expire_nodest_conn;
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 7/7 net: change type of virtio_chan->p9_max_pages
In reply to Zhang YanfeiThis member of struct virtio_chan is calculated from nr_free_buffer_pages so change its type to unsigned long in case of overflow.
--- net/9p/trans_virtio.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/9p/trans_virtio.c +1 -1
@@ -87,7 +87,7 @@ struct virtio_chan {/* This is global limit. Since we don't have a global structure, * will be placing it in each channel. */ -int p9_max_pages; +unsigned long p9_max_pages;/* Scatterlist: can be too big for stack. */ struct scatterlist sg[VIRTQUEUE_NUM ];
Signature · 7 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>