diff options
author | Mel Gorman <mel@csn.ul.ie> | 2007-10-16 04:25:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:00 -0400 |
commit | 5c0e3066474b57c56ff0d88ca31d95bd14232fee (patch) | |
tree | 90c963c62891db4a9039e84e615c01408b09c845 /include/linux/mmzone.h | |
parent | 46dafbca2bba811665b01d8cedf911204820623c (diff) |
Fix corruption of memmap on IA64 SPARSEMEM when mem_section is not a power of 2
There are problems in the use of SPARSEMEM and pageblock flags that causes
problems on ia64.
The first part of the problem is that units are incorrect in
SECTION_BLOCKFLAGS_BITS computation. This results in a map_section's
section_mem_map being treated as part of a bitmap which isn't good. This
was evident with an invalid virtual address when mem_init attempted to free
bootmem pages while relinquishing control from the bootmem allocator.
The second part of the problem occurs because the pageblock flags bitmap is
be located with the mem_section. The SECTIONS_PER_ROOT computation using
sizeof (mem_section) may not be a power of 2 depending on the size of the
bitmap. This renders masks and other such things not power of 2 base.
This issue was seen with SPARSEMEM_EXTREME on ia64. This patch moves the
bitmap outside of mem_section and uses a pointer instead in the
mem_section. The bitmaps are allocated when the section is being
initialised.
Note that sparse_early_usemap_alloc() does not use alloc_remap() like
sparse_early_mem_map_alloc(). The allocation required for the bitmap on
x86, the only architecture that uses alloc_remap is typically smaller than
a cache line. alloc_remap() pads out allocations to the cache size which
would be a needless waste.
Credit to Bob Picco for identifying the original problem and effecting a
fix for the SECTION_BLOCKFLAGS_BITS calculation. Credit to Andy Whitcroft
for devising the best way of allocating the bitmaps only when required for
the section.
[wli@holomorphy.com: warning fix]
Signed-off-by: Bob Picco <bob.picco@hp.com>
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: William Irwin <bill.irwin@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mmzone.h')
-rw-r--r-- | include/linux/mmzone.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index a8140a9a65e8..9a5d5590bd39 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -748,7 +748,7 @@ extern struct zone *next_zone(struct zone *zone); | |||
748 | #define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1)) | 748 | #define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1)) |
749 | 749 | ||
750 | #define SECTION_BLOCKFLAGS_BITS \ | 750 | #define SECTION_BLOCKFLAGS_BITS \ |
751 | ((SECTION_SIZE_BITS - (MAX_ORDER-1)) * NR_PAGEBLOCK_BITS) | 751 | ((1 << (PFN_SECTION_SHIFT - (MAX_ORDER-1))) * NR_PAGEBLOCK_BITS) |
752 | 752 | ||
753 | #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS | 753 | #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS |
754 | #error Allocator MAX_ORDER exceeds SECTION_SIZE | 754 | #error Allocator MAX_ORDER exceeds SECTION_SIZE |
@@ -769,7 +769,9 @@ struct mem_section { | |||
769 | * before using it wrong. | 769 | * before using it wrong. |
770 | */ | 770 | */ |
771 | unsigned long section_mem_map; | 771 | unsigned long section_mem_map; |
772 | DECLARE_BITMAP(pageblock_flags, SECTION_BLOCKFLAGS_BITS); | 772 | |
773 | /* See declaration of similar field in struct zone */ | ||
774 | unsigned long *pageblock_flags; | ||
773 | }; | 775 | }; |
774 | 776 | ||
775 | #ifdef CONFIG_SPARSEMEM_EXTREME | 777 | #ifdef CONFIG_SPARSEMEM_EXTREME |