All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Sasha Levin <levinsasha928@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	hpa@linux.intel.com, linux-mm <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Early boot panic on machine with lots of memory
Date: Tue, 19 Jun 2012 14:20:59 -0700	[thread overview]
Message-ID: <20120619212059.GJ32733@google.com> (raw)
In-Reply-To: <20120619041154.GA28651@shangw>

Hello, guys.

On Tue, Jun 19, 2012 at 12:11:54PM +0800, Gavin Shan wrote:
> Here, [0x0000102febc080-0x0000102febf080] was released to available memory block
> by function free_low_memory_core_early(). I'm not sure the release memblock might
> be taken by bootmem, but I think it's worthy to have a try of removing following
> 2 lines: memblock_free_reserved_regions() and memblock_reserve_reserved_regions()
> 
> unsigned long __init free_low_memory_core_early(int nodeid)
> {
>         unsigned long count = 0;
>         phys_addr_t start, end;
>         u64 i;
> 
>         /* free reserved array temporarily so that it's treated as free area */
>         /* memblock_free_reserved_regions(); -REMOVED */
> 
>         for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) {
>                 unsigned long start_pfn = PFN_UP(start);
>                 unsigned long end_pfn = min_t(unsigned long,
>                                               PFN_DOWN(end), max_low_pfn);
>                 if (start_pfn < end_pfn) {
>                         __free_pages_memory(start_pfn, end_pfn);
>                         count += end_pfn - start_pfn;
>                 }
>         }
> 
>         /* put region array back? */
>         /* memblock_reserve_reserved_regions(); -REMOVED */
> 
>         return count;
> }

I think I figured out what's going on.  Sasha, your kernel has
CONFIG_DEBUG_PAGEALLOC enabled, right?  __free_pages_memory() hands
the memory area to the buddy page allocator which marks the pages
not-present in the page table if CONFIG_DEBUG_PAGEALLOC is set by
calling kernel_map_pages().  reserved array doesn't tend to be too big
and ends up surrounded by other reserved areas to avoid being returned
to page allocator but on your setup it ends up being doubled towards
the end of the boot process and gets unmapped triggering page fault on
the following attempt to access the table.

Something like the following should fix it.

diff --git a/mm/memblock.c b/mm/memblock.c
index 32a0a5e..2770970 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -148,11 +148,15 @@ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start,
  */
 int __init_memblock memblock_free_reserved_regions(void)
 {
+#ifndef CONFIG_DEBUG_PAGEALLOC
 	if (memblock.reserved.regions == memblock_reserved_init_regions)
 		return 0;
 
 	return memblock_free(__pa(memblock.reserved.regions),
 		 sizeof(struct memblock_region) * memblock.reserved.max);
+#else
+	return 0;
+#endif
 }
 
 /*
@@ -160,11 +164,15 @@ int __init_memblock memblock_free_reserved_regions(void)
  */
 int __init_memblock memblock_reserve_reserved_regions(void)
 {
+#ifndef COFNIG_DEBUG_PAGEALLOC
 	if (memblock.reserved.regions == memblock_reserved_init_regions)
 		return 0;
 
 	return memblock_reserve(__pa(memblock.reserved.regions),
 		 sizeof(struct memblock_region) * memblock.reserved.max);
+#else
+	return 0;
+#endif
 }
 
 static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)


WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Sasha Levin <levinsasha928@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	hpa@linux.intel.com, linux-mm <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Early boot panic on machine with lots of memory
Date: Tue, 19 Jun 2012 14:20:59 -0700	[thread overview]
Message-ID: <20120619212059.GJ32733@google.com> (raw)
In-Reply-To: <20120619041154.GA28651@shangw>

Hello, guys.

On Tue, Jun 19, 2012 at 12:11:54PM +0800, Gavin Shan wrote:
> Here, [0x0000102febc080-0x0000102febf080] was released to available memory block
> by function free_low_memory_core_early(). I'm not sure the release memblock might
> be taken by bootmem, but I think it's worthy to have a try of removing following
> 2 lines: memblock_free_reserved_regions() and memblock_reserve_reserved_regions()
> 
> unsigned long __init free_low_memory_core_early(int nodeid)
> {
>         unsigned long count = 0;
>         phys_addr_t start, end;
>         u64 i;
> 
>         /* free reserved array temporarily so that it's treated as free area */
>         /* memblock_free_reserved_regions(); -REMOVED */
> 
>         for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) {
>                 unsigned long start_pfn = PFN_UP(start);
>                 unsigned long end_pfn = min_t(unsigned long,
>                                               PFN_DOWN(end), max_low_pfn);
>                 if (start_pfn < end_pfn) {
>                         __free_pages_memory(start_pfn, end_pfn);
>                         count += end_pfn - start_pfn;
>                 }
>         }
> 
>         /* put region array back? */
>         /* memblock_reserve_reserved_regions(); -REMOVED */
> 
>         return count;
> }

I think I figured out what's going on.  Sasha, your kernel has
CONFIG_DEBUG_PAGEALLOC enabled, right?  __free_pages_memory() hands
the memory area to the buddy page allocator which marks the pages
not-present in the page table if CONFIG_DEBUG_PAGEALLOC is set by
calling kernel_map_pages().  reserved array doesn't tend to be too big
and ends up surrounded by other reserved areas to avoid being returned
to page allocator but on your setup it ends up being doubled towards
the end of the boot process and gets unmapped triggering page fault on
the following attempt to access the table.

