2009-10-07 09:50:24

by Andreas Fenkart

[permalink] [raw]
Subject: Make totalhigh_pages of consistent type.

Printing the value of totalhigh_pages requires casting, see
typical print message:

arch/x86/mm/init_32.c:
printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
"%dk reserved, %dk data, %dk init, %ldk highmem)\n",
nr_free_pages() << (PAGE_SHIFT-10),
num_physpages << (PAGE_SHIFT-10),
codesize >> 10,
reservedpages << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10,
(unsigned long)(totalhigh_pages << (PAGE_SHIFT-10)));


The problem is that the type of totalhigh_pages is dependent on
CONFIG_HIGHMEM being set or not.

include/linux/highmem.h:
#ifdef CONFIG_HIGHMEM

extern unsigned long totalhigh_pages;

#else /* CONFIG_HIGHMEM */

-#define totalhigh_pages 0
+#define totalhigh_pages 0UL
...

The patch changes the define, so that totalhigh_pages is of uniform
type in both cases.

Patch is build-tested on x86_32 and ARM

kind regards

Andreas


2009-10-07 09:50:35

by Andreas Fenkart

[permalink] [raw]
Subject: [PATCH 1/1] Make totalhigh_pages unsigned long.

Makes it consistent with the extern declaration, used when
CONFIG_HIGHMEM is set
Removes redundant casts in printout messages

Signed-off-by: Andreas Fenkart <[email protected]>
---
arch/arm/mm/init.c | 2 +-
arch/mips/mm/init.c | 2 +-
arch/mips/sgi-ip27/ip27-memory.c | 2 +-
arch/mn10300/mm/init.c | 3 +--
arch/score/mm/init.c | 2 +-
arch/x86/mm/init_32.c | 3 +--
include/linux/highmem.h | 2 +-
7 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 877c492..8d76b50 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -598,7 +598,7 @@ void __init mem_init(void)
"%dK data, %dK init, %luK highmem)\n",
nr_free_pages() << (PAGE_SHIFT-10), codesize >> 10,
datasize >> 10, initsize >> 10,
- (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
+ totalhigh_pages << (PAGE_SHIFT-10));

if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
extern int sysctl_overcommit_memory;
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 15aa190..03ac816 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -420,7 +420,7 @@ void __init mem_init(void)
reservedpages << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10,
- (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
+ totalhigh_pages << (PAGE_SHIFT-10));
}
#endif /* !CONFIG_NEED_MULTIPLE_NODES */

diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index f61c164..bc12971 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -505,5 +505,5 @@ void __init mem_init(void)
(num_physpages - tmp) << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10,
- (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
+ totalhigh_pages << (PAGE_SHIFT-10));
}
diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c
index ec14205..dd27a9a 100644
--- a/arch/mn10300/mm/init.c
+++ b/arch/mn10300/mm/init.c
@@ -118,8 +118,7 @@ void __init mem_init(void)
reservedpages << (PAGE_SHIFT - 10),
datasize >> 10,
initsize >> 10,
- (unsigned long) (totalhigh_pages << (PAGE_SHIFT - 10))
- );
+ totalhigh_pages << (PAGE_SHIFT - 10));
}

/*
diff --git a/arch/score/mm/init.c b/arch/score/mm/init.c
index 4e3dcd0..3739a41 100644
--- a/arch/score/mm/init.c
+++ b/arch/score/mm/init.c
@@ -111,7 +111,7 @@ void __init mem_init(void)
ram << (PAGE_SHIFT-10), codesize >> 10,
reservedpages << (PAGE_SHIFT-10), datasize >> 10,
initsize >> 10,
- (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
+ totalhigh_pages << (PAGE_SHIFT-10));
}
#endif /* !CONFIG_NEED_MULTIPLE_NODES */

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 30938c1..b1738d1 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -892,8 +892,7 @@ void __init mem_init(void)
reservedpages << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10,
- (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))
- );
+ totalhigh_pages << (PAGE_SHIFT-10));

printk(KERN_INFO "virtual kernel memory layout:\n"
" fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 211ff44..ab2cc20 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -46,7 +46,7 @@ void kmap_flush_unused(void);

static inline unsigned int nr_free_highpages(void) { return 0; }

-#define totalhigh_pages 0
+#define totalhigh_pages 0UL

#ifndef ARCH_HAS_KMAP
static inline void *kmap(struct page *page)
--
1.6.4.3