linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization
@ 2014-05-08  7:06 Emil Medve
  2014-05-08  7:06 ` [PATCH 2/2 v3] powerpc: Enable NO_BOOTMEM Emil Medve
  2014-08-05  7:25 ` [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Anton Blanchard
  0 siblings, 2 replies; 4+ messages in thread
From: Emil Medve @ 2014-05-08  7:06 UTC (permalink / raw)
  To: benh, linuxppc-dev; +Cc: Emil Medve

Unify the low/highmem code path from do_init_bootmem() by using (the)
lowmem related variables/parameters even when the low/highmem split
is not needed (64-bit) or configured. In such cases the "lowmem"
variables/parameters continue to observe the definition by referring
to memory directly mapped by the kernel

Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
---

v2: Rebased, no changes

v3: No changes

 arch/powerpc/mm/mem.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 32202c9..eaf5d1d8 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -188,27 +188,31 @@ EXPORT_SYMBOL_GPL(walk_system_ram_range);
 void __init do_init_bootmem(void)
 {
 	unsigned long start, bootmap_pages;
-	unsigned long total_pages;
 	struct memblock_region *reg;
 	int boot_mapsize;
+	phys_addr_t _total_lowmem;
+	phys_addr_t _lowmem_end_addr;
 
-	max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
-	total_pages = (memblock_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT;
-#ifdef CONFIG_HIGHMEM
-	total_pages = total_lowmem >> PAGE_SHIFT;
-	max_low_pfn = lowmem_end_addr >> PAGE_SHIFT;
+#ifndef CONFIG_HIGHMEM
+	_lowmem_end_addr = memblock_end_of_DRAM();
+#else
+	_lowmem_end_addr = lowmem_end_addr;
 #endif
 
+	max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
+	max_low_pfn = _lowmem_end_addr >> PAGE_SHIFT;
+	min_low_pfn = MEMORY_START >> PAGE_SHIFT;
+
 	/*
 	 * Find an area to use for the bootmem bitmap.  Calculate the size of
 	 * bitmap required as (Total Memory) / PAGE_SIZE / BITS_PER_BYTE.
 	 * Add 1 additional page in case the address isn't page-aligned.
 	 */
-	bootmap_pages = bootmem_bootmap_pages(total_pages);
+	_total_lowmem = _lowmem_end_addr - memstart_addr;
+	bootmap_pages = bootmem_bootmap_pages(_total_lowmem >> PAGE_SHIFT);
 
 	start = memblock_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
 
-	min_low_pfn = MEMORY_START >> PAGE_SHIFT;
 	boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn);
 
 	/* Place all memblock_regions in the same node and merge contiguous
@@ -219,26 +223,18 @@ void __init do_init_bootmem(void)
 	/* Add all physical memory to the bootmem map, mark each area
 	 * present.
 	 */
-#ifdef CONFIG_HIGHMEM
-	free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT);
+	free_bootmem_with_active_regions(0, max_low_pfn);
 
 	/* reserve the sections we're already using */
 	for_each_memblock(reserved, reg) {
-		unsigned long top = reg->base + reg->size - 1;
-		if (top < lowmem_end_addr)
+		if (reg->base + reg->size - 1 < _lowmem_end_addr)
 			reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
-		else if (reg->base < lowmem_end_addr) {
-			unsigned long trunc_size = lowmem_end_addr - reg->base;
+		else if (reg->base < _lowmem_end_addr) {
+			unsigned long trunc_size = _lowmem_end_addr - reg->base;
 			reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT);
 		}
 	}
-#else
-	free_bootmem_with_active_regions(0, max_pfn);
 
-	/* reserve the sections we're already using */
-	for_each_memblock(reserved, reg)
-		reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
-#endif
 	/* XXX need to clip this if using highmem? */
 	sparse_memory_present_with_active_regions(0);
 
-- 
1.9.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2 v3] powerpc: Enable NO_BOOTMEM
  2014-05-08  7:06 [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Emil Medve
@ 2014-05-08  7:06 ` Emil Medve
  2014-08-05  7:25 ` [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Anton Blanchard
  1 sibling, 0 replies; 4+ messages in thread
From: Emil Medve @ 2014-05-08  7:06 UTC (permalink / raw)
  To: benh, linuxppc-dev; +Cc: Emil Medve

Currently bootmem is just a wrapper around/on top of memblock. This
eliminates from the build/kernel image the bootmem code and the
initialization wrapper code just as other ARHC(es) did: x86, arm,
etc

For now only cover !NUMA systems

Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
---

v2: Acknowledge that NUMA systems/builds are not covered by this patch

v3: Don't re-define NO_BOOTMEM
    Update the commit message

 arch/powerpc/Kconfig  | 1 +
 arch/powerpc/mm/mem.c | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e099899..3499303 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -105,6 +105,7 @@ config PPC
 	select HAVE_ARCH_KGDB
 	select HAVE_KRETPROBES
 	select HAVE_ARCH_TRACEHOOK
+	select NO_BOOTMEM if !NUMA
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
 	select HAVE_DMA_ATTRS
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index eaf5d1d8..d3e1d5f 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -187,10 +187,12 @@ EXPORT_SYMBOL_GPL(walk_system_ram_range);
 #ifndef CONFIG_NEED_MULTIPLE_NODES
 void __init do_init_bootmem(void)
 {
+#ifndef CONFIG_NO_BOOTMEM
 	unsigned long start, bootmap_pages;
 	struct memblock_region *reg;
 	int boot_mapsize;
 	phys_addr_t _total_lowmem;
+#endif
 	phys_addr_t _lowmem_end_addr;
 
 #ifndef CONFIG_HIGHMEM
@@ -203,6 +205,7 @@ void __init do_init_bootmem(void)
 	max_low_pfn = _lowmem_end_addr >> PAGE_SHIFT;
 	min_low_pfn = MEMORY_START >> PAGE_SHIFT;
 
+#ifndef CONFIG_NO_BOOTMEM
 	/*
 	 * Find an area to use for the bootmem bitmap.  Calculate the size of
 	 * bitmap required as (Total Memory) / PAGE_SIZE / BITS_PER_BYTE.
@@ -214,12 +217,14 @@ void __init do_init_bootmem(void)
 	start = memblock_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
 
 	boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn);
+#endif
 
 	/* Place all memblock_regions in the same node and merge contiguous
 	 * memblock_regions
 	 */
 	memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
 
+#ifndef CONFIG_NO_BOOTMEM
 	/* Add all physical memory to the bootmem map, mark each area
 	 * present.
 	 */
@@ -234,11 +239,14 @@ void __init do_init_bootmem(void)
 			reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT);
 		}
 	}
