linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/24] mm: Use memblock interface instead of bootmem
@ 2013-11-08 23:41 Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 01/24] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
                   ` (24 more replies)
  0 siblings, 25 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	H. Peter Anvin, Andrew Morton, Russell King, Arnd Bergmann,
	Nicolas Pitre, Olof Johansson

Tejun and others,

Following up with the earlier RFC [1] comments, here is the updated
patch series based on the discussion. This series is the last bottleneck
now for me to enable the coherency on keystone ARM LPAE architecture on which
the physical memory starts after 4BG. I would like to get these patches
in next merge window(3.14), so any help in terms of testing/comments is
appreciated.

To recap on the original issue, current memblock APIs don't work on
32 PAE or LPAE extension arches where the physical memory start
address beyond 4GB. The problem was discussed here [2] where
Tejun, Yinghai(thanks) proposed a way forward with memblock interfaces.
Based on the proposal, this series adds necessary memblock interfaces
and convert the core kernel code to use them. Architectures already
converted to NO_BOOTMEM use these new interfaces and other which still
uses bootmem, these new interfaces just fallback to exiting bootmem APIs.

So no functional change in behavior. In long run, once all the architectures
moves to NO_BOOTMEM, we can get rid of bootmem layer completely. This is
one step to remove the core code dependency with bootmem and also
gives path for architectures to move away from bootmem.

Testing is done on ARM architecture with 32 bit ARM LAPE machines
with normal as well sparse(faked) memory model. To convert ARM to
NO_BOOTMEM, we have used Russell's work [3] and couple of patches
on top of that. I will be posting those patches as well after 3.13-rc1

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Olof Johansson <olof@lixom.net>

Grygorii Strashko (10):
  mm/memblock: debug: correct displaying of upper memory boundary
  mm/memblock: debug: don't free reserved array if
    !ARCH_DISCARD_MEMBLOCK
  mm/bootmem: remove duplicated declaration of __free_pages_bootmem()
  mm/block: remove unnecessary inclusion of bootmem.h
  mm/memory_hotplug: remove unnecessary inclusion of bootmem.h
  mm/staging: remove unnecessary inclusion of bootmem.h
  mm/char: remove unnecessary inclusion of bootmem.h
  mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment
  mm/hugetlb: Use memblock apis for early memory allocations
  mm/page_cgroup: Use memblock apis for early memory allocations

Santosh Shilimkar (14):
  mm/memblock: Add memblock memory allocation apis
  mm/init: Use memblock apis for early memory allocations
  mm/printk: Use memblock apis for early memory allocations
  mm/page_alloc: Use memblock apis for early memory allocations
  mm/power: Use memblock apis for early memory allocations
  mm/lib/swiotlb: Use memblock apis for early memory allocations
  mm/lib/cpumask: Use memblock apis for early memory allocations
  mm/sparse: Use memblock apis for early memory allocations
  mm/percpu: Use memblock apis for early memory allocations
  mm/memory_hotplug: Use memblock apis for early memory allocations
  mm/firmware: Use memblock apis for early memory allocations
  mm/ARM: kernel: Use memblock apis for early memory allocations
  mm/ARM: mm: Use memblock apis for early memory allocations
  mm/ARM: OMAP: Use memblock apis for early memory allocations

 arch/arm/kernel/devtree.c        |    2 +-
 arch/arm/kernel/setup.c          |    2 +-
 arch/arm/mach-omap2/omap_hwmod.c |    8 +-
 arch/arm/mm/init.c               |    2 +-
 block/blk-ioc.c                  |    1 -
 drivers/char/mem.c               |    1 -
 drivers/firmware/memmap.c        |    2 +-
 drivers/staging/speakup/main.c   |    2 -
 include/linux/bootmem.h          |   84 ++++++++++++++-
 init/main.c                      |    4 +-
 kernel/power/snapshot.c          |    2 +-
 kernel/printk/printk.c           |   10 +-
 lib/cpumask.c                    |    4 +-
 lib/swiotlb.c                    |   36 ++++---
 mm/hugetlb.c                     |   10 +-
 mm/memblock.c                    |  215 +++++++++++++++++++++++++++++++++++++-
 mm/memory_hotplug.c              |    3 +-
 mm/page_alloc.c                  |   27 ++---
 mm/page_cgroup.c                 |    5 +-
 mm/percpu.c                      |   41 +++++---
 mm/sparse-vmemmap.c              |    6 +-
 mm/sparse.c                      |   27 ++---
 22 files changed, 397 insertions(+), 97 deletions(-)

Regards,
Santosh

[1] https://lkml.org/lkml/2013/10/12/147
[2] https://lkml.org/lkml/2013/6/29/77
[3] http://lwn.net/Articles/561854/

-- 
1.7.9.5

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

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

* [PATCH 01/24] mm/memblock: debug: correct displaying of upper memory boundary
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 02/24] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK Santosh Shilimkar
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

When debugging is enabled (cmdline has "memblock=debug") the memblock
will display upper memory boundary per each allocated/freed memory range
wrongly. For example:
 memblock_reserve: [0x0000009e7e8000-0x0000009e7ed000] _memblock_early_alloc_try_nid_nopanic+0xfc/0x12c

The 0x0000009e7ed000 is displayed instead of 0x0000009e7ecfff

Hence, correct this by changing formula used to calculate upper memory
boundary to (u64)base + size - 1 instead of  (u64)base + size everywhere
in the debug messages.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/memblock.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 0ac412a..e03918e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -545,7 +545,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 {
 	memblock_dbg("   memblock_free: [%#016llx-%#016llx] %pF\n",
 		     (unsigned long long)base,
-		     (unsigned long long)base + size,
+		     (unsigned long long)base + size - 1,
 		     (void *)_RET_IP_);
 
 	return __memblock_remove(&memblock.reserved, base, size);
@@ -557,7 +557,7 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 
 	memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
 		     (unsigned long long)base,
-		     (unsigned long long)base + size,
+		     (unsigned long long)base + size - 1,
 		     (void *)_RET_IP_);
 
 	return memblock_add_region(_rgn, base, size, MAX_NUMNODES);
-- 
1.7.9.5

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

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

* [PATCH 02/24] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 01/24] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 03/24] mm/bootmem: remove duplicated declaration of __free_pages_bootmem() Santosh Shilimkar
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Now the Nobootmem allocator will always try to free memory allocated for
reserved memory regions (free_low_memory_core_early()) without taking
into to account current memblock debugging configuration
(CONFIG_ARCH_DISCARD_MEMBLOCK and CONFIG_DEBUG_FS state).
As result if:
 - CONFIG_DEBUG_FS defined
 - CONFIG_ARCH_DISCARD_MEMBLOCK not defined;
-  reserved memory regions array have been resized during boot

then:
- memory allocated for reserved memory regions array will be freed to
buddy allocator;
- debug_fs entry "sys/kernel/debug/memblock/reserved" will show garbage
instead of state of memory reservations. like:
   0: 0x98393bc0..0x9a393bbf
   1: 0xff120000..0xff11ffff
   2: 0x00000000..0xffffffff

Hence, do not free memory allocated for reserved memory regions if
defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK).

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/memblock.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/mm/memblock.c b/mm/memblock.c
index e03918e..88a6a0e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -167,6 +167,19 @@ phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
 	if (memblock.reserved.regions == memblock_reserved_init_regions)
 		return 0;
 
+	/*
+	 * Don't allow Nobootmem allocator to free reserved memory regions
+	 * array if
+	 *  - CONFIG_DEBUG_FS is enabled;
+	 *  - CONFIG_ARCH_DISCARD_MEMBLOCK is not enabled;
+	 *  - reserved memory regions array have been resized during boot.
+	 * Otherwise debug_fs entry "sys/kernel/debug/memblock/reserved"
+	 * will show garbage instead of state of memory reservations.
+	 */
+	if (IS_ENABLED(CONFIG_DEBUG_FS) &&
+	    !IS_ENABLED(CONFIG_ARCH_DISCARD_MEMBLOCK))
+		return 0;
+
 	*addr = __pa(memblock.reserved.regions);
 
 	return PAGE_ALIGN(sizeof(struct memblock_region) *
-- 
1.7.9.5

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

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

* [PATCH 03/24] mm/bootmem: remove duplicated declaration of __free_pages_bootmem()
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 01/24] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 02/24] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h Santosh Shilimkar
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

The __free_pages_bootmem is used internally by MM core and
already defined in internal.h. So, remove duplicated declaration.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 include/linux/bootmem.h |    1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index f1f07d3..55d52fb 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -52,7 +52,6 @@ extern void free_bootmem_node(pg_data_t *pgdat,
 			      unsigned long size);
 extern void free_bootmem(unsigned long physaddr, unsigned long size);
 extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
-extern void __free_pages_bootmem(struct page *page, unsigned int order);
 
 /*
  * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
-- 
1.7.9.5

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

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

* [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (2 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 03/24] mm/bootmem: remove duplicated declaration of __free_pages_bootmem() Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-13  2:09   ` Jens Axboe
  2013-11-08 23:41 ` [PATCH 05/24] mm/memory_hotplug: " Santosh Shilimkar
                   ` (20 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Jens Axboe, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Clean-up to remove depedency with bootmem headers.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 block/blk-ioc.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 46cd7bd..242df01 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -6,7 +6,6 @@
 #include <linux/init.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
-#include <linux/bootmem.h>	/* for max_pfn/max_low_pfn */
 #include <linux/slab.h>
 
 #include "blk.h"
-- 
1.7.9.5

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

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

* [PATCH 05/24] mm/memory_hotplug: remove unnecessary inclusion of bootmem.h
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (3 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 06/24] mm/staging: " Santosh Shilimkar
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Clean-up to remove depedency with bootmem headers.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/memory_hotplug.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index ed85fe3..f7bda5e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -9,7 +9,6 @@
 #include <linux/swap.h>
 #include <linux/interrupt.h>
 #include <linux/pagemap.h>
-#include <linux/bootmem.h>
 #include <linux/compiler.h>
 #include <linux/export.h>
 #include <linux/pagevec.h>
-- 
1.7.9.5

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

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

* [PATCH 06/24] mm/staging: remove unnecessary inclusion of bootmem.h
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (4 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 05/24] mm/memory_hotplug: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 07/24] mm/char: " Santosh Shilimkar
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, William Hubbs, Chris Brannon, Kirk Reiser,
	Greg Kroah-Hartman, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Clean-up to remove depedency with bootmem headers.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 drivers/staging/speakup/main.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 14079c4..041f01e 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -37,8 +37,6 @@
 #include <linux/input.h>
 #include <linux/kmod.h>
 