Something like the following should fix it.

diff --git a/mm/memblock.c b/mm/memblock.c
index 32a0a5e..2770970 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -148,11 +148,15 @@ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start,
  */
 int __init_memblock memblock_free_reserved_regions(void)
 {
+#ifndef CONFIG_DEBUG_PAGEALLOC
 	if (memblock.reserved.regions == memblock_reserved_init_regions)
 		return 0;
 
 	return memblock_free(__pa(memblock.reserved.regions),
 		 sizeof(struct memblock_region) * memblock.reserved.max);
+#else
+	return 0;
+#endif
 }
 
 /*
@@ -160,11 +164,15 @@ int __init_memblock memblock_free_reserved_regions(void)
  */
 int __init_memblock memblock_reserve_reserved_regions(void)
 {
+#ifndef COFNIG_DEBUG_PAGEALLOC
 	if (memblock.reserved.regions == memblock_reserved_init_regions)
 		return 0;
 
 	return memblock_reserve(__pa(memblock.reserved.regions),
 		 sizeof(struct memblock_region) * memblock.reserved.max);
+#else
+	return 0;
+#endif
 }
 
 static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2012-06-19 21:21 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-13 21:38 Early boot panic on machine with lots of memory Sasha Levin
2012-06-14  3:20 ` Tejun Heo
2012-06-14  3:20   ` Tejun Heo
2012-06-14  9:50   ` Sasha Levin
2012-06-14  9:50     ` Sasha Levin
2012-06-14 20:56     ` Yinghai Lu
2012-06-14 20:56       ` Yinghai Lu
2012-06-14 21:34       ` Sasha Levin
2012-06-14 21:34         ` Sasha Levin
2012-06-14 23:57         ` Yinghai Lu
2012-06-14 23:57           ` Yinghai Lu
2012-06-15  0:59           ` Sasha Levin
2012-06-15  0:59             ` Sasha Levin
2012-06-15  0:59             ` Sasha Levin
2012-06-15  2:21             ` Yinghai Lu
2012-06-15  2:21               ` Yinghai Lu
2012-06-15  7:41               ` Sasha Levin
2012-06-15  7:41                 ` Sasha Levin
2012-06-18 22:32     ` Tejun Heo
2012-06-18 22:32       ` Tejun Heo
2012-06-18 22:50       ` Sasha Levin
2012-06-18 22:50         ` Sasha Levin
2012-06-19  4:11         ` Gavin Shan
2012-06-19  4:11           ` Gavin Shan
2012-06-19  5:43           ` Yinghai Lu
2012-06-19  5:43             ` Yinghai Lu
2012-06-19  6:09             ` Gavin Shan
2012-06-19  6:09               ` Gavin Shan
2012-06-19 18:12               ` Yinghai Lu
2012-06-19 18:12                 ` Yinghai Lu
2012-06-19 21:20           ` Tejun Heo [this message]
2012-06-19 21:20             ` Tejun Heo
2012-06-19 21:26             ` Tejun Heo
2012-06-19 21:26               ` Tejun Heo
2012-06-20  2:57               ` Yinghai Lu
2012-06-21 20:17                 ` Tejun Heo
2012-06-21 20:17                   ` Tejun Heo
2012-06-22  1:47                   ` Yinghai Lu
2012-06-22  1:58                     ` Yinghai Lu
2012-06-22 18:51                     ` Tejun Heo
2012-06-22 18:51                       ` Tejun Heo
2012-06-22 19:23                       ` Yinghai Lu
2012-06-22 19:23                         ` Yinghai Lu
2012-06-22 19:29                         ` Tejun Heo
2012-06-22 19:29                           ` Tejun Heo
2012-06-22 20:01                           ` Yinghai Lu
2012-06-22 20:01                             ` Yinghai Lu
2012-06-22 20:14                             ` Tejun Heo
2012-06-22 20:14                               ` Tejun Heo
2012-06-22 20:23                               ` Yinghai Lu
2012-06-22 20:23                                 ` Yinghai Lu
2012-06-23  2:14                           ` Yinghai Lu
2012-06-27 18:13                             ` Tejun Heo
2012-06-27 18:13                               ` Tejun Heo
2012-06-27 19:22                               ` Yinghai Lu
2012-06-27 19:22                                 ` Yinghai Lu
2012-06-27 19:26                                 ` Tejun Heo
2012-06-27 19:26                                   ` Tejun Heo
2012-06-27 21:15                                   ` Yinghai Lu
2012-06-29 18:27                                     ` [PATCH for -3.5] memblock: free allocated memblock_reserved_regions later Yinghai Lu
2012-06-29 18:27                                       ` Yinghai Lu
2012-06-29 18:32                                       ` Tejun Heo
2012-06-29 18:32                                         ` Tejun Heo
2012-06-29 18:38                                         ` Yinghai Lu
2012-06-29 18:38                                           ` Yinghai Lu
2012-06-21 20:19             ` Early boot panic on machine with lots of memory Tejun Heo
2012-06-21 20:19               ` Tejun Heo
2012-06-22 10:29               ` Sasha Levin
2012-06-22 10:29                 ` Sasha Levin
2012-06-22 18:15                 ` Yinghai Lu
2012-06-22 18:15                   ` Yinghai Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120619212059.GJ32733@google.com \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=hpa@linux.intel.com \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shangw@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.