Commit a5b5323b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Make nr_swap_pages a long

From: Anton Blanchard <anton@samba.org>

../include/linux/swap.h:extern int nr_swap_pages;       /* XXX: shouldn't this be ulong? --hch */

Sounds like it should be too me.  Some of the code checks for nr_swap_pages
< 0 so I made it a long instead.  I had to fix up the ppc64 show_mem() (Im
guessing there will be other trivial changes required in other 64bit archs,
I can find and fix those if you want).

I also noticed that the ppc64 show_mem() used ints to store page counts.
We can overflow that, so make them unsigned long.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6a948bc8
...@@ -106,7 +106,7 @@ show_mem(void) ...@@ -106,7 +106,7 @@ show_mem(void)
printk("\nMem-info:\n"); printk("\nMem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -371,7 +371,7 @@ show_mem(void) ...@@ -371,7 +371,7 @@ show_mem(void)
printk("\nMem-info:\n"); printk("\nMem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for (nid = 0; nid < numnodes; nid++) { for (nid = 0; nid < numnodes; nid++) {
struct page * lmem_map = node_mem_map(nid); struct page * lmem_map = node_mem_map(nid);
i = node_spanned_pages(nid); i = node_spanned_pages(nid);
......
...@@ -58,7 +58,7 @@ void show_mem(void) ...@@ -58,7 +58,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for (node = 0; node < numnodes; node++) { for (node = 0; node < numnodes; node++) {
struct page *page, *end; struct page *page, *end;
......
...@@ -67,7 +67,7 @@ void show_mem(void) ...@@ -67,7 +67,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
page = NODE_MEM_MAP(0); page = NODE_MEM_MAP(0);
......
...@@ -138,7 +138,7 @@ show_mem(void) ...@@ -138,7 +138,7 @@ show_mem(void)
printk("\nMem-info:\n"); printk("\nMem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -33,7 +33,7 @@ void show_mem(void) ...@@ -33,7 +33,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_pgdat(pgdat) { for_each_pgdat(pgdat) {
for (i = 0; i < pgdat->node_spanned_pages; ++i) { for (i = 0; i < pgdat->node_spanned_pages; ++i) {
page = pgdat->node_mem_map + i; page = pgdat->node_mem_map + i;
......
...@@ -43,7 +43,7 @@ show_mem (void) ...@@ -43,7 +43,7 @@ show_mem (void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
if (!pfn_valid(i)) if (!pfn_valid(i))
......
...@@ -498,7 +498,7 @@ void show_mem(void) ...@@ -498,7 +498,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_pgdat(pgdat) { for_each_pgdat(pgdat) {
printk("Node ID: %d\n", pgdat->node_id); printk("Node ID: %d\n", pgdat->node_id);
for(i = 0; i < pgdat->node_spanned_pages; i++) { for(i = 0; i < pgdat->node_spanned_pages; i++) {
......
...@@ -743,7 +743,7 @@ static int unswap_by_read(unsigned short *map, unsigned long max, ...@@ -743,7 +743,7 @@ static int unswap_by_read(unsigned short *map, unsigned long max,
if (map[i]) { if (map[i]) {
entry = swp_entry(stram_swap_type, i); entry = swp_entry(stram_swap_type, i);
DPRINTK("unswap: map[i=%lu]=%u nr_swap=%u\n", DPRINTK("unswap: map[i=%lu]=%u nr_swap=%ld\n",
i, map[i], nr_swap_pages); i, map[i], nr_swap_pages);
swap_device_lock(stram_swap_info); swap_device_lock(stram_swap_info);
...@@ -772,7 +772,7 @@ static int unswap_by_read(unsigned short *map, unsigned long max, ...@@ -772,7 +772,7 @@ static int unswap_by_read(unsigned short *map, unsigned long max,
#endif #endif
} }
DPRINTK( "unswap: map[i=%lu]=%u nr_swap=%u\n", DPRINTK( "unswap: map[i=%lu]=%u nr_swap=%ld\n",
i, map[i], nr_swap_pages ); i, map[i], nr_swap_pages );
swap_list_lock(); swap_list_lock();
swap_device_lock(stram_swap_info); swap_device_lock(stram_swap_info);
......
...@@ -47,7 +47,7 @@ void show_mem(void) ...@@ -47,7 +47,7 @@ void show_mem(void)
printk("\nMem-info:\n"); printk("\nMem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -12,7 +12,7 @@ void show_mem(void) ...@@ -12,7 +12,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
pfn = max_mapnr; pfn = max_mapnr;
while (pfn-- > 0) { while (pfn-- > 0) {
page = pfn_to_page(pfn); page = pfn_to_page(pfn);
......
...@@ -484,7 +484,8 @@ void show_mem(void) ...@@ -484,7 +484,8 @@ void show_mem(void)
printk(KERN_INFO "Mem-info:\n"); printk(KERN_INFO "Mem-info:\n");
show_free_areas(); show_free_areas();
printk(KERN_INFO "Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk(KERN_INFO "Free swap: %6ldkB\n",
nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -118,7 +118,7 @@ void show_mem(void) ...@@ -118,7 +118,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -89,15 +89,15 @@ unsigned long top_of_ram; ...@@ -89,15 +89,15 @@ unsigned long top_of_ram;
void show_mem(void) void show_mem(void)
{ {
int total = 0, reserved = 0; unsigned long total = 0, reserved = 0;
int shared = 0, cached = 0; unsigned long shared = 0, cached = 0;
struct page *page; struct page *page;
pg_data_t *pgdat; pg_data_t *pgdat;
unsigned long i; unsigned long i;
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_pgdat(pgdat) { for_each_pgdat(pgdat) {
for (i = 0; i < pgdat->node_spanned_pages; i++) { for (i = 0; i < pgdat->node_spanned_pages; i++) {
page = pgdat->node_mem_map + i; page = pgdat->node_mem_map + i;
...@@ -110,10 +110,10 @@ void show_mem(void) ...@@ -110,10 +110,10 @@ void show_mem(void)
shared += page_count(page) - 1; shared += page_count(page) - 1;
} }
} }
printk("%d pages of RAM\n",total); printk("%ld pages of RAM\n", total);
printk("%d reserved pages\n",reserved); printk("%ld reserved pages\n", reserved);
printk("%d pages shared\n",shared); printk("%ld pages shared\n", shared);
printk("%d pages swap cached\n",cached); printk("%ld pages swap cached\n", cached);
} }
#ifdef CONFIG_PPC_ISERIES #ifdef CONFIG_PPC_ISERIES
......
...@@ -60,7 +60,7 @@ void show_mem(void) ...@@ -60,7 +60,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -66,7 +66,7 @@ void show_mem(void) ...@@ -66,7 +66,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
total++; total++;
......
...@@ -76,7 +76,7 @@ void show_mem(void) ...@@ -76,7 +76,7 @@ void show_mem(void)
{ {
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n", printk("Free swap: %6ldkB\n",
nr_swap_pages << (PAGE_SHIFT-10)); nr_swap_pages << (PAGE_SHIFT-10));
printk("%ld pages of RAM\n", totalram_pages); printk("%ld pages of RAM\n", totalram_pages);
printk("%d free pages\n", nr_free_pages()); printk("%d free pages\n", nr_free_pages());
......
...@@ -348,7 +348,7 @@ void show_mem(void) ...@@ -348,7 +348,7 @@ void show_mem(void)
{ {
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n", printk("Free swap: %6ldkB\n",
nr_swap_pages << (PAGE_SHIFT-10)); nr_swap_pages << (PAGE_SHIFT-10));
printk("%ld pages of RAM\n", num_physpages); printk("%ld pages of RAM\n", num_physpages);
printk("%d free pages\n", nr_free_pages()); printk("%d free pages\n", nr_free_pages());
......
...@@ -380,7 +380,7 @@ void show_mem(void) ...@@ -380,7 +380,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
pfn = max_mapnr; pfn = max_mapnr;
while(pfn-- > 0) { while(pfn-- > 0) {
page = pfn_to_page(pfn); page = pfn_to_page(pfn);
......
...@@ -60,7 +60,7 @@ void show_mem(void) ...@@ -60,7 +60,7 @@ void show_mem(void)
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas();
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_pgdat(pgdat) { for_each_pgdat(pgdat) {
for (i = 0; i < pgdat->node_spanned_pages; ++i) { for (i = 0; i < pgdat->node_spanned_pages; ++i) {
......
...@@ -156,7 +156,7 @@ extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct * ...@@ -156,7 +156,7 @@ extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *
/* linux/mm/page_alloc.c */ /* linux/mm/page_alloc.c */
extern unsigned long totalram_pages; extern unsigned long totalram_pages;
extern unsigned long totalhigh_pages; extern unsigned long totalhigh_pages;
extern int nr_swap_pages; /* XXX: shouldn't this be ulong? --hch */ extern long nr_swap_pages;
extern unsigned int nr_free_pages(void); extern unsigned int nr_free_pages(void);
extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat); extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat);
extern unsigned int nr_free_buffer_pages(void); extern unsigned int nr_free_buffer_pages(void);
......
...@@ -38,7 +38,7 @@ DECLARE_BITMAP(node_online_map, MAX_NUMNODES); ...@@ -38,7 +38,7 @@ DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
struct pglist_data *pgdat_list; struct pglist_data *pgdat_list;
unsigned long totalram_pages; unsigned long totalram_pages;
unsigned long totalhigh_pages; unsigned long totalhigh_pages;
int nr_swap_pages; long nr_swap_pages;
int numnodes = 1; int numnodes = 1;
int sysctl_lower_zone_protection = 0; int sysctl_lower_zone_protection = 0;
......
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