-#include <linux/bootmem.h>	/* for alloc_bootmem */
-
 /* speakup_*_selection */
 #include <linux/module.h>
 #include <linux/sched.h>
-- 
1.7.9.5

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

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

* [PATCH 07/24] mm/char: remove unnecessary inclusion of bootmem.h
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (5 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 06/24] mm/staging: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 08/24] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment Santosh Shilimkar
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Arnd Bergmann, Greg Kroah-Hartman,
	Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Clean-up to remove depedency with bootmem headers.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 drivers/char/mem.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index f895a8c..92c5937 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -22,7 +22,6 @@
 #include <linux/device.h>
 #include <linux/highmem.h>
 #include <linux/backing-dev.h>
-#include <linux/bootmem.h>
 #include <linux/splice.h>
 #include <linux/pfn.h>
 #include <linux/export.h>
-- 
1.7.9.5

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

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

* [PATCH 08/24] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (6 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 07/24] mm/char: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 09/24] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu, Andrew Morton

From: Grygorii Strashko <grygorii.strashko@ti.com>

drop WARN and use SMP_CACHE_BYTES as a default alignment in
memblock_alloc_base_nid() as recommended by Tejun Heo in
https://lkml.org/lkml/2013/10/13/117.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 mm/memblock.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 88a6a0e..36b795f 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -785,8 +785,8 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size,
 {
 	phys_addr_t found;
 
-	if (WARN_ON(!align))
-		align = __alignof__(long long);
+	if (!align)
+		align = SMP_CACHE_BYTES;
 
 	/* align @size to avoid excessive fragmentation on reserved array */
 	size = round_up(size, align);
-- 
1.7.9.5

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

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

* [PATCH 09/24] mm/memblock: Add memblock memory allocation apis
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (7 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 08/24] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-12-03  0:31   ` Andrew Morton
  2013-11-08 23:41 ` [PATCH 10/24] mm/init: Use memblock apis for early memory allocations Santosh Shilimkar
                   ` (15 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Grygorii Strashko

Introduce memblock memory allocation APIs which allow to support
PAE or LPAE extension on 32 bits archs where the physical memory start
address can be beyond 4GB. In such cases, existing bootmem APIs which
operate on 32 bit addresses won't work and needs memblock layer which
operates on 64 bit addresses.

So we add equivalent APIs so that we can replace usage of bootmem
with memblock interfaces. Architectures already converted to NO_BOOTMEM
use these new interfaces and other which still uses bootmem, these new
APIs just fallback to exiting bootmem APIs. So no functional change as
such.

In long run, once all the achitectures moves to NO_BOOTMEM, we can get rid of
bootmem layer completely. This is one step to remove the core code dependency
with bootmem and also gives path for architectures to move away from bootmem.

The proposed interface will became active if both CONFIG_HAVE_MEMBLOCK
and CONFIG_NO_BOOTMEM are specified by arch. In case !CONFIG_NO_BOOTMEM,
the memblock() wrappers will fallback to the existing bootmem apis so
that arch's not converted to NO_BOOTMEM continue to work as is.

The meaning of MEMBLOCK_ALLOC_ACCESSIBLE and MEMBLOCK_ALLOC_ANYWHERE is
kept same.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 include/linux/bootmem.h |   83 ++++++++++++++++++++
 mm/memblock.c           |  194 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 277 insertions(+)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 55d52fb..418fdb3 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -141,6 +141,89 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
 #define alloc_bootmem_low_pages_node(pgdat, x) \
 	__alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
 
+
+#if defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM)
+
+/* FIXME: use MEMBLOCK_ALLOC_* variants here */
+#define BOOTMEM_ALLOC_ACCESSIBLE	0
+#define BOOTMEM_ALLOC_ANYWHERE		(~(phys_addr_t)0)
+
+/*
+ * FIXME: use NUMA_NO_NODE instead of MAX_NUMNODES when bootmem/nobootmem code
+ * will be removed.
+ * It can't be done now, because when MEMBLOCK or NO_BOOTMEM are not enabled
+ * all calls of the new API will be redirected to bottmem/nobootmem where
+ * MAX_NUMNODES is widely used.
+ * Also, memblock core APIs __next_free_mem_range_rev() and
+ * __next_free_mem_range() would need to be updated, and as result we will
+ * need to re-check/update all direct calls of memblock_alloc_xxx()
+ * APIs (including nobootmem).
+ */
+
+/* FIXME: Move to memblock.h at a point where we remove nobootmem.c */
+void *memblock_virt_alloc_try_nid_nopanic(phys_addr_t size,
+		phys_addr_t align, phys_addr_t from,
+		phys_addr_t max_addr, int nid);
+void *memblock_virt_alloc_try_nid(phys_addr_t size, phys_addr_t align,
+		phys_addr_t from, phys_addr_t max_addr, int nid);
+void __memblock_free_early(phys_addr_t base, phys_addr_t size);
+void __memblock_free_late(phys_addr_t base, phys_addr_t size);
+
+#define memblock_virt_alloc(x) \
+	memblock_virt_alloc_try_nid(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT, \
+				     BOOTMEM_ALLOC_ACCESSIBLE, MAX_NUMNODES)
+#define memblock_virt_alloc_align(x, align) \
+	memblock_virt_alloc_try_nid(x, align, BOOTMEM_LOW_LIMIT, \
+				     BOOTMEM_ALLOC_ACCESSIBLE, MAX_NUMNODES)
+#define memblock_virt_alloc_nopanic(x) \
+	memblock_virt_alloc_try_nid_nopanic(x, SMP_CACHE_BYTES, \
+					     BOOTMEM_LOW_LIMIT, \
+					     BOOTMEM_ALLOC_ACCESSIBLE, \
+					     MAX_NUMNODES)
+#define memblock_virt_alloc_align_nopanic(x, align) \
+	memblock_virt_alloc_try_nid_nopanic(x, align, \
+					     BOOTMEM_LOW_LIMIT, \
+					     BOOTMEM_ALLOC_ACCESSIBLE, \
+					     MAX_NUMNODES)
+#define memblock_virt_alloc_node(x, nid) \
+	memblock_virt_alloc_try_nid(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT, \
+				     BOOTMEM_ALLOC_ACCESSIBLE, nid)
+#define memblock_virt_alloc_node_nopanic(x, nid) \
+	memblock_virt_alloc_try_nid_nopanic(x, SMP_CACHE_BYTES, \
+					     BOOTMEM_LOW_LIMIT, \
+					     BOOTMEM_ALLOC_ACCESSIBLE, nid)
+
+#define memblock_free_early(x, s)		__memblock_free_early(x, s)
+#define memblock_free_early_nid(x, s, nid)	__memblock_free_early(x, s)
+#define memblock_free_late(x, s)		__memblock_free_late(x, s)
+
+#else
+
+/* Fall back to all the existing bootmem APIs */
+#define memblock_virt_alloc(x) \
+	__alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
+#define memblock_virt_alloc_align(x, align) \
+	__alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT)
+#define memblock_virt_alloc_nopanic(x) \
+	__alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
+#define memblock_virt_alloc_node(x, nid) \
+	__alloc_bootmem_node(NODE_DATA(nid), x, SMP_CACHE_BYTES, \
+			BOOTMEM_LOW_LIMIT)
+#define memblock_virt_alloc_node_nopanic(x, nid) \
+	__alloc_bootmem_node_nopanic(NODE_DATA(nid), x, SMP_CACHE_BYTES, \
+			BOOTMEM_LOW_LIMIT)
+#define memblock_virt_alloc_try_nid(size, align, from, max_addr, nid) \
+		__alloc_bootmem_node_high(NODE_DATA(nid), size, align, from)
+#define memblock_virt_alloc_try_nid_nopanic(size, align, from, max_addr, nid) \
+		___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align, \
+			from, max_addr)
+#define memblock_free_early(x, s)	free_bootmem(x, s)
+#define memblock_free_early_nid(x, s, nid) \
+			free_bootmem_node(NODE_DATA(nid), x, s)
+#define memblock_free_late(x, s)	free_bootmem_late(x, s)
+
+#endif /* defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) */
+
 #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
 extern void *alloc_remap(int nid, unsigned long size);
 #else
diff --git a/mm/memblock.c b/mm/memblock.c
index 36b795f..524b089 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -20,6 +20,8 @@
 #include <linux/seq_file.h>
 #include <linux/memblock.h>
 
+#include "internal.h"
+
 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;
 
@@ -835,6 +837,198 @@ phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, i
 	return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
 }
 
+/**
+ * _memblock_virt_alloc_try_nid_nopanic - allocate boot memory block
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @from: the lower bound of the memory region from where the allocation
+ *	  is preferred (phys address)
+ * @max_addr: the upper bound of the memory region from where the allocation
+ *	      is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to
+ *	      allocate only from memory limited by memblock.current_limit value
+ * @nid: nid of the free area to find, %MAX_NUMNODES for any node
+ *
+ * The @from limit is dropped if it can not be satisfied and the allocation
+ * will fall back to memory below @from.
+ *
+ * Allocation may fall back to any node in the system if the specified node
+ * can not hold the requested memory.
+ *
+ * The phys address of allocated boot memory block is converted to virtual and
+ * allocated memory is reset to 0.
+ *
+ * In addition, function sets sets the min_count for allocated boot memory block
+ * to 0 so that it is never reported as leaks.
+ *
+ * RETURNS:
+ * Virtual address of allocated memory block on success, NULL on failure.
+ */
+static void * __init _memblock_virt_alloc_try_nid_nopanic(
+				phys_addr_t size, phys_addr_t align,
+				phys_addr_t from, phys_addr_t max_addr,
+				int nid)
+{
+	phys_addr_t alloc;
+	void *ptr;
+
+	if (WARN_ON_ONCE(slab_is_available())) {
+		if (nid == MAX_NUMNODES)
+			return kzalloc(size, GFP_NOWAIT);
+		else
+			return kzalloc_node(size, GFP_NOWAIT, nid);
+	}
+
+	if (!align)
+		align = SMP_CACHE_BYTES;
+
+	/* align @size to avoid excessive fragmentation on reserved array */
+	size = round_up(size, align);
+
+again:
+	alloc = memblock_find_in_range_node(from, max_addr, size, align, nid);
+	if (alloc)
+		goto done;
+
+	if (nid != MAX_NUMNODES) {
+		alloc = memblock_find_in_range_node(from, max_addr, size,
+						    align, MAX_NUMNODES);
+		if (alloc)
+			goto done;
+	}
+
+	if (from) {
+		from = 0;
+		goto again;
+	} else {
+		goto error;
+	}
+
+done:
+	memblock_reserve(alloc, size);
+	ptr = phys_to_virt(alloc);
+	memset(ptr, 0, size);
+
+	/*
+	 * The min_count is set to 0 so that bootmem allocated blocks
+	 * are never reported as leaks.
+	 */
+	kmemleak_alloc(ptr, size, 0, 0);
+
+	return ptr;
+
+error:
+	return NULL;
+}
+
+/**
+ * memblock_virt_alloc_try_nid_nopanic - allocate boot memory block
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @from: the lower bound of the memory region from where the allocation
+ *	  is preferred (phys address)
+ * @max_addr: the upper bound of the memory region from where the allocation
+ *	      is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to
+ *	      allocate only from memory limited by memblock.current_limit value
+ * @nid: nid of the free area to find, %MAX_NUMNODES for any node
+ *
+ * Public version of _memblock_virt_alloc_try_nid_nopanic() which provides
+ * additional debug information (including caller info), if enabled.
+ *
+ * RETURNS:
+ * Virtual address of allocated memory block on success, NULL on failure.
+ */
+void * __init memblock_virt_alloc_try_nid_nopanic(
+				phys_addr_t size, phys_addr_t align,
+				phys_addr_t from, phys_addr_t max_addr,
+				int nid)
+{
+	memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx %pF\n",
+		     __func__, (u64)size, (u64)align, nid, (u64)from,
+		     (u64)max_addr, (void *)_RET_IP_);
+	return _memblock_virt_alloc_try_nid_nopanic(size,
+						align, from, max_addr, nid);
+}
+
+/**
+ * memblock_virt_alloc_try_nid - allocate boot memory block with panicking
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @from: the lower bound of the memory region from where the allocation
+ *	  is preferred (phys address)
+ * @max_addr: the upper bound of the memory region from where the allocation
+ *	      is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to
+ *	      allocate only from memory limited by memblock.current_limit value
+ * @nid: nid of the free area to find, %MAX_NUMNODES for any node
+ *
+ * Public panicking version of _memblock_virt_alloc_try_nid_nopanic()
+ * which provides debug information (including caller info), if enabled,
+ * and panics if the request can not be satisfied.
+ *
+ * RETURNS:
+ * Virtual address of allocated memory block on success, NULL on failure.
+ */
+void * __init memblock_virt_alloc_try_nid(
+			phys_addr_t size, phys_addr_t align,
+			phys_addr_t from, phys_addr_t max_addr,
+			int nid)
+{
+	void *ptr;
+
+	memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx %pF\n",
+		     __func__, (u64)size, (u64)align, nid, (u64)from,
+		     (u64)max_addr, (void *)_RET_IP_);
+	ptr = _memblock_virt_alloc_try_nid_nopanic(size,
+					align, from, max_addr, nid);
+	if (ptr)
+		return ptr;
+
+	panic("%s: Failed to allocate %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx\n",
+	      __func__, (u64)size, (u64)align, nid, (u64)from, (u64)max_addr);
+	return NULL;
+}
+
+/**
+ * __memblock_free_early - free boot memory block
+ * @base: phys starting address of the  boot memory block
+ * @size: size of the boot memory block in bytes
+ *
+ * Free boot memory block previously allocated by memblock_virt_alloc_xx() API.
+ * The freeing memory will not be released to the buddy allocator.
+ */
+void __init __memblock_free_early(phys_addr_t base, phys_addr_t size)
+{
+	memblock_dbg("%s: [%#016llx-%#016llx] %pF\n",
+		     __func__, (u64)base, (u64)base + size - 1,
+		     (void *)_RET_IP_);
+	kmemleak_free_part(__va(base), size);
+	__memblock_remove(&memblock.reserved, base, size);
+}
+
+/*
+ * __memblock_free_late - free bootmem block pages directly to buddy allocator
+ * @addr: phys starting address of the  boot memory block
+ * @size: size of the boot memory block in bytes
+ *
+ * This is only useful when the bootmem allocator has already been torn
+ * down, but we are still initializing the system.  Pages are released directly
+ * to the buddy allocator, no bootmem metadata is updated because it is gone.
+ */
+void __init __memblock_free_late(phys_addr_t base, phys_addr_t size)
+{
+	u64 cursor, end;
+
+	memblock_dbg("%s: [%#016llx-%#016llx] %pF\n",
+		     __func__, (u64)base, (u64)base + size - 1,
+		     (void *)_RET_IP_);
+	kmemleak_free_part(__va(base), size);
+	cursor = PFN_UP(base);
+	end = PFN_DOWN(base + size);
+
+	for (; cursor < end; cursor++) {
+		__free_pages_bootmem(pfn_to_page(cursor), 0);
+		totalram_pages++;
+	}
+}
 
 /*
  * Remaining API functions
-- 
1.7.9.5

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

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

* [PATCH 10/24] mm/init: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (8 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 09/24] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 11/24] mm/printk: " Santosh Shilimkar
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu, Andrew Morton

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 init/main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index af310af..1a95ea2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -346,8 +346,8 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  */
 static void __init setup_command_line(char *command_line)
 {
-	saved_command_line = alloc_bootmem(strlen (boot_command_line)+1);
-	static_command_line = alloc_bootmem(strlen (command_line)+1);
+	saved_command_line = memblock_virt_alloc(strlen(boot_command_line)+1);
+	static_command_line = memblock_virt_alloc(strlen(command_line)+1);
 	strcpy (saved_command_line, boot_command_line);
 	strcpy (static_command_line, command_line);
 }
-- 
1.7.9.5

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

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

* [PATCH 11/24] mm/printk: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (9 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 10/24] mm/init: Use memblock apis for early memory allocations Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 12/24] mm/page_alloc: " Santosh Shilimkar
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Grygorii Strashko

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 kernel/printk/printk.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index b4e8500..706295e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -757,14 +757,10 @@ void __init setup_log_buf(int early)
 		return;
 
 	if (early) {
-		unsigned long mem;
-
-		mem = memblock_alloc(new_log_buf_len, PAGE_SIZE);
-		if (!mem)
-			return;
-		new_log_buf = __va(mem);
+		new_log_buf =
+			memblock_virt_alloc_align(new_log_buf_len, PAGE_SIZE);
 	} else {
-		new_log_buf = alloc_bootmem_nopanic(new_log_buf_len);
+		new_log_buf = memblock_virt_alloc_nopanic(new_log_buf_len);
 	}
 
 	if (unlikely(!new_log_buf)) {
-- 
1.7.9.5

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

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

* [PATCH 12/24] mm/page_alloc: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (10 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 11/24] mm/printk: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 13/24] mm/power: " Santosh Shilimkar
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Grygorii Strashko

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/page_alloc.c |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0ee638f..5b9143e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4218,7 +4218,6 @@ static noinline __init_refok
 int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages)
 {
 	int i;
-	struct pglist_data *pgdat = zone->zone_pgdat;
 	size_t alloc_size;
 
 	/*
@@ -4234,7 +4233,8 @@ int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages)
 
 	if (!slab_is_available()) {
 		zone->wait_table = (wait_queue_head_t *)
-			alloc_bootmem_node_nopanic(pgdat, alloc_size);
+			memblock_virt_alloc_node_nopanic(
+				alloc_size, zone->zone_pgdat->node_id);
 	} else {
 		/*
 		 * This case means that a zone whose size was 0 gets new memory
@@ -4354,13 +4354,14 @@ bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
 #endif
 
 /**
- * free_bootmem_with_active_regions - Call free_bootmem_node for each active range
+ * free_bootmem_with_active_regions - Call memblock_free_early_nid for each active range
  * @nid: The node to free memory on. If MAX_NUMNODES, all nodes are freed.
- * @max_low_pfn: The highest PFN that will be passed to free_bootmem_node
+ * @max_low_pfn: The highest PFN that will be passed to memblock_free_early_nid
  *
  * If an architecture guarantees that all ranges registered with
  * add_active_ranges() contain no holes and may be freed, this
- * this function may be used instead of calling free_bootmem() manually.
+ * this function may be used instead of calling memblock_free_early_nid()
+ * manually.
  */
 void __init free_bootmem_with_active_regions(int nid, unsigned long max_low_pfn)
 {
@@ -4372,9 +4373,9 @@ void __init free_bootmem_with_active_regions(int nid, unsigned long max_low_pfn)
 		end_pfn = min(end_pfn, max_low_pfn);
 
 		if (start_pfn < end_pfn)
-			free_bootmem_node(NODE_DATA(this_nid),
-					  PFN_PHYS(start_pfn),
-					  (end_pfn - start_pfn) << PAGE_SHIFT);
+			memblock_free_early_nid(PFN_PHYS(start_pfn),
+					(end_pfn - start_pfn) << PAGE_SHIFT,
+					this_nid);
 	}
 }
 
@@ -4645,8 +4646,9 @@ static void __init setup_usemap(struct pglist_data *pgdat,
 	unsigned long usemapsize = usemap_size(zone_start_pfn, zonesize);
 	zone->pageblock_flags = NULL;
 	if (usemapsize)
-		zone->pageblock_flags = alloc_bootmem_node_nopanic(pgdat,
-								   usemapsize);
+		zone->pageblock_flags =
+			memblock_virt_alloc_node_nopanic(usemapsize,
+							 pgdat->node_id);
 }
 #else
 static inline void setup_usemap(struct pglist_data *pgdat, struct zone *zone,
@@ -4840,7 +4842,8 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)
 		size =  (end - start) * sizeof(struct page);
 		map = alloc_remap(pgdat->node_id, size);
 		if (!map)
-			map = alloc_bootmem_node_nopanic(pgdat, size);
+			map = memblock_virt_alloc_node_nopanic(size,
+							       pgdat->node_id);
 		pgdat->node_mem_map = map + (pgdat->node_start_pfn - start);
 	}
 #ifndef CONFIG_NEED_MULTIPLE_NODES
@@ -5866,7 +5869,7 @@ void *__init alloc_large_system_hash(const char *tablename,
 	do {
 		size = bucketsize << log2qty;
 		if (flags & HASH_EARLY)
-			table = alloc_bootmem_nopanic(size);
+			table = memblock_virt_alloc_nopanic(size);
 		else if (hashdist)
 			table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL);
 		else {
-- 
1.7.9.5

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

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

* [PATCH 13/24] mm/power: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (11 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 12/24] mm/page_alloc: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-09  1:30   ` Rafael J. Wysocki
  2013-11-08 23:41 ` [PATCH 14/24] mm/lib/swiotlb: " Santosh Shilimkar
                   ` (11 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Pavel Machek, Rafael J. Wysocki, linux-pm

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-pm@vger.kernel.org

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 kernel/power/snapshot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 358a146..887134e 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -637,7 +637,7 @@ __register_nosave_region(unsigned long start_pfn, unsigned long end_pfn,
 		BUG_ON(!region);
 	} else
 		/* This allocation cannot fail */
-		region = alloc_bootmem(sizeof(struct nosave_region));
+		region = memblock_virt_alloc(sizeof(struct nosave_region));
 	region->start_pfn = start_pfn;
 	region->end_pfn = end_pfn;
 	list_add_tail(&region->list, &nosave_regions);
-- 
1.7.9.5

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

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

* [PATCH 14/24] mm/lib/swiotlb: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (12 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 13/24] mm/power: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-09 16:55   ` Konrad Rzeszutek Wilk
  2013-11-08 23:41 ` [PATCH 15/24] mm/lib/cpumask: " Santosh Shilimkar
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Konrad Rzeszutek Wilk

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 lib/swiotlb.c |   36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 4e8686c..78ac01a 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -169,8 +169,9 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
 	/*
 	 * Get the overflow emergency buffer
 	 */
-	v_overflow_buffer = alloc_bootmem_low_pages_nopanic(
-						PAGE_ALIGN(io_tlb_overflow));
+	v_overflow_buffer = memblock_virt_alloc_align_nopanic(
+						PAGE_ALIGN(io_tlb_overflow),
+						PAGE_SIZE);
 	if (!v_overflow_buffer)
 		return -ENOMEM;
 
@@ -181,11 +182,15 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
 	 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
 	 * between io_tlb_start and io_tlb_end.
 	 */
-	io_tlb_list = alloc_bootmem_pages(PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
+	io_tlb_list = memblock_virt_alloc_align(
+				PAGE_ALIGN(io_tlb_nslabs * sizeof(int)),
+				PAGE_SIZE);
 	for (i = 0; i < io_tlb_nslabs; i++)
  		io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE);
 	io_tlb_index = 0;
-	io_tlb_orig_addr = alloc_bootmem_pages(PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)));
+	io_tlb_orig_addr = memblock_virt_alloc_align(
+				PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)),
+				PAGE_SIZE);
 
 	if (verbose)
 		swiotlb_print_info();
