Skip to contentSkip to conversation

mm: nobootmem: fix sign extend problem in __free_pages_memory()

PATCH In review Russ Anderson 3 participants 3 messages May 7, 2012 – May 8, 2012 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: nobootmem: fix sign extend problem in __free_pages_memory()

Systems with 8 TBytes of memory or greater can hit a problem where only the the first 8 TB of memory shows up. This is due to "int i" being smaller than "unsigned long start_aligned", causing the high bits to be dropped.

The fix is to change i to unsigned long to match start_aligned and end_aligned.

Thanks to Jack Steiner ([email protected]) for assistance tracking this down.

---
 mm/nobootmem.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/nobootmem.c +1 -2
Index: linux/mm/nobootmem.c
===================================================================
@@ -82,8 +82,7 @@ void __init free_bootmem_late(unsigned l
 
 static void __init __free_pages_memory(unsigned long start, unsigned long end)
 {
-	int i;
-	unsigned long start_aligned, end_aligned;
+	unsigned long i, start_aligned, end_aligned;
 	int order = ilog2(BITS_PER_LONG);
 
 	start_aligned = (start + (BITS_PER_LONG - 1)) & ~(BITS_PER_LONG - 1);
Signature · 9 lines
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          [email protected]

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw
Quoted 2 lines · On Mon, 7 May 2012 14:32:03 -0500 Russ Anderson <[email protected]> wrote:

Systems with 8 TBytes of memory or greater can hit a problem where only the the first 8 TB of memory shows up.

erk.

Quoted 10 lines

This is
due to "int i" being smaller than "unsigned long start_aligned", causing the high bits to be dropped.

The fix is to change i to unsigned long to match start_aligned and end_aligned.

Thanks to Jack Steiner ([email protected]) for assistance tracking this down.

I added the Cc: <[email protected]> to this. The fix is small and safe and someone might want to run older kernels on such a machine.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#2 lore raw
In reply to Russ Anderson
Quoted 4 lines · Russ Anderson

Systems with 8 TBytes of memory or greater can hit a problem where only the the first 8 TB of memory shows up.  This is due to "int i" being smaller than "unsigned long start_aligned", causing the high bits to be dropped.

when you have 8T installed, you should get [0,2g), [4g, 8T+2g)

if you have more than that. [2g, 4g) could be added as ram together with MMIO....

Quoted 18 lines

The fix is to change i to unsigned long to match start_aligned and end_aligned.

Thanks to Jack Steiner ([email protected]) for assistance tracking this down.

---
 mm/nobootmem.c |    3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux/mm/nobootmem.c
===================================================================

mm/nobootmem.c        2012-05-05 08:39:42.714784530 -0500 void __init free_bootmem_late(unsigned l · line 88

Quoted 9 lines
mm/nobootmem.c        2012-05-05 08:39:42.714784530 -0500 renamed from mm/nobootmem.c   2012-05-05 08:39:39.470845187 -0500 +1 -2
@@ -82,8 +82,7 @@ void __init free_bootmem_late(unsigned l
 
  static void __init __free_pages_memory(unsigned long start, unsigned long end)
  {
-       int i;
-       unsigned long start_aligned, end_aligned;
+       unsigned long i, start_aligned, end_aligned;
        int order = ilog2(BITS_PER_LONG);
 
        start_aligned = (start + (BITS_PER_LONG - 1)) & ~(BITS_PER_LONG - 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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>