+#endif
 
 	/* XXX need to clip this if using highmem? */
 	sparse_memory_present_with_active_regions(0);
 
+#ifndef CONFIG_NO_BOOTMEM
 	init_bootmem_done = 1;
+#endif
 }
 
 /* mark pages that don't exist as nosave */
-- 
1.9.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization
  2014-05-08  7:06 [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Emil Medve
  2014-05-08  7:06 ` [PATCH 2/2 v3] powerpc: Enable NO_BOOTMEM Emil Medve
@ 2014-08-05  7:25 ` Anton Blanchard
  2014-08-05  7:28   ` Emil Medve
  1 sibling, 1 reply; 4+ messages in thread
From: Anton Blanchard @ 2014-08-05  7:25 UTC (permalink / raw)
  To: Emil Medve; +Cc: linuxppc-dev

Hi Emil,

> Unify the low/highmem code path from do_init_bootmem() by using (the)
> lowmem related variables/parameters even when the low/highmem split
> is not needed (64-bit) or configured. In such cases the "lowmem"
> variables/parameters continue to observe the definition by referring
> to memory directly mapped by the kernel

Ben pointed me at this patch after I had finished my bootmem removal
series. I can rebase on this one if it makes sense.

Anton

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization
  2014-08-05  7:25 ` [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Anton Blanchard
@ 2014-08-05  7:28   ` Emil Medve
  0 siblings, 0 replies; 4+ messages in thread
From: Emil Medve @ 2014-08-05  7:28 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev

Hello Anton,


On 08/05/2014 02:25 AM, Anton Blanchard wrote:
> Hi Emil,
> 
>> Unify the low/highmem code path from do_init_bootmem() by using (the)
>> lowmem related variables/parameters even when the low/highmem split
>> is not needed (64-bit) or configured. In such cases the "lowmem"
>> variables/parameters continue to observe the definition by referring
>> to memory directly mapped by the kernel
> 
> Ben pointed me at this patch after I had finished my bootmem removal
> series. I can rebase on this one if it makes sense.

I'll deffer to your judgment. I'm just happy to see bootmem gone

Later today, I'll test your patch series on some boards I have and I'll
notify you of the result. I have some of_reserved_mem based code that I
think will be a nice test case


Cheers,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-05  7:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08  7:06 [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Emil Medve
2014-05-08  7:06 ` [PATCH 2/2 v3] powerpc: Enable NO_BOOTMEM Emil Medve
2014-08-05  7:25 ` [PATCH 1/2 v3] bootmem/powerpc: Unify bootmem initialization Anton Blanchard
2014-08-05  7:28   ` Emil Medve

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