@@ -212,13 +217,14 @@ swiotlb_init(int verbose)
 	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
 
 	/* Get IO TLB memory from the low pages */
-	vstart = alloc_bootmem_low_pages_nopanic(PAGE_ALIGN(bytes));
+	vstart = memblock_virt_alloc_align_nopanic(PAGE_ALIGN(bytes),
+						   PAGE_SIZE);
 	if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose))
 		return;
 
 	if (io_tlb_start)
-		free_bootmem(io_tlb_start,
-				 PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
+		memblock_free_early(io_tlb_start,
+				    PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
 	pr_warn("Cannot allocate SWIOTLB buffer");
 	no_iotlb_memory = true;
 }
@@ -354,14 +360,14 @@ void __init swiotlb_free(void)
 		free_pages((unsigned long)phys_to_virt(io_tlb_start),
 			   get_order(io_tlb_nslabs << IO_TLB_SHIFT));
 	} else {
-		free_bootmem_late(io_tlb_overflow_buffer,
-				  PAGE_ALIGN(io_tlb_overflow));
-		free_bootmem_late(__pa(io_tlb_orig_addr),
-				  PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)));
-		free_bootmem_late(__pa(io_tlb_list),
-				  PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
-		free_bootmem_late(io_tlb_start,
-				  PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
+		memblock_free_late(io_tlb_overflow_buffer,
+				   PAGE_ALIGN(io_tlb_overflow));
+		memblock_free_late(__pa(io_tlb_orig_addr),
+				   PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)));
+		memblock_free_late(__pa(io_tlb_list),
+				   PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
+		memblock_free_late(io_tlb_start,
+				   PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
 	}
 	io_tlb_nslabs = 0;
 }
