linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Hao <haokexin@gmail.com>
To: Kumar Gala <galak@kernel.crashing.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Scott Wood <scottwood@freescale.com>,
	linuxppc <linuxppc-dev@lists.ozlabs.org>,
	linux-mm@kvack.org
Subject: [PATCH v2 5/8] memblock: introduce the memblock_reinit function
Date: Thu, 4 Jul 2013 20:54:11 +0800	[thread overview]
Message-ID: <1372942454-25191-6-git-send-email-haokexin@gmail.com> (raw)
In-Reply-To: <1372942454-25191-1-git-send-email-haokexin@gmail.com>

In the current code, the data used by memblock are initialized
statically. But in some special cases we may scan the memory twice.
So we should have a way to reinitialize these data before the second
time.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
A new patch in v2.

 include/linux/memblock.h |  1 +
 mm/memblock.c            | 33 +++++++++++++++++++++++----------
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index f388203..9d55311 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -58,6 +58,7 @@ int memblock_remove(phys_addr_t base, phys_addr_t size);
 int memblock_free(phys_addr_t base, phys_addr_t size);
 int memblock_reserve(phys_addr_t base, phys_addr_t size);
 void memblock_trim_memory(phys_addr_t align);
+void memblock_reinit(void);
 
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
diff --git a/mm/memblock.c b/mm/memblock.c
index c5fad93..9406ce6 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -23,23 +23,36 @@
 static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
 static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
 
-struct memblock memblock __initdata_memblock = {
-	.memory.regions		= memblock_memory_init_regions,
-	.memory.cnt		= 1,	/* empty dummy entry */
-	.memory.max		= INIT_MEMBLOCK_REGIONS,
-
-	.reserved.regions	= memblock_reserved_init_regions,
-	.reserved.cnt		= 1,	/* empty dummy entry */
-	.reserved.max		= INIT_MEMBLOCK_REGIONS,
+#define INIT_MEMBLOCK {							\
+	.memory.regions		= memblock_memory_init_regions,		\
+	.memory.cnt		= 1,	/* empty dummy entry */		\
+	.memory.max		= INIT_MEMBLOCK_REGIONS,		\
+									\
+	.reserved.regions	= memblock_reserved_init_regions,	\
+	.reserved.cnt		= 1,	/* empty dummy entry */		\
+	.reserved.max		= INIT_MEMBLOCK_REGIONS,		\
+									\
+	.current_limit		= MEMBLOCK_ALLOC_ANYWHERE,		\
+}
 
-	.current_limit		= MEMBLOCK_ALLOC_ANYWHERE,
-};
+struct memblock memblock __initdata_memblock = INIT_MEMBLOCK;
 
 int memblock_debug __initdata_memblock;
 static int memblock_can_resize __initdata_memblock;
 static int memblock_memory_in_slab __initdata_memblock = 0;
 static int memblock_reserved_in_slab __initdata_memblock = 0;
 
+void __init memblock_reinit(void)
+{
+	memset(memblock_memory_init_regions, 0,
+				sizeof(memblock_memory_init_regions));
+	memset(memblock_reserved_init_regions, 0,
+				sizeof(memblock_reserved_init_regions));
+
+	memset(&memblock, 0, sizeof(memblock));
+	memblock = (struct memblock) INIT_MEMBLOCK;
+}
+
 /* inline so we don't get a warning when pr_debug is compiled out */
 static __init_memblock const char *
 memblock_type_name(struct memblock_type *type)
-- 
1.8.1.4

--
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>

           reply	other threads:[~2013-07-04 12:55 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1372942454-25191-1-git-send-email-haokexin@gmail.com>]

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=1372942454-25191-6-git-send-email-haokexin@gmail.com \
    --to=haokexin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=galak@kernel.crashing.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=scottwood@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).