Skip to content

Commit ea34f78

Browse files
rppttorvalds
authored andcommitted
ia64: forbid using VIRTUAL_MEM_MAP with FLATMEM
Virtual memory map was intended to avoid wasting memory on the memory map on systems with large holes in the physical memory layout. Long ago it been superseded first by DISCONTIGMEM and then by SPARSEMEM. Moreover, SPARSEMEM_VMEMMAP provide the same functionality in much more portable way. As the first step to removing the VIRTUAL_MEM_MAP forbid it's usage with FLATMEM and panic on systems with large holes in the physical memory layout that try to run FLATMEM kernels. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Matt Turner <[email protected]> Cc: Meelis Roos <[email protected]> Cc: Michael Schmitz <[email protected]> Cc: Russell King <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1f11212 commit ea34f78

File tree

4 files changed

+22
-44
lines changed

4 files changed

+22
-44
lines changed

arch/ia64/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ config NODES_SHIFT
329329
# VIRTUAL_MEM_MAP has been retained for historical reasons.
330330
config VIRTUAL_MEM_MAP
331331
bool "Virtual mem map"
332-
depends on !SPARSEMEM
332+
depends on !SPARSEMEM && !FLATMEM
333333
default y
334334
help
335335
Say Y to compile the kernel with support for a virtual mem map.

arch/ia64/include/asm/meminit.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ extern int reserve_elfcorehdr(u64 *start, u64 *end);
5959
extern int register_active_ranges(u64 start, u64 len, int nid);
6060

6161
#ifdef CONFIG_VIRTUAL_MEM_MAP
62-
# define LARGE_GAP 0x40000000 /* Use virtual mem map if hole is > than this */
6362
extern unsigned long VMALLOC_END;
6463
extern struct page *vmem_map;
65-
extern int find_largest_hole(u64 start, u64 end, void *arg);
6664
extern int create_mem_map_page_table(u64 start, u64 end, void *arg);
6765
extern int vmemmap_find_next_valid_pfn(int, int);
6866
#else

arch/ia64/mm/contig.c

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919
#include <linux/mm.h>
2020
#include <linux/nmi.h>
2121
#include <linux/swap.h>
22+
#include <linux/sizes.h>
2223

2324
#include <asm/meminit.h>
2425
#include <asm/sections.h>
2526
#include <asm/mca.h>
2627

27-
#ifdef CONFIG_VIRTUAL_MEM_MAP
28-
static unsigned long max_gap;
29-
#endif
30-
3128
/* physical address where the bootmem map is located */
3229
unsigned long bootmap_start;
3330

@@ -166,33 +163,30 @@ find_memory (void)
166163
alloc_per_cpu_data();
167164
}
168165

169-
static void __init virtual_map_init(void)
166+
static int __init find_largest_hole(u64 start, u64 end, void *arg)
170167
{
171-
#ifdef CONFIG_VIRTUAL_MEM_MAP
172-
efi_memmap_walk(find_largest_hole, (u64 *)&max_gap);
173-
if (max_gap < LARGE_GAP) {
174-
vmem_map = (struct page *) 0;
175-
} else {
176-
unsigned long map_size;
168+
u64 *max_gap = arg;
177169

178-
/* allocate virtual_mem_map */
170+
static u64 last_end = PAGE_OFFSET;
179171

180-
map_size = PAGE_ALIGN(ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) *
181-
sizeof(struct page));
182-
VMALLOC_END -= map_size;
183-
vmem_map = (struct page *) VMALLOC_END;
184-
efi_memmap_walk(create_mem_map_page_table, NULL);
172+
/* NOTE: this algorithm assumes efi memmap table is ordered */
185173

186-
/*
187-
* alloc_node_mem_map makes an adjustment for mem_map
188-
* which isn't compatible with vmem_map.
189-
*/
190-
NODE_DATA(0)->node_mem_map = vmem_map +
191-
find_min_pfn_with_active_regions();
174+
if (*max_gap < (start - last_end))
175+
*max_gap = start - last_end;
176+
last_end = end;
177+
return 0;
178+
}
192179

193-
printk("Virtual mem_map starts at 0x%p\n", mem_map);
194-
}
195-
#endif /* !CONFIG_VIRTUAL_MEM_MAP */
180+
static void __init verify_gap_absence(void)
181+
{
182+
unsigned long max_gap;
183+
184+
/* Forbid FLATMEM if hole is > than 1G */
185+
efi_memmap_walk(find_largest_hole, (u64 *)&max_gap);
186+
if (max_gap >= SZ_1G)
187+
panic("Cannot use FLATMEM with %ldMB hole\n"
188+
"Please switch over to SPARSEMEM\n",
189+
(max_gap >> 20));
196190
}
197191

198192
/*
@@ -210,7 +204,7 @@ paging_init (void)
210204
max_zone_pfns[ZONE_DMA32] = max_dma;
211205
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
212206

213-
virtual_map_init();
207+
verify_gap_absence();
214208

215209
free_area_init(max_zone_pfns);
216210
zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));

arch/ia64/mm/init.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -574,20 +574,6 @@ ia64_pfn_valid (unsigned long pfn)
574574
}
575575
EXPORT_SYMBOL(ia64_pfn_valid);
576576

577-
int __init find_largest_hole(u64 start, u64 end, void *arg)
578-
{
579-
u64 *max_gap = arg;
580-
581-
static u64 last_end = PAGE_OFFSET;
582-
583-
/* NOTE: this algorithm assumes efi memmap table is ordered */
584-
585-
if (*max_gap < (start - last_end))
586-
*max_gap = start - last_end;
587-
last_end = end;
588-
return 0;
589-
}
590-
591577
#endif /* CONFIG_VIRTUAL_MEM_MAP */
592578

593579
int __init register_active_ranges(u64 start, u64 len, int nid)

0 commit comments

Comments
 (0)