-- 
1.7.9.5

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

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

* [PATCH 15/24] mm/lib/cpumask: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (13 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 14/24] mm/lib/swiotlb: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 16/24] mm/sparse: " Santosh Shilimkar
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu, Andrew Morton

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 lib/cpumask.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/cpumask.c b/lib/cpumask.c
index d327b87..44e492e 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -140,7 +140,7 @@ EXPORT_SYMBOL(zalloc_cpumask_var);
  */
 void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask)
 {
-	*mask = alloc_bootmem(cpumask_size());
+	*mask = memblock_virt_alloc(cpumask_size());
 }
 
 /**
@@ -161,6 +161,6 @@ EXPORT_SYMBOL(free_cpumask_var);
  */
 void __init free_bootmem_cpumask_var(cpumask_var_t mask)
 {
-	free_bootmem(__pa(mask), cpumask_size());
+	memblock_free_early(__pa(mask), cpumask_size());
 }
 #endif
-- 
1.7.9.5

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

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

* [PATCH 16/24] mm/sparse: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (14 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 15/24] mm/lib/cpumask: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 17/24] mm/hugetlb: " Santosh Shilimkar
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu, Andrew Morton

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/sparse-vmemmap.c |    6 ++++--
 mm/sparse.c         |   27 +++++++++++++++------------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 27eeab3..4cba9c2 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -40,7 +40,8 @@ static void * __init_refok __earlyonly_bootmem_alloc(int node,
 				unsigned long align,
 				unsigned long goal)
 {
-	return __alloc_bootmem_node_high(NODE_DATA(node), size, align, goal);
+	return memblock_virt_alloc_try_nid(size, align, goal,
+					    BOOTMEM_ALLOC_ACCESSIBLE, node);
 }
 
 static void *vmemmap_buf;
@@ -226,7 +227,8 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
 
 	if (vmemmap_buf_start) {
 		/* need to free left buf */
-		free_bootmem(__pa(vmemmap_buf), vmemmap_buf_end - vmemmap_buf);
+		memblock_free_early(__pa(vmemmap_buf),
+				    vmemmap_buf_end - vmemmap_buf);
 		vmemmap_buf = NULL;
 		vmemmap_buf_end = NULL;
 	}
diff --git a/mm/sparse.c b/mm/sparse.c
index 4ac1d7e..0afcd41 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -69,7 +69,7 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid)
 		else
 			section = kzalloc(array_size, GFP_KERNEL);
 	} else {
-		section = alloc_bootmem_node(NODE_DATA(nid), array_size);
+		section = memblock_virt_alloc_node(array_size, nid);
 	}
 
 	return section;
@@ -279,8 +279,9 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 	limit = goal + (1UL << PA_SECTION_SHIFT);
 	nid = early_pfn_to_nid(goal >> PAGE_SHIFT);
 again:
-	p = ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size,
-					  SMP_CACHE_BYTES, goal, limit);
+	p = memblock_virt_alloc_try_nid_nopanic(size,
+						SMP_CACHE_BYTES, goal, limit,
+						NODE_DATA(nid));
 	if (!p && limit) {
 		limit = 0;
 		goto again;
@@ -331,7 +332,7 @@ static unsigned long * __init
 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 					 unsigned long size)
 {
-	return alloc_bootmem_node_nopanic(pgdat, size);
+	return memblock_virt_alloc_node_nopanic(size, pgdat->node_id);
 }
 
 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
@@ -376,8 +377,9 @@ struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid)
 		return map;
 
 	size = PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION);
-	map = __alloc_bootmem_node_high(NODE_DATA(nid), size,
-					 PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
+	map = memblock_virt_alloc_try_nid(size,
+					  PAGE_SIZE, __pa(MAX_DMA_ADDRESS),
+					  BOOTMEM_ALLOC_ACCESSIBLE, nid);
 	return map;
 }
 void __init sparse_mem_maps_populate_node(struct page **map_map,
@@ -401,8 +403,9 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
 	}
 
 	size = PAGE_ALIGN(size);
