diff mbox

[PATCHv4] mm: Don't offset memmap for flatmem

Message ID CA+8MBbLGdYfQRPnVmT=te1y3C7PhCcXqbDGXb7LtqvCWTA+vDQ@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Luck Nov. 9, 2015, 11:20 p.m. UTC
> @@ -4984,9 +4987,9 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
>          */
>         if (pgdat == NODE_DATA(0)) {
>                 mem_map = NODE_DATA(0)->node_mem_map;
> -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> +#if defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) || defined(CONFIG_FLATMEM)
>                 if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
> -                       mem_map -= (pgdat->node_start_pfn - ARCH_PFN_OFFSET);
> +                       mem_map -= offset;
>  #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
>         }
>  #endif

This piece breaks ia64.  See the comment earlier in the function
that "ia64 gets its own node_mem_map" ... so we skip the initialization
of offset ... and arrive down here and just subtract "0" from mem_map.

Attached patch fixes ia64 ... does ARM still work if this is applied?

-Tony

Comments

Laura Abbott Nov. 10, 2015, 1:34 a.m. UTC | #1
On 11/9/15 3:20 PM, Tony Luck wrote:
>> @@ -4984,9 +4987,9 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
>>           */
>>          if (pgdat == NODE_DATA(0)) {
>>                  mem_map = NODE_DATA(0)->node_mem_map;
>> -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
>> +#if defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) || defined(CONFIG_FLATMEM)
>>                  if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
>> -                       mem_map -= (pgdat->node_start_pfn - ARCH_PFN_OFFSET);
>> +                       mem_map -= offset;
>>   #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
>>          }
>>   #endif
>
> This piece breaks ia64.  See the comment earlier in the function
> that "ia64 gets its own node_mem_map" ... so we skip the initialization
> of offset ... and arrive down here and just subtract "0" from mem_map.
>
> Attached patch fixes ia64 ... does ARM still work if this is applied?
>
> -Tony
>

Yes, this still fixes the problem for me. I see the pfn <-> page
translation working as expected.

Tested-by: Laura Abbott <laura@labbott.name>

Thanks,
Laura
diff mbox

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 208e4c7e771b..c4705095a516 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5266,6 +5266,7 @@  static void __paginginit free_area_init_core(struct pglist_data *pgdat)
 
 static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
 {
+	unsigned long __maybe_unused start = 0;
 	unsigned long __maybe_unused offset = 0;
 
 	/* Skip empty nodes */
@@ -5273,9 +5274,11 @@  static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
 		return;
 
 #ifdef CONFIG_FLAT_NODE_MEM_MAP
+	start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES - 1);
+	offset = pgdat->node_start_pfn - start;
 	/* ia64 gets its own node_mem_map, before this, without bootmem */
 	if (!pgdat->node_mem_map) {
-		unsigned long size, start, end;
+		unsigned long size, end;
 		struct page *map;
 
 		/*
@@ -5284,7 +5287,6 @@  static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
 		 * for the buddy allocator to function correctly.
 		 */
 		start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES - 1);
-		offset = pgdat->node_start_pfn - start;
 		end = pgdat_end_pfn(pgdat);
 		end = ALIGN(end, MAX_ORDER_NR_PAGES);
 		size =  (end - start) * sizeof(struct page);