-	map = __alloc_bootmem_node_high(NODE_DATA(nodeid), size * map_count,
-					 PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
+	map = memblock_virt_alloc_try_nid(size * map_count,
+					  PAGE_SIZE, __pa(MAX_DMA_ADDRESS),
+					  BOOTMEM_ALLOC_ACCESSIBLE, nodeid);
 	if (map) {
 		for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
 			if (!present_section_nr(pnum))
@@ -545,7 +548,7 @@ void __init sparse_init(void)
 	 * sparse_early_mem_map_alloc, so allocate usemap_map at first.
 	 */
 	size = sizeof(unsigned long *) * NR_MEM_SECTIONS;
-	usemap_map = alloc_bootmem(size);
+	usemap_map = memblock_virt_alloc(size);
 	if (!usemap_map)
 		panic("can not allocate usemap_map\n");
 	alloc_usemap_and_memmap(sparse_early_usemaps_alloc_node,
@@ -553,7 +556,7 @@ void __init sparse_init(void)
 
 #ifdef CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER
 	size2 = sizeof(struct page *) * NR_MEM_SECTIONS;
-	map_map = alloc_bootmem(size2);
+	map_map = memblock_virt_alloc(size2);
 	if (!map_map)
 		panic("can not allocate map_map\n");
 	alloc_usemap_and_memmap(sparse_early_mem_maps_alloc_node,
@@ -583,9 +586,9 @@ void __init sparse_init(void)
 	vmemmap_populate_print_last();
 
 #ifdef CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER
-	free_bootmem(__pa(map_map), size2);
+	memblock_free_early(__pa(map_map), size2);
 #endif
-	free_bootmem(__pa(usemap_map), size);
+	memblock_free_early(__pa(usemap_map), size);
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-- 
1.7.9.5

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

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

* [PATCH 17/24] mm/hugetlb: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (15 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 16/24] mm/sparse: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 18/24] mm/page_cgroup: " Santosh Shilimkar
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/hugetlb.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b49579c..3c9f965 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1282,9 +1282,9 @@ int __weak alloc_bootmem_huge_page(struct hstate *h)
 	for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) {
 		void *addr;
 
-		addr = __alloc_bootmem_node_nopanic(NODE_DATA(node),
-				huge_page_size(h), huge_page_size(h), 0);
-
+		addr = memblock_virt_alloc_try_nid_nopanic(
+				huge_page_size(h), huge_page_size(h),
+				0, BOOTMEM_ALLOC_ACCESSIBLE, node);
 		if (addr) {
 			/*
 			 * Use the beginning of the huge page to store the
@@ -1324,8 +1324,8 @@ static void __init gather_bootmem_prealloc(void)
 
 #ifdef CONFIG_HIGHMEM
 		page = pfn_to_page(m->phys >> PAGE_SHIFT);
-		free_bootmem_late((unsigned long)m,
-				  sizeof(struct huge_bootmem_page));
+		memblock_free_late(__pa(m),
+				   sizeof(struct huge_bootmem_page));
 #else
 		page = virt_to_page(m);
 #endif
-- 
1.7.9.5

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

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

* [PATCH 18/24] mm/page_cgroup: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (16 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 17/24] mm/hugetlb: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 19/24] mm/percpu: " Santosh Shilimkar
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Grygorii Strashko, Yinghai Lu,
	Andrew Morton, Johannes Weiner, Michal Hocko, KAMEZAWA Hiroyuki,
	cgroups, Santosh Shilimkar

From: Grygorii Strashko <grygorii.strashko@ti.com>

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: cgroups@vger.kernel.org

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/page_cgroup.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 6d757e3a..d8bd2c5 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -54,8 +54,9 @@ static int __init alloc_node_page_cgroup(int nid)
 
 	table_size = sizeof(struct page_cgroup) * nr_pages;
 
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
+	base = memblock_virt_alloc_try_nid_nopanic(
+			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS),
+			BOOTMEM_ALLOC_ACCESSIBLE, nid);
 	if (!base)
 		return -ENOMEM;
 	NODE_DATA(nid)->node_page_cgroup = base;
-- 
1.7.9.5

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

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

* [PATCH 19/24] mm/percpu: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (17 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 18/24] mm/page_cgroup: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 20/24] mm/memory_hotplug: " Santosh Shilimkar
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Christoph Lameter

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <cl@linux-foundation.org>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/percpu.c |   41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 8c8e08f..de68457 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1063,7 +1063,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
 			  __alignof__(ai->groups[0].cpu_map[0]));
 	ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]);
 
-	ptr = alloc_bootmem_nopanic(PFN_ALIGN(ai_size));
+	ptr = memblock_virt_alloc_nopanic(PFN_ALIGN(ai_size));
 	if (!ptr)
 		return NULL;
 	ai = ptr;
@@ -1088,7 +1088,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
  */
 void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai)
 {
-	free_bootmem(__pa(ai), ai->__ai_size);
+	memblock_free_early(__pa(ai), ai->__ai_size);
 }
 
 /**
@@ -1246,10 +1246,12 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
 	PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0);
 
 	/* process group information and build config tables accordingly */
-	group_offsets = alloc_bootmem(ai->nr_groups * sizeof(group_offsets[0]));
-	group_sizes = alloc_bootmem(ai->nr_groups * sizeof(group_sizes[0]));
-	unit_map = alloc_bootmem(nr_cpu_ids * sizeof(unit_map[0]));
-	unit_off = alloc_bootmem(nr_cpu_ids * sizeof(unit_off[0]));
+	group_offsets = memblock_virt_alloc(ai->nr_groups *
+					     sizeof(group_offsets[0]));
+	group_sizes = memblock_virt_alloc(ai->nr_groups *
+					   sizeof(group_sizes[0]));
+	unit_map = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_map[0]));
+	unit_off = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_off[0]));
 
 	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
 		unit_map[cpu] = UINT_MAX;
@@ -1311,7 +1313,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
 	 * empty chunks.
 	 */
 	pcpu_nr_slots = __pcpu_size_to_slot(pcpu_unit_size) + 2;
-	pcpu_slot = alloc_bootmem(pcpu_nr_slots * sizeof(pcpu_slot[0]));
+	pcpu_slot = memblock_virt_alloc(pcpu_nr_slots * sizeof(pcpu_slot[0]));
 	for (i = 0; i < pcpu_nr_slots; i++)
 		INIT_LIST_HEAD(&pcpu_slot[i]);
 
@@ -1322,7 +1324,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
 	 * covers static area + reserved area (mostly used for module
 	 * static percpu allocation).
 	 */
-	schunk = alloc_bootmem(pcpu_chunk_struct_size);
+	schunk = memblock_virt_alloc(pcpu_chunk_struct_size);
 	INIT_LIST_HEAD(&schunk->list);
 	schunk->base_addr = base_addr;
 	schunk->map = smap;
@@ -1346,7 +1348,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
 
 	/* init dynamic chunk if necessary */
 	if (dyn_size) {
-		dchunk = alloc_bootmem(pcpu_chunk_struct_size);
+		dchunk = memblock_virt_alloc(pcpu_chunk_struct_size);
 		INIT_LIST_HEAD(&dchunk->list);
 		dchunk->base_addr = base_addr;
 		dchunk->map = dmap;
@@ -1626,7 +1628,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
 	size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
 	areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *));
 
-	areas = alloc_bootmem_nopanic(areas_size);
+	areas = memblock_virt_alloc_nopanic(areas_size);
 	if (!areas) {
 		rc = -ENOMEM;
 		goto out_free;
@@ -1711,7 +1713,7 @@ out_free_areas:
 out_free:
 	pcpu_free_alloc_info(ai);
 	if (areas)
-		free_bootmem(__pa(areas), areas_size);
+		memblock_free_early(__pa(areas), areas_size);
 	return rc;
 }
 #endif /* BUILD_EMBED_FIRST_CHUNK */
@@ -1759,7 +1761,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
 	/* unaligned allocations can't be freed, round up to page size */
 	pages_size = PFN_ALIGN(unit_pages * num_possible_cpus() *
 			       sizeof(pages[0]));
-	pages = alloc_bootmem(pages_size);
+	pages = memblock_virt_alloc(pages_size);
 
 	/* allocate pages */
 	j = 0;
@@ -1822,7 +1824,7 @@ enomem:
 		free_fn(page_address(pages[j]), PAGE_SIZE);
 	rc = -ENOMEM;
 out_free_ar:
-	free_bootmem(__pa(pages), pages_size);
+	memblock_free_early(__pa(pages), pages_size);
 	pcpu_free_alloc_info(ai);
 	return rc;
 }
@@ -1847,12 +1849,15 @@ EXPORT_SYMBOL(__per_cpu_offset);
 static void * __init pcpu_dfl_fc_alloc(unsigned int cpu, size_t size,
 				       size_t align)
 {
-	return __alloc_bootmem_nopanic(size, align, __pa(MAX_DMA_ADDRESS));
+	return  memblock_virt_alloc_try_nid_nopanic(size, align,
+						     __pa(MAX_DMA_ADDRESS),
+						     BOOTMEM_ALLOC_ACCESSIBLE,
+						     MAX_NUMNODES);
 }
 
 static void __init pcpu_dfl_fc_free(void *ptr, size_t size)
 {
-	free_bootmem(__pa(ptr), size);
+	memblock_free_early(__pa(ptr), size);
 }
 
 void __init setup_per_cpu_areas(void)
@@ -1895,7 +1900,11 @@ void __init setup_per_cpu_areas(void)
 	void *fc;
 
 	ai = pcpu_alloc_alloc_info(1, 1);
-	fc = __alloc_bootmem(unit_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
+	fc = memblock_virt_alloc_try_nid_nopanic(unit_size,
+						 PAGE_SIZE,
+						 __pa(MAX_DMA_ADDRESS),
+						 BOOTMEM_ALLOC_ACCESSIBLE,
+						 MAX_NUMNODES);
 	if (!ai || !fc)
 		panic("Failed to allocate memory for percpu areas.");
 	/* kmemleak tracks the percpu allocations separately */
-- 
1.7.9.5

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

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

* [PATCH 20/24] mm/memory_hotplug: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (18 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 19/24] mm/percpu: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 21/24] mm/firmware: " Santosh Shilimkar
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Grygorii Strashko

Correct ensure_zone_is_initialized() function description according
to the introduced memblock APIs for early memory allocations.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 mm/memory_hotplug.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index f7bda5e..3ffe114 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -267,7 +267,7 @@ static void fix_zone_id(struct zone *zone, unsigned long start_pfn,
 }
 
 /* Can fail with -ENOMEM from allocating a wait table with vmalloc() or
- * alloc_bootmem_node_nopanic() */
+ * alloc_bootmem_node_nopanic()/memblock_virt_alloc_node_nopanic() */
 static int __ref ensure_zone_is_initialized(struct zone *zone,
 			unsigned long start_pfn, unsigned long num_pages)
 {
-- 
1.7.9.5

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

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

* [PATCH 21/24] mm/firmware: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (19 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 20/24] mm/memory_hotplug: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 22/24] mm/ARM: kernel: " Santosh Shilimkar
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Grygorii Strashko

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 drivers/firmware/memmap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index e2e04b0..15550b2 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -324,7 +324,7 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type)
 {
 	struct firmware_map_entry *entry;
 
-	entry = alloc_bootmem(sizeof(struct firmware_map_entry));
+	entry = memblock_virt_alloc(sizeof(struct firmware_map_entry));
 	if (WARN_ON(!entry))
 		return -ENOMEM;
 
-- 
1.7.9.5

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

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

* [PATCH 22/24] mm/ARM: kernel: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (20 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 21/24] mm/firmware: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:41 ` [PATCH 23/24] mm/ARM: mm: " Santosh Shilimkar
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu, Andrew Morton

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/kernel/devtree.c |    2 +-
 arch/arm/kernel/setup.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index f35906b..a07892e 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -33,7 +33,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 
 void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
 {
-	return alloc_bootmem_align(size, align);
+	return memblock_virt_alloc_align(size, align);
 }
 
 void __init arm_dt_memblock_reserve(void)
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e1b1394..d25db56 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -707,7 +707,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
 	kernel_data.end     = virt_to_phys(_end - 1);
 
 	for_each_memblock(memory, region) {
-		res = alloc_bootmem_low(sizeof(*res));
+		res = memblock_virt_alloc(sizeof(*res));
 		res->name  = "System RAM";
 		res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
 		res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
-- 
1.7.9.5

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

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

* [PATCH 23/24] mm/ARM: mm: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (21 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 22/24] mm/ARM: kernel: " Santosh Shilimkar
@ 2013-11-08 23:41 ` Santosh Shilimkar
  2013-11-08 23:42 ` [PATCH 24/24] mm/ARM: OMAP: " Santosh Shilimkar
  2013-11-29 16:50 ` [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:41 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu, Andrew Morton

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/mm/init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index cef338d..091e2c9 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -414,7 +414,7 @@ free_memmap(unsigned long start_pfn, unsigned long end_pfn)
 	 * free the section of the memmap array.
 	 */
 	if (pg < pgend)
-		free_bootmem(pg, pgend - pg);
+		memblock_free_early(pg, pgend - pg);
 }
 
 /*
-- 
1.7.9.5

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

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

* [PATCH 24/24] mm/ARM: OMAP: Use memblock apis for early memory allocations
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (22 preceding siblings ...)
  2013-11-08 23:41 ` [PATCH 23/24] mm/ARM: mm: " Santosh Shilimkar
@ 2013-11-08 23:42 ` Santosh Shilimkar
  2013-11-29 16:50 ` [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
  24 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-08 23:42 UTC (permalink / raw)
  To: tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Santosh Shilimkar, Yinghai Lu,
	Andrew Morton, Paul Walmsley, Tony Lindgren

Switch to memblock interfaces for early memory allocator instead of
bootmem allocator. No functional change in beahvior than what it is
in current code from bootmem users points of view.

Archs already converted to NO_BOOTMEM now directly use memblock
interfaces instead of bootmem wrappers build on top of memblock. And the
archs which still uses bootmem, these new apis just fallback to exiting
bootmem APIs.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d9ee0ff..0a3a048 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2676,9 +2676,7 @@ static int __init _alloc_links(struct omap_hwmod_link **ml,
 	sz = sizeof(struct omap_hwmod_link) * LINKS_PER_OCP_IF;
 
 	*sl = NULL;
-	*ml = alloc_bootmem(sz);
-
-	memset(*ml, 0, sz);
+	*ml = memblock_virt_alloc(sz);
 
 	*sl = (void *)(*ml) + sizeof(struct omap_hwmod_link);
 
@@ -2797,9 +2795,7 @@ static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
 	pr_debug("omap_hwmod: %s: allocating %d byte linkspace (%d links)\n",
 		 __func__, sz, max_ls);
 
-	linkspace = alloc_bootmem(sz);
-
-	memset(linkspace, 0, sz);
+	linkspace = memblock_virt_alloc(sz);
 
 	return 0;
 }
-- 
1.7.9.5

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

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

* Re: [PATCH 13/24] mm/power: Use memblock apis for early memory allocations
  2013-11-08 23:41 ` [PATCH 13/24] mm/power: " Santosh Shilimkar
@ 2013-11-09  1:30   ` Rafael J. Wysocki
  2013-11-09 19:08     ` Santosh Shilimkar
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael J. Wysocki @ 2013-11-09  1:30 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu,
	Andrew Morton, Pavel Machek, linux-pm

On Friday, November 08, 2013 06:41:49 PM Santosh Shilimkar wrote:
> Switch to memblock interfaces for early memory allocator instead of
> bootmem allocator. No functional change in beahvior than what it is
> in current code from bootmem users points of view.
> 
> Archs already converted to NO_BOOTMEM now directly use memblock
> interfaces instead of bootmem wrappers build on top of memblock. And the
> archs which still uses bootmem, these new apis just fallback to exiting
> bootmem APIs.
> 
> Cc: Yinghai Lu <yinghai@kernel.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> Cc: linux-pm@vger.kernel.org
> 
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

Fine by me, thanks!

> ---
>  kernel/power/snapshot.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> index 358a146..887134e 100644
> --- a/kernel/power/snapshot.c
> +++ b/kernel/power/snapshot.c
> @@ -637,7 +637,7 @@ __register_nosave_region(unsigned long start_pfn, unsigned long end_pfn,
>  		BUG_ON(!region);
>  	} else
>  		/* This allocation cannot fail */
> -		region = alloc_bootmem(sizeof(struct nosave_region));
> +		region = memblock_virt_alloc(sizeof(struct nosave_region));
>  	region->start_pfn = start_pfn;
>  	region->end_pfn = end_pfn;
>  	list_add_tail(&region->list, &nosave_regions);
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

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

* Re: [PATCH 14/24] mm/lib/swiotlb: Use memblock apis for early memory allocations
  2013-11-08 23:41 ` [PATCH 14/24] mm/lib/swiotlb: " Santosh Shilimkar
@ 2013-11-09 16:55   ` Konrad Rzeszutek Wilk
  2013-11-09 19:07     ` Santosh Shilimkar
  0 siblings, 1 reply; 36+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-11-09 16:55 UTC (permalink / raw)
  To: Santosh Shilimkar, tj, linux-kernel
  Cc: linux-mm, linux-arm-kernel, Yinghai Lu, Andrew Morton

Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:
>Switch to memblock interfaces for early memory allocator instead of
>bootmem allocator. No functional change in beahvior than what it is
>in current code from bootmem users points of view.
>
>Archs already converted to NO_BOOTMEM now directly use memblock
>interfaces instead of bootmem wrappers build on top of memblock. And
>the
>archs which still uses bootmem, these new apis just fallback to exiting
>bootmem APIs.
>
>Cc: Yinghai Lu <yinghai@kernel.org>
>Cc: Tejun Heo <tj@kernel.org>
>Cc: Andrew Morton <akpm@linux-foundation.org>
>Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>
>Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
>---
> lib/swiotlb.c |   36 +++++++++++++++++++++---------------
> 1 file changed, 21 insertions(+), 15 deletions(-)
>
>diff --git a/lib/swiotlb.c b/lib/swiotlb.c
>index 4e8686c..78ac01a 100644
>--- a/lib/swiotlb.c
>+++ b/lib/swiotlb.c
>@@ -169,8 +169,9 @@ int __init swiotlb_init_with_tbl(char *tlb,
>unsigned long nslabs, int verbose)
> 	/*
> 	 * Get the overflow emergency buffer
> 	 */
>-	v_overflow_buffer = alloc_bootmem_low_pages_nopanic(
>-						PAGE_ALIGN(io_tlb_overflow));
>+	v_overflow_buffer = memblock_virt_alloc_align_nopanic(
>+						PAGE_ALIGN(io_tlb_overflow),
>+						PAGE_SIZE);

Does this guarantee that the pages will be allocated below 4GB?

> 	if (!v_overflow_buffer)
> 		return -ENOMEM;
>
>@@ -181,11 +182,15 @@ int __init swiotlb_init_with_tbl(char *tlb,
>unsigned long nslabs, int verbose)
>	 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
> 	 * between io_tlb_start and io_tlb_end.
> 	 */
>-	io_tlb_list = alloc_bootmem_pages(PAGE_ALIGN(io_tlb_nslabs *
>sizeof(int)));
>+	io_tlb_list = memblock_virt_alloc_align(
>+				PAGE_ALIGN(io_tlb_nslabs * sizeof(int)),
>+				PAGE_SIZE);
> 	for (i = 0; i < io_tlb_nslabs; i++)
>  		io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE);
> 	io_tlb_index = 0;
>-	io_tlb_orig_addr = alloc_bootmem_pages(PAGE_ALIGN(io_tlb_nslabs *
>sizeof(phys_addr_t)));
>+	io_tlb_orig_addr = memblock_virt_alloc_align(
>+				PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)),
>+				PAGE_SIZE);
>
> 	if (verbose)
> 		swiotlb_print_info();
>@@ -212,13 +217,14 @@ swiotlb_init(int verbose)
> 	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
>
> 	/* Get IO TLB memory from the low pages */
>-	vstart = alloc_bootmem_low_pages_nopanic(PAGE_ALIGN(bytes));
>+	vstart = memblock_virt_alloc_align_nopanic(PAGE_ALIGN(bytes),
>+						   PAGE_SIZE);

Ditto?
> 	if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose))
> 		return;
>
> 	if (io_tlb_start)
>-		free_bootmem(io_tlb_start,
>-				 PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
>+		memblock_free_early(io_tlb_start,
>+				    PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
> 	pr_warn("Cannot allocate SWIOTLB buffer");
> 	no_iotlb_memory = true;
> }
>@@ -354,14 +360,14 @@ void __init swiotlb_free(void)
> 		free_pages((unsigned long)phys_to_virt(io_tlb_start),
> 			   get_order(io_tlb_nslabs << IO_TLB_SHIFT));
> 	} else {
>-		free_bootmem_late(io_tlb_overflow_buffer,
>-				  PAGE_ALIGN(io_tlb_overflow));
>-		free_bootmem_late(__pa(io_tlb_orig_addr),
>-				  PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)));
>-		free_bootmem_late(__pa(io_tlb_list),
>-				  PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
>-		free_bootmem_late(io_tlb_start,
>-				  PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
>+		memblock_free_late(io_tlb_overflow_buffer,
>+				   PAGE_ALIGN(io_tlb_overflow));
>+		memblock_free_late(__pa(io_tlb_orig_addr),
>+				   PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)));
>+		memblock_free_late(__pa(io_tlb_list),
>+				   PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
>+		memblock_free_late(io_tlb_start,
>+				   PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
> 	}
> 	io_tlb_nslabs = 0;
> }


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

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

* Re: [PATCH 14/24] mm/lib/swiotlb: Use memblock apis for early memory allocations
  2013-11-09 16:55   ` Konrad Rzeszutek Wilk
@ 2013-11-09 19:07     ` Santosh Shilimkar
  0 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-09 19:07 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu, Andrew Morton

On Saturday 09 November 2013 11:55 AM, Konrad Rzeszutek Wilk wrote:
> Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:
>> Switch to memblock interfaces for early memory allocator instead of
>> bootmem allocator. No functional change in beahvior than what it is
>> in current code from bootmem users points of view.
>>
>> Archs already converted to NO_BOOTMEM now directly use memblock
>> interfaces instead of bootmem wrappers build on top of memblock. And
>> the
>> archs which still uses bootmem, these new apis just fallback to exiting
>> bootmem APIs.
>>
>> Cc: Yinghai Lu <yinghai@kernel.org>
>> Cc: Tejun Heo <tj@kernel.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>>
>> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
>> ---
>> lib/swiotlb.c |   36 +++++++++++++++++++++---------------
>> 1 file changed, 21 insertions(+), 15 deletions(-)
>>
>> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
>> index 4e8686c..78ac01a 100644
>> --- a/lib/swiotlb.c
>> +++ b/lib/swiotlb.c
>> @@ -169,8 +169,9 @@ int __init swiotlb_init_with_tbl(char *tlb,
>> unsigned long nslabs, int verbose)
>> 	/*
>> 	 * Get the overflow emergency buffer
>> 	 */
>> -	v_overflow_buffer = alloc_bootmem_low_pages_nopanic(
>> -						PAGE_ALIGN(io_tlb_overflow));
>> +	v_overflow_buffer = memblock_virt_alloc_align_nopanic(
>> +						PAGE_ALIGN(io_tlb_overflow),
>> +						PAGE_SIZE);
> 
> Does this guarantee that the pages will be allocated below 4GB?
> 
Yes. The memblock layer still allocates memory from lowmem. As I
mentioned, there is no change in the behavior than what is today
apart from just the interface change.

Regards,
Santosh

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

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

* Re: [PATCH 13/24] mm/power: Use memblock apis for early memory allocations
  2013-11-09  1:30   ` Rafael J. Wysocki
@ 2013-11-09 19:08     ` Santosh Shilimkar
  0 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-09 19:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu,
	Andrew Morton, Pavel Machek, linux-pm

On Friday 08 November 2013 08:30 PM, Rafael J. Wysocki wrote:
> On Friday, November 08, 2013 06:41:49 PM Santosh Shilimkar wrote:
>> Switch to memblock interfaces for early memory allocator instead of
>> bootmem allocator. No functional change in beahvior than what it is
>> in current code from bootmem users points of view.
>>
>> Archs already converted to NO_BOOTMEM now directly use memblock
>> interfaces instead of bootmem wrappers build on top of memblock. And the
>> archs which still uses bootmem, these new apis just fallback to exiting
>> bootmem APIs.
>>
>> Cc: Yinghai Lu <yinghai@kernel.org>
>> Cc: Tejun Heo <tj@kernel.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Pavel Machek <pavel@ucw.cz>
>> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
>> Cc: linux-pm@vger.kernel.org
>>
>> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> 
> Fine by me, thanks!
> 
Thanks Rafael. I take that as an ack.

Regards,
Santosh

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

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

* Re: [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h
  2013-11-08 23:41 ` [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h Santosh Shilimkar
@ 2013-11-13  2:09   ` Jens Axboe
  2013-11-13 23:10     ` Santosh Shilimkar
  0 siblings, 1 reply; 36+ messages in thread
From: Jens Axboe @ 2013-11-13  2:09 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Grygorii Strashko,
	Yinghai Lu, Andrew Morton

On Fri, Nov 08 2013, Santosh Shilimkar wrote:
> From: Grygorii Strashko <grygorii.strashko@ti.com>
> 
> Clean-up to remove depedency with bootmem headers.

Thanks, cleaned up for after merge window inclusion. Changed the wording
to make it more correct and fixed the spelling error:

block: cleanup removing dependency on bootmem headers

-- 
Jens Axboe

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

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

* Re: [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h
  2013-11-13  2:09   ` Jens Axboe
@ 2013-11-13 23:10     ` Santosh Shilimkar
  0 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-13 23:10 UTC (permalink / raw)
  To: Jens Axboe
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Grygorii Strashko,
	Yinghai Lu, Andrew Morton

On Tuesday 12 November 2013 09:09 PM, Jens Axboe wrote:
> On Fri, Nov 08 2013, Santosh Shilimkar wrote:
>> From: Grygorii Strashko <grygorii.strashko@ti.com>
>>
>> Clean-up to remove depedency with bootmem headers.
> 
> Thanks, cleaned up for after merge window inclusion. Changed the wording
> to make it more correct and fixed the spelling error:
> 
> block: cleanup removing dependency on bootmem headers
> 
Thanks !!

regards,
Santosh

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

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

* Re: [PATCH 00/24] mm: Use memblock interface instead of bootmem
  2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
                   ` (23 preceding siblings ...)
  2013-11-08 23:42 ` [PATCH 24/24] mm/ARM: OMAP: " Santosh Shilimkar
@ 2013-11-29 16:50 ` Santosh Shilimkar
  2013-12-03  0:32   ` Andrew Morton
  24 siblings, 1 reply; 36+ messages in thread
From: Santosh Shilimkar @ 2013-11-29 16:50 UTC (permalink / raw)
  To: tj, Andrew Morton
  Cc: Santosh Shilimkar, linux-kernel, linux-mm, linux-arm-kernel,
	Yinghai Lu, H. Peter Anvin, Russell King, Arnd Bergmann,
	Nicolas Pitre, Olof Johansson

Tejun, Andrew,

On Friday 08 November 2013 06:41 PM, Santosh Shilimkar wrote:
> Tejun and others,
> 
> Following up with the earlier RFC [1] comments, here is the updated
> patch series based on the discussion. This series is the last bottleneck
> now for me to enable the coherency on keystone ARM LPAE architecture on which
> the physical memory starts after 4BG. I would like to get these patches
> in next merge window(3.14), so any help in terms of testing/comments is
> appreciated.
> 
Now since the 3.13-rc1 is out, it will be best to apply these patches 
on memblock tree so that they start appearing in next to catch any
regressions, issues etc. It will give us some time to fix any issues
arises from next.

For convenience, I have re-based the series on top of 3.13-rc1 and
pushed it on below tree.

git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone.git
for_3.14/memblock

web-url:
https://git.kernel.org/cgit/linux/kernel/git/ssantosh/linux-keystone.git/log/?h=for_3.14/memblock

Can you please pull these in you tree and apply against your
next branch ?

Regards,
Santosh		 



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

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

* Re: [PATCH 09/24] mm/memblock: Add memblock memory allocation apis
  2013-11-08 23:41 ` [PATCH 09/24] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
@ 2013-12-03  0:31   ` Andrew Morton
  2013-12-03  0:48     ` Santosh Shilimkar
  0 siblings, 1 reply; 36+ messages in thread
From: Andrew Morton @ 2013-12-03  0:31 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu,
	Grygorii Strashko

On Fri, 8 Nov 2013 18:41:45 -0500 Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:

> Introduce memblock memory allocation APIs which allow to support
> PAE or LPAE extension on 32 bits archs where the physical memory start
> address can be beyond 4GB. In such cases, existing bootmem APIs which
> operate on 32 bit addresses won't work and needs memblock layer which
> operates on 64 bit addresses.
> 
> So we add equivalent APIs so that we can replace usage of bootmem
> with memblock interfaces. Architectures already converted to NO_BOOTMEM
> use these new interfaces and other which still uses bootmem, these new
> APIs just fallback to exiting bootmem APIs. So no functional change as
> such.
> 
> In long run, once all the achitectures moves to NO_BOOTMEM, we can get rid of
> bootmem layer completely. This is one step to remove the core code dependency
> with bootmem and also gives path for architectures to move away from bootmem.
> 
> The proposed interface will became active if both CONFIG_HAVE_MEMBLOCK
> and CONFIG_NO_BOOTMEM are specified by arch. In case !CONFIG_NO_BOOTMEM,
> the memblock() wrappers will fallback to the existing bootmem apis so
> that arch's not converted to NO_BOOTMEM continue to work as is.
> 
> The meaning of MEMBLOCK_ALLOC_ACCESSIBLE and MEMBLOCK_ALLOC_ANYWHERE is
> kept same.
> 
> ...
>
> +static void * __init _memblock_virt_alloc_try_nid_nopanic(
> +				phys_addr_t size, phys_addr_t align,
> +				phys_addr_t from, phys_addr_t max_addr,
> +				int nid)
> +{
> +	phys_addr_t alloc;
> +	void *ptr;
> +
> +	if (WARN_ON_ONCE(slab_is_available())) {
> +		if (nid == MAX_NUMNODES)
> +			return kzalloc(size, GFP_NOWAIT);
> +		else
> +			return kzalloc_node(size, GFP_NOWAIT, nid);
> +	}

The use of MAX_NUMNODES is a bit unconventional here.  I *think* we
generally use NUMA_NO_NODE to indicate "don't care".  I Also *think*
that if this code did s/MAX_NUMNODES/NUMA_NO_NODE/g then the above
simply becomes

	return kzalloc_node(size, GFP_NOWAIT, nid);

and kzalloc_node() handles NUMA_NO_NODE appropriately.

I *think* ;)  Please check all this.


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

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

* Re: [PATCH 00/24] mm: Use memblock interface instead of bootmem
  2013-11-29 16:50 ` [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
@ 2013-12-03  0:32   ` Andrew Morton
  2013-12-03  0:40     ` Santosh Shilimkar
  0 siblings, 1 reply; 36+ messages in thread
From: Andrew Morton @ 2013-12-03  0:32 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu,
	H. Peter Anvin, Russell King, Arnd Bergmann, Nicolas Pitre,
	Olof Johansson

On Fri, 29 Nov 2013 11:50:10 -0500 Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:

> Tejun, Andrew,
> 
> On Friday 08 November 2013 06:41 PM, Santosh Shilimkar wrote:
> > Tejun and others,
> > 
> > Following up with the earlier RFC [1] comments, here is the updated
> > patch series based on the discussion. This series is the last bottleneck
> > now for me to enable the coherency on keystone ARM LPAE architecture on which
> > the physical memory starts after 4BG. I would like to get these patches
> > in next merge window(3.14), so any help in terms of testing/comments is
> > appreciated.
> > 
> Now since the 3.13-rc1 is out, it will be best to apply these patches 
> on memblock tree so that they start appearing in next to catch any
> regressions, issues etc. It will give us some time to fix any issues
> arises from next.
> 
> For convenience, I have re-based the series on top of 3.13-rc1 and
> pushed it on below tree.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone.git
> for_3.14/memblock
> 
> web-url:
> https://git.kernel.org/cgit/linux/kernel/git/ssantosh/linux-keystone.git/log/?h=for_3.14/memblock
> 
> Can you please pull these in you tree and apply against your
> next branch ?

It would cause me much joy if yinghai were able to find time to review
all this.  The patches are a bit old now, so perhaps a resend will help.

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

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

* Re: [PATCH 00/24] mm: Use memblock interface instead of bootmem
  2013-12-03  0:32   ` Andrew Morton
@ 2013-12-03  0:40     ` Santosh Shilimkar
  0 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-12-03  0:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu,
	H. Peter Anvin, Russell King, Arnd Bergmann, Nicolas Pitre,
	Olof Johansson

On Monday 02 December 2013 07:32 PM, Andrew Morton wrote:
> On Fri, 29 Nov 2013 11:50:10 -0500 Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:
> 
>> Tejun, Andrew,
>>
>> On Friday 08 November 2013 06:41 PM, Santosh Shilimkar wrote:
>>> Tejun and others,
>>>
>>> Following up with the earlier RFC [1] comments, here is the updated
>>> patch series based on the discussion. This series is the last bottleneck
>>> now for me to enable the coherency on keystone ARM LPAE architecture on which
>>> the physical memory starts after 4BG. I would like to get these patches
>>> in next merge window(3.14), so any help in terms of testing/comments is
>>> appreciated.
>>>
>> Now since the 3.13-rc1 is out, it will be best to apply these patches 
>> on memblock tree so that they start appearing in next to catch any
>> regressions, issues etc. It will give us some time to fix any issues
>> arises from next.
>>
>> For convenience, I have re-based the series on top of 3.13-rc1 and
>> pushed it on below tree.
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone.git
>> for_3.14/memblock
>>
>> web-url:
>> https://git.kernel.org/cgit/linux/kernel/git/ssantosh/linux-keystone.git/log/?h=for_3.14/memblock
>>
>> Can you please pull these in you tree and apply against your
>> next branch ?
> 
> It would cause me much joy if yinghai were able to find time to review
> all this.  The patches are a bit old now, so perhaps a resend will help.
> 
OK. I will re-send the patchset.

Regards,
Santosh

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

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

* Re: [PATCH 09/24] mm/memblock: Add memblock memory allocation apis
  2013-12-03  0:31   ` Andrew Morton
@ 2013-12-03  0:48     ` Santosh Shilimkar
  0 siblings, 0 replies; 36+ messages in thread
From: Santosh Shilimkar @ 2013-12-03  0:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: tj, linux-kernel, linux-mm, linux-arm-kernel, Yinghai Lu,
	Grygorii Strashko

On Monday 02 December 2013 07:31 PM, Andrew Morton wrote:
> On Fri, 8 Nov 2013 18:41:45 -0500 Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:
> 
>> Introduce memblock memory allocation APIs which allow to support
>> PAE or LPAE extension on 32 bits archs where the physical memory start
>> address can be beyond 4GB. In such cases, existing bootmem APIs which
>> operate on 32 bit addresses won't work and needs memblock layer which
>> operates on 64 bit addresses.
>>
>> So we add equivalent APIs so that we can replace usage of bootmem
>> with memblock interfaces. Architectures already converted to NO_BOOTMEM
>> use these new interfaces and other which still uses bootmem, these new
>> APIs just fallback to exiting bootmem APIs. So no functional change as
>> such.
>>
>> In long run, once all the achitectures moves to NO_BOOTMEM, we can get rid of
>> bootmem layer completely. This is one step to remove the core code dependency
>> with bootmem and also gives path for architectures to move away from bootmem.
>>
>> The proposed interface will became active if both CONFIG_HAVE_MEMBLOCK
>> and CONFIG_NO_BOOTMEM are specified by arch. In case !CONFIG_NO_BOOTMEM,
>> the memblock() wrappers will fallback to the existing bootmem apis so
>> that arch's not converted to NO_BOOTMEM continue to work as is.
>>
>> The meaning of MEMBLOCK_ALLOC_ACCESSIBLE and MEMBLOCK_ALLOC_ANYWHERE is
>> kept same.
>>
>> ...
>>
>> +static void * __init _memblock_virt_alloc_try_nid_nopanic(
>> +				phys_addr_t size, phys_addr_t align,
>> +				phys_addr_t from, phys_addr_t max_addr,
>> +				int nid)
>> +{
>> +	phys_addr_t alloc;
>> +	void *ptr;
>> +
>> +	if (WARN_ON_ONCE(slab_is_available())) {
>> +		if (nid == MAX_NUMNODES)
>> +			return kzalloc(size, GFP_NOWAIT);
>> +		else
>> +			return kzalloc_node(size, GFP_NOWAIT, nid);
>> +	}
> 
> The use of MAX_NUMNODES is a bit unconventional here.  I *think* we
> generally use NUMA_NO_NODE to indicate "don't care".  I Also *think*
> that if this code did s/MAX_NUMNODES/NUMA_NO_NODE/g then the above
> simply becomes
> 
> 	return kzalloc_node(size, GFP_NOWAIT, nid);
> 
> and kzalloc_node() handles NUMA_NO_NODE appropriately.
> 
> I *think* ;)  Please check all this.
> 
I guess same comment was given by Tejun as well. We didn't
address that in this series mainly because when NO_BOOTMEM
are not enabled, all calls of the new APIs will
be redirected to bootmem  where MAX_NUMNODES is used.

Also, memblock core APIs __next_free_mem_range_rev() and
__next_free_mem_range() would need to be updated, and as result
we will need to re-check/update all direct calls of
memblock_alloc_xxx() APIs (including nobootmem).

So to keep behavior consistent with and without NO_BOOTMEM, we
used MAX_NUMNODES. Once we get a stage where we can remove
the bootmem.c, it should be easy to update the code
to use NUMA_NO_NODE without too much churn.

Regards,
Santosh

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

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

end of thread, other threads:[~2013-12-03  0:48 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-08 23:41 [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 01/24] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 02/24] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 03/24] mm/bootmem: remove duplicated declaration of __free_pages_bootmem() Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 04/24] mm/block: remove unnecessary inclusion of bootmem.h Santosh Shilimkar
2013-11-13  2:09   ` Jens Axboe
2013-11-13 23:10     ` Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 05/24] mm/memory_hotplug: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 06/24] mm/staging: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 07/24] mm/char: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 08/24] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 09/24] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
2013-12-03  0:31   ` Andrew Morton
2013-12-03  0:48     ` Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 10/24] mm/init: Use memblock apis for early memory allocations Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 11/24] mm/printk: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 12/24] mm/page_alloc: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 13/24] mm/power: " Santosh Shilimkar
2013-11-09  1:30   ` Rafael J. Wysocki
2013-11-09 19:08     ` Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 14/24] mm/lib/swiotlb: " Santosh Shilimkar
2013-11-09 16:55   ` Konrad Rzeszutek Wilk
2013-11-09 19:07     ` Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 15/24] mm/lib/cpumask: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 16/24] mm/sparse: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 17/24] mm/hugetlb: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 18/24] mm/page_cgroup: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 19/24] mm/percpu: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 20/24] mm/memory_hotplug: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 21/24] mm/firmware: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 22/24] mm/ARM: kernel: " Santosh Shilimkar
2013-11-08 23:41 ` [PATCH 23/24] mm/ARM: mm: " Santosh Shilimkar
2013-11-08 23:42 ` [PATCH 24/24] mm/ARM: OMAP: " Santosh Shilimkar
2013-11-29 16:50 ` [PATCH 00/24] mm: Use memblock interface instead of bootmem Santosh Shilimkar
2013-12-03  0:32   ` Andrew Morton
2013-12-03  0:40     ` Santosh Shilimkar

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