* [PATCH v3 01/23] mm/memblock: debug: correct displaying of upper memory boundary
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:56 ` Felipe Balbi
2013-12-09 21:50 ` [PATCH v3 02/23] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK Santosh Shilimkar
` (21 subsequent siblings)
22 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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>
Cc: Tejun Heo <tj@kernel.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 53e477b..aab5669 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -643,7 +643,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);
@@ -655,7 +655,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 01/23] mm/memblock: debug: correct displaying of upper memory boundary
2013-12-09 21:50 ` [PATCH v3 01/23] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
@ 2013-12-09 21:56 ` Felipe Balbi
2013-12-09 22:39 ` Santosh Shilimkar
0 siblings, 1 reply; 40+ messages in thread
From: Felipe Balbi @ 2013-12-09 21:56 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Dec 09, 2013 at 04:50:34PM -0500, Santosh Shilimkar wrote:
> 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>
> Cc: Tejun Heo <tj@kernel.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>
Very minor patch but perhaps we should Cc: stable here ? not that it
matters much...
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131209/b729d3dc/attachment.sig>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 01/23] mm/memblock: debug: correct displaying of upper memory boundary
2013-12-09 21:56 ` Felipe Balbi
@ 2013-12-09 22:39 ` Santosh Shilimkar
0 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 22:39 UTC (permalink / raw)
To: linux-arm-kernel
On Monday 09 December 2013 04:56 PM, Felipe Balbi wrote:
> On Mon, Dec 09, 2013 at 04:50:34PM -0500, Santosh Shilimkar wrote:
>> 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>
>> Cc: Tejun Heo <tj@kernel.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>
>
> Very minor patch but perhaps we should Cc: stable here ? not that it
> matters much...
>
Yeah... No major fix as such from stable perspective.
regards,
Santosh
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 02/23] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 01/23] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-10 0:11 ` Andrew Morton
2013-12-09 21:50 ` [PATCH v3 03/23] mm/bootmem: remove duplicated declaration of __free_pages_bootmem() Santosh Shilimkar
` (20 subsequent siblings)
22 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>
Reviewed-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 | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mm/memblock.c b/mm/memblock.c
index aab5669..39855d4 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -265,6 +265,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 02/23] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK
2013-12-09 21:50 ` [PATCH v3 02/23] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK Santosh Shilimkar
@ 2013-12-10 0:11 ` Andrew Morton
2013-12-10 16:44 ` Grygorii Strashko
0 siblings, 1 reply; 40+ messages in thread
From: Andrew Morton @ 2013-12-10 0:11 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 9 Dec 2013 16:50:35 -0500 Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:
> 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).
Alternatives:
- disable /proc/sys/kernel/debug/memblock/reserved in this case
- disable defined(CONFIG_DEBUG_FS) &&
!defined(CONFIG_ARCH_DISCARD_MEMBLOCK) in Kconfig.
How much memory are we talking about here? If it's more than "very
little" then I think either of these would be better - most users will
value the extra memory over an accurate
/proc/sys/kernel/debug/memblock/reserved?
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 02/23] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK
2013-12-10 0:11 ` Andrew Morton
@ 2013-12-10 16:44 ` Grygorii Strashko
0 siblings, 0 replies; 40+ messages in thread
From: Grygorii Strashko @ 2013-12-10 16:44 UTC (permalink / raw)
To: linux-arm-kernel
Hi Andrew,
On 12/10/2013 02:11 AM, Andrew Morton wrote:
> On Mon, 9 Dec 2013 16:50:35 -0500 Santosh Shilimkar <santosh.shilimkar@ti.com> wrote:
>
>> 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).
>
> Alternatives:
>
> - disable /proc/sys/kernel/debug/memblock/reserved in this case
>
> - disable defined(CONFIG_DEBUG_FS) &&
> !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) in Kconfig.
Yes. But this is debug information and it's useful to have it.
>
> How much memory are we talking about here? If it's more than "very
> little" then I think either of these would be better - most users will
> value the extra memory over an accurate
> /proc/sys/kernel/debug/memblock/reserved?
>
Sorry, I have no real statistic information and I hit this issue while testing this series
by simulating huge amount of bootmem allocation during kernel boot.
The real number of entries i saw on Keystone & OMAP boards is no more than ~20.
Few digits below:
- size of static reserved memory regions array is 2048 bytes
- the size of array is doubled during each allocation
Regards,
-grygorii
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 03/23] mm/bootmem: remove duplicated declaration of __free_pages_bootmem()
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 01/23] mm/memblock: debug: correct displaying of upper memory boundary Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 02/23] mm/memblock: debug: don't free reserved array if !ARCH_DISCARD_MEMBLOCK Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 04/23] mm/memblock: remove unnecessary inclusions of bootmem.h Santosh Shilimkar
` (19 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Tejun Heo <tj@kernel.org>
Cc: Tejun Heo <tj@kernel.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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 04/23] mm/memblock: remove unnecessary inclusions of bootmem.h
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (2 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 03/23] mm/bootmem: remove duplicated declaration of __free_pages_bootmem() Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 05/23] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment Santosh Shilimkar
` (18 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
From: Grygorii Strashko <grygorii.strashko@ti.com>
Clean-up to remove depedency with bootmem headers.
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tejun Heo <tj@kernel.org>
Reviewed-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/char/mem.c | 1 -
mm/memory_hotplug.c | 1 -
2 files changed, 2 deletions(-)
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>
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 489f235..cf1736d 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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 05/23] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (3 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 04/23] mm/memblock: remove unnecessary inclusions of bootmem.h Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-13 21:21 ` Tejun Heo
2013-12-09 21:50 ` [PATCH v3 06/23] mm/memblock: reorder parameters of memblock_find_in_range_node Santosh Shilimkar
` (17 subsequent siblings)
22 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
From: Grygorii Strashko <grygorii.strashko@ti.com>
Don't produce warning and interpret 0 as "default align" equal to
SMP_CACHE_BYTES in case if caller of memblock_alloc_base_nid() doesn't
specify alignment for the block (align == 0).
This is done in preparation of introducing common memblock alloc
interface to make code behavior consistent. More details are
in below thread :
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>
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 39855d4..784958d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -883,8 +883,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 06/23] mm/memblock: reorder parameters of memblock_find_in_range_node
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (4 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 05/23] mm/memblock: drop WARN and use SMP_CACHE_BYTES as a default alignment Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-13 21:22 ` Tejun Heo
2013-12-09 21:50 ` [PATCH v3 07/23] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES Santosh Shilimkar
` (16 subsequent siblings)
22 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
From: Grygorii Strashko <grygorii.strashko@ti.com>
Reorder parameters of memblock_find_in_range_node to be consistent
with other memblock APIs.
The change was suggested by Tejun Heo <tj@kernel.org>.
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/memblock.h | 5 +++--
mm/memblock.c | 16 ++++++++--------
mm/nobootmem.c | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 77c60e5..dca4533 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -47,8 +47,9 @@ extern int memblock_debug;
#define memblock_dbg(fmt, ...) \
if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end,
- phys_addr_t size, phys_addr_t align, int nid);
+phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
+ phys_addr_t start, phys_addr_t end,
+ int nid);
phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
phys_addr_t size, phys_addr_t align);
phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
diff --git a/mm/memblock.c b/mm/memblock.c
index 784958d..8786503 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -154,10 +154,10 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,
/**
* memblock_find_in_range_node - find free area in given range and node
- * @start: start of candidate range
- * @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE}
* @size: size of free area to find
* @align: alignment of free area to find
+ * @start: start of candidate range
+ * @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE}
* @nid: nid of the free area to find, %MAX_NUMNODES for any node
*
* Find @size free area aligned to @align in the specified range and node.
@@ -173,9 +173,9 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,
* RETURNS:
* Found address on success, 0 on failure.
*/
-phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start,
- phys_addr_t end, phys_addr_t size,
- phys_addr_t align, int nid)
+phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,
+ phys_addr_t align, phys_addr_t start,
+ phys_addr_t end, int nid)
{
int ret;
phys_addr_t kernel_end;
@@ -238,8 +238,8 @@ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start,
phys_addr_t end, phys_addr_t size,
phys_addr_t align)
{
- return memblock_find_in_range_node(start, end, size, align,
- MAX_NUMNODES);
+ return memblock_find_in_range_node(size, align, start, end,
+ MAX_NUMNODES);
}
static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
@@ -889,7 +889,7 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size,
/* align @size to avoid excessive fragmentation on reserved array */
size = round_up(size, align);
- found = memblock_find_in_range_node(0, max_addr, size, align, nid);
+ found = memblock_find_in_range_node(size, align, 0, max_addr, nid);
if (found && !memblock_reserve(found, size))
return found;
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 2c254d3..59777e0 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -41,7 +41,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
if (limit > memblock.current_limit)
limit = memblock.current_limit;
- addr = memblock_find_in_range_node(goal, limit, size, align, nid);
+ addr = memblock_find_in_range_node(size, align, goal, limit, nid);
if (!addr)
return NULL;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 07/23] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (5 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 06/23] mm/memblock: reorder parameters of memblock_find_in_range_node Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-13 21:29 ` Tejun Heo
2013-12-09 21:50 ` [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
` (15 subsequent siblings)
22 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
From: Grygorii Strashko <grygorii.strashko@ti.com>
It's recommended to use NUMA_NO_NODE everywhere to select
"process any node" behavior or to indicate that "no node id specified".
Hence, update __next_free_mem_range*() API's to accept both NUMA_NO_NODE
and MAX_NUMNODES, but emit warning once on MAX_NUMNODES, and correct
corresponding API's documentation to describe new behavior.
Also, update other memblock/nobootmem APIs where MAX_NUMNODES is used
dirrectly.
The change was suggested by Tejun Heo <tj@kernel.org>.
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/memblock.h | 4 ++--
mm/memblock.c | 28 +++++++++++++++++++---------
mm/nobootmem.c | 8 ++++----
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index dca4533..8607429 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -88,7 +88,7 @@ void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start,
/**
* for_each_free_mem_range - iterate through free memblock areas
* @i: u64 used as loop variable
- * @nid: node selector, %MAX_NUMNODES for all nodes
+ * @nid: node selector, %NUMA_NO_NODE for all nodes
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
@@ -108,7 +108,7 @@ void __next_free_mem_range_rev(u64 *idx, int nid, phys_addr_t *out_start,
/**
* for_each_free_mem_range_reverse - rev-iterate through free memblock areas
* @i: u64 used as loop variable
- * @nid: node selector, %MAX_NUMNODES for all nodes
+ * @nid: node selector, %NUMA_NO_NODE for all nodes
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
diff --git a/mm/memblock.c b/mm/memblock.c
index 8786503..900057b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -91,7 +91,7 @@ static long __init_memblock memblock_overlaps_region(struct memblock_type *type,
* @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE}
* @size: size of free area to find
* @align: alignment of free area to find
- * @nid: nid of the free area to find, %MAX_NUMNODES for any node
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
*
* Utility called from memblock_find_in_range_node(), find free area bottom-up.
*
@@ -123,7 +123,7 @@ __memblock_find_range_bottom_up(phys_addr_t start, phys_addr_t end,
* @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE}
* @size: size of free area to find
* @align: alignment of free area to find
- * @nid: nid of the free area to find, %MAX_NUMNODES for any node
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
*
* Utility called from memblock_find_in_range_node(), find free area top-down.
*
@@ -158,7 +158,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,
* @align: alignment of free area to find
* @start: start of candidate range
* @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE}
- * @nid: nid of the free area to find, %MAX_NUMNODES for any node
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
*
* Find @size free area aligned to @align in the specified range and node.
*
@@ -239,7 +239,7 @@ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start,
phys_addr_t align)
{
return memblock_find_in_range_node(size, align, start, end,
- MAX_NUMNODES);
+ NUMA_NO_NODE);
}
static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
@@ -677,7 +677,7 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
/**
* __next_free_mem_range - next function for for_each_free_mem_range()
* @idx: pointer to u64 loop variable
- * @nid: node selector, %MAX_NUMNODES for all nodes
+ * @nid: node selector, %NUMA_NO_NODE for all nodes
* @out_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @out_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @out_nid: ptr to int for nid of the range, can be %NULL
@@ -705,6 +705,11 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
struct memblock_type *rsv = &memblock.reserved;
int mi = *idx & 0xffffffff;
int ri = *idx >> 32;
+ bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
+
+ if (nid == MAX_NUMNODES)
+ pr_warn_once("%s: Usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE instead\n",
+ __func__);
for ( ; mi < mem->cnt; mi++) {
struct memblock_region *m = &mem->regions[mi];
@@ -712,7 +717,7 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
phys_addr_t m_end = m->base + m->size;
/* only memory regions are associated with nodes, check it */
- if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m))
+ if (check_node && nid != memblock_get_region_node(m))
continue;
/* scan areas before each reservation for intersection */
@@ -753,7 +758,7 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
/**
* __next_free_mem_range_rev - next function for for_each_free_mem_range_reverse()
* @idx: pointer to u64 loop variable
- * @nid: nid: node selector, %MAX_NUMNODES for all nodes
+ * @nid: nid: node selector, %NUMA_NO_NODE for all nodes
* @out_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @out_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @out_nid: ptr to int for nid of the range, can be %NULL
@@ -768,6 +773,11 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
struct memblock_type *rsv = &memblock.reserved;
int mi = *idx & 0xffffffff;
int ri = *idx >> 32;
+ bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
+
+ if (nid == MAX_NUMNODES)
+ pr_warn_once("%s: Usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE instead\n",
+ __func__);
if (*idx == (u64)ULLONG_MAX) {
mi = mem->cnt - 1;
@@ -780,7 +790,7 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
phys_addr_t m_end = m->base + m->size;
/* only memory regions are associated with nodes, check it */
- if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m))
+ if (check_node && nid != memblock_get_region_node(m))
continue;
/* scan areas before each reservation for intersection */
@@ -903,7 +913,7 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n
phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
{
- return memblock_alloc_base_nid(size, align, max_addr, MAX_NUMNODES);
+ return memblock_alloc_base_nid(size, align, max_addr, NUMA_NO_NODE);
}
phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 59777e0..19121ce 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -117,7 +117,7 @@ static unsigned long __init free_low_memory_core_early(void)
phys_addr_t start, end, size;
u64 i;
- for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL)
+ for_each_free_mem_range(i, NUMA_NO_NODE, &start, &end, NULL)
count += __free_memory_core(start, end);
/* free range that is used for reserved array if we allocate it */
@@ -161,7 +161,7 @@ unsigned long __init free_all_bootmem(void)
reset_all_zones_managed_pages();
/*
- * We need to use MAX_NUMNODES instead of NODE_DATA(0)->node_id
+ * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id
* because in some case like Node0 doesn't have RAM installed
* low ram will be on Node1
*/
@@ -215,7 +215,7 @@ static void * __init ___alloc_bootmem_nopanic(unsigned long size,
restart:
- ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align, goal, limit);
+ ptr = __alloc_memory_core_early(NUMA_NO_NODE, size, align, goal, limit);
if (ptr)
return ptr;
@@ -299,7 +299,7 @@ again:
if (ptr)
return ptr;
- ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+ ptr = __alloc_memory_core_early(NUMA_NO_NODE, size, align,
goal, limit);
if (ptr)
return ptr;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 07/23] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES
2013-12-09 21:50 ` [PATCH v3 07/23] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES Santosh Shilimkar
@ 2013-12-13 21:29 ` Tejun Heo
2013-12-14 0:44 ` Santosh Shilimkar
0 siblings, 1 reply; 40+ messages in thread
From: Tejun Heo @ 2013-12-13 21:29 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Dec 09, 2013 at 04:50:40PM -0500, Santosh Shilimkar wrote:
> + if (nid == MAX_NUMNODES)
> + pr_warn_once("%s: Usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE instead\n",
> + __func__);
Why not just use WARN_ONCE()? We'd want to know who the caller is
anyway. Also, wouldn't something like the following simpler?
if (WARN_ONCE(nid == MAX_NUMNODES, blah blah))
nid = NUMA_NO_NODE;
> @@ -768,6 +773,11 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
> struct memblock_type *rsv = &memblock.reserved;
> int mi = *idx & 0xffffffff;
> int ri = *idx >> 32;
> + bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
> +
> + if (nid == MAX_NUMNODES)
> + pr_warn_once("%s: Usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE instead\n",
> + __func__);
Ditto.
Provided the patch is tested on an actual NUMA setup.
Reviwed-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 07/23] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES
2013-12-13 21:29 ` Tejun Heo
@ 2013-12-14 0:44 ` Santosh Shilimkar
0 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-14 0:44 UTC (permalink / raw)
To: linux-arm-kernel
On Friday 13 December 2013 04:29 PM, Tejun Heo wrote:
> On Mon, Dec 09, 2013 at 04:50:40PM -0500, Santosh Shilimkar wrote:
>> + if (nid == MAX_NUMNODES)
>> + pr_warn_once("%s: Usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE instead\n",
>> + __func__);
>
> Why not just use WARN_ONCE()? We'd want to know who the caller is
> anyway. Also, wouldn't something like the following simpler?
>
> if (WARN_ONCE(nid == MAX_NUMNODES, blah blah))
> nid = NUMA_NO_NODE;
>
Agree.
>> @@ -768,6 +773,11 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
>> struct memblock_type *rsv = &memblock.reserved;
>> int mi = *idx & 0xffffffff;
>> int ri = *idx >> 32;
>> + bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
>> +
>> + if (nid == MAX_NUMNODES)
>> + pr_warn_once("%s: Usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE instead\n",
>> + __func__);
>
> Ditto.
>
OK.
>
> Reviwed-by: Tejun Heo <tj@kernel.org>
>
Thanks
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (6 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 07/23] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-10 0:25 ` Andrew Morton
2013-12-13 21:37 ` Tejun Heo
2013-12-09 21:50 ` [PATCH v3 09/23] mm/init: Use memblock apis for early memory allocations Santosh Shilimkar
` (14 subsequent siblings)
22 siblings, 2 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 memblock interfaces. The architectures
which are still not converted to NO_BOOTMEM continue to function
as is because we still maintain the fal lback option of bootmem
back-end supporting these new interfaces. So no functional change
as such.
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.
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 | 151 ++++++++++++++++++++++++++++++++++++
mm/memblock.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 349 insertions(+)
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 55d52fb..1c9aa0e 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -141,6 +141,157 @@ 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: 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 min_addr,
+ phys_addr_t max_addr, int nid);
+void *memblock_virt_alloc_try_nid(phys_addr_t size, phys_addr_t align,
+ phys_addr_t min_addr, 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);
+
+static inline void * __init memblock_virt_alloc(
+ phys_addr_t size, phys_addr_t align)
+{
+ return memblock_virt_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT,
+ BOOTMEM_ALLOC_ACCESSIBLE,
+ NUMA_NO_NODE);
+}
+
+static inline void * __init memblock_virt_alloc_nopanic(
+ phys_addr_t size, phys_addr_t align)
+{
+ return memblock_virt_alloc_try_nid_nopanic(size, align,
+ BOOTMEM_LOW_LIMIT,
+ BOOTMEM_ALLOC_ACCESSIBLE,
+ NUMA_NO_NODE);
+}
+
+static inline void * __init memblock_virt_alloc_from_nopanic(
+ phys_addr_t size, phys_addr_t align, phys_addr_t min_addr)
+{
+ return memblock_virt_alloc_try_nid_nopanic(size, align, min_addr,
+ BOOTMEM_ALLOC_ACCESSIBLE,
+ NUMA_NO_NODE);
+}
+
+static inline void * __init memblock_virt_alloc_node(
+ phys_addr_t size, int nid)
+{
+ return memblock_virt_alloc_try_nid(size, 0, BOOTMEM_LOW_LIMIT,
+ BOOTMEM_ALLOC_ACCESSIBLE, nid);
+}
+
+static inline void * __init memblock_virt_alloc_node_nopanic(
+ phys_addr_t size, int nid)
+{
+ return memblock_virt_alloc_try_nid_nopanic(size, 0, BOOTMEM_LOW_LIMIT,
+ BOOTMEM_ALLOC_ACCESSIBLE,
+ nid);
+}
+
+static inline void __init memblock_free_early(
+ phys_addr_t base, phys_addr_t size)
+{
+ __memblock_free_early(base, size);
+}
+
+static inline void __init memblock_free_early_nid(
+ phys_addr_t base, phys_addr_t size, int nid)
+{
+ __memblock_free_early(base, size);
+}
+
+static inline void __init memblock_free_late(
+ phys_addr_t base, phys_addr_t size)
+{
+ __memblock_free_late(base, size);
+}
+
+#else
+
+#define BOOTMEM_ALLOC_ACCESSIBLE 0
+
+
+/* Fall back to all the existing bootmem APIs */
+static inline void * __init memblock_virt_alloc(
+ phys_addr_t size, phys_addr_t align)
+{
+ if (!align)
+ align = SMP_CACHE_BYTES;
+ return __alloc_bootmem(size, align, BOOTMEM_LOW_LIMIT);
+}
+
+static inline void * __init memblock_virt_alloc_nopanic(
+ phys_addr_t size, phys_addr_t align)
+{
+ if (!align)
+ align = SMP_CACHE_BYTES;
+ return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT);
+}
+
+static inline void * __init memblock_virt_alloc_from_nopanic(
+ phys_addr_t size, phys_addr_t align, phys_addr_t min_addr)
+{
+ return __alloc_bootmem_nopanic(size, align, min_addr);
+}
+
+static inline void * __init memblock_virt_alloc_node(
+ phys_addr_t size, int nid)
+{
+ return __alloc_bootmem_node(NODE_DATA(nid), size, SMP_CACHE_BYTES,
+ BOOTMEM_LOW_LIMIT);
+}
+
+static inline void * __init memblock_virt_alloc_node_nopanic(
+ phys_addr_t size, int nid)
+{
+ return __alloc_bootmem_node_nopanic(NODE_DATA(nid), size,
+ SMP_CACHE_BYTES,
+ BOOTMEM_LOW_LIMIT);
+}
+
+static inline void * __init memblock_virt_alloc_try_nid(phys_addr_t size,
+ phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid)
+{
+ return __alloc_bootmem_node_high(NODE_DATA(nid), size, align,
+ min_addr);
+}
+
+static inline void * __init memblock_virt_alloc_try_nid_nopanic(
+ phys_addr_t size, phys_addr_t align,
+ phys_addr_t min_addr, phys_addr_t max_addr, int nid)
+{
+ return ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align,
+ min_addr, max_addr);
+}
+
+static inline void __init memblock_free_early(
+ phys_addr_t base, phys_addr_t size)
+{
+ free_bootmem(base, size);
+}
+
+static inline void __init memblock_free_early_nid(
+ phys_addr_t base, phys_addr_t size, int nid)
+{
+ free_bootmem_node(NODE_DATA(nid), base, size);
+}
+
+static inline void __init memblock_free_late(
+ phys_addr_t base, phys_addr_t size)
+{
+ free_bootmem_late(base, size);
+}
+#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 900057b..d03d50a 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -21,6 +21,9 @@
#include <linux/memblock.h>
#include <asm-generic/sections.h>
+#include <linux/io.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;
@@ -943,6 +946,201 @@ 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_internal - allocate boot memory block
+ * @size: size of memory block to be allocated in bytes
+ * @align: alignment of the region and block's size
+ * @min_addr: the lower bound of the memory region to allocate (phys address)
+ * @max_addr: the upper bound of the memory region to allocate (phys address)
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
+ *
+ * The @min_addr limit is dropped if it can not be satisfied and the allocation
+ * will fall back to memory below @min_addr. Also, allocation may fall back
+ * to any node in the system if the specified node can not
+ * hold the requested memory.
+ *
+ * The allocation is performed from memory region limited by
+ * memblock.current_limit if @max_addr == %BOOTMEM_ALLOC_ACCESSIBLE.
+ *
+ * The memory block is aligned on SMP_CACHE_BYTES if @align == 0.
+ *
+ * The phys address of allocated boot memory block is converted to virtual and
+ * allocated memory is reset to 0.
+ *
+ * In addition, function sets the min_count to 0 using kmemleak_alloc for
+ * allocated boot memory block, 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_internal(
+ phys_addr_t size, phys_addr_t align,
+ phys_addr_t min_addr, phys_addr_t max_addr,
+ int nid)
+{
+ phys_addr_t alloc;
+ void *ptr;
+
+ if (nid == MAX_NUMNODES)
+ pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
+ __func__);
+
+ if (WARN_ON_ONCE(slab_is_available()))
+ 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(size, align, min_addr, max_addr,
+ nid);
+ if (alloc)
+ goto done;
+
+ if (nid != NUMA_NO_NODE) {
+ alloc = memblock_find_in_range_node(size, align, min_addr,
+ max_addr, NUMA_NO_NODE);
+ if (alloc)
+ goto done;
+ }
+
+ if (min_addr) {
+ min_addr = 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
+ * @min_addr: 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, %NUMA_NO_NODE 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 min_addr, 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)min_addr,
+ (u64)max_addr, (void *)_RET_IP_);
+ return memblock_virt_alloc_internal(size, align, min_addr,
+ 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
+ * @min_addr: 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, %NUMA_NO_NODE 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 min_addr, 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)min_addr,
+ (u64)max_addr, (void *)_RET_IP_);
+ ptr = memblock_virt_alloc_internal(size, align,
+ min_addr, 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)min_addr,
+ (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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-09 21:50 ` [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
@ 2013-12-10 0:25 ` Andrew Morton
2013-12-10 16:04 ` Santosh Shilimkar
2013-12-13 21:37 ` Tejun Heo
1 sibling, 1 reply; 40+ messages in thread
From: Andrew Morton @ 2013-12-10 0:25 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 9 Dec 2013 16:50:41 -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 memblock interfaces. The architectures
> which are still not converted to NO_BOOTMEM continue to function
> as is because we still maintain the fal lback option of bootmem
> back-end supporting these new interfaces. So no functional change
> as such.
>
> 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.
>
> 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 inline void * __init memblock_virt_alloc(
> + phys_addr_t size, phys_addr_t align)
> +{
> + return memblock_virt_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT,
> + BOOTMEM_ALLOC_ACCESSIBLE,
> + NUMA_NO_NODE);
> +}
erk. I prefer
static inline void * __init
memblock_virt_alloc(phys_addr_t size, phys_addr_t align);
to this. But not enough to bother changing it ;)
> +/**
> + * memblock_virt_alloc_internal - allocate boot memory block
> + * @size: size of memory block to be allocated in bytes
> + * @align: alignment of the region and block's size
> + * @min_addr: the lower bound of the memory region to allocate (phys address)
> + * @max_addr: the upper bound of the memory region to allocate (phys address)
> + * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
> + *
> + * The @min_addr limit is dropped if it can not be satisfied and the allocation
> + * will fall back to memory below @min_addr. Also, allocation may fall back
> + * to any node in the system if the specified node can not
> + * hold the requested memory.
> + *
> + * The allocation is performed from memory region limited by
> + * memblock.current_limit if @max_addr == %BOOTMEM_ALLOC_ACCESSIBLE.
> + *
> + * The memory block is aligned on SMP_CACHE_BYTES if @align == 0.
> + *
> + * The phys address of allocated boot memory block is converted to virtual and
> + * allocated memory is reset to 0.
> + *
> + * In addition, function sets the min_count to 0 using kmemleak_alloc for
> + * allocated boot memory block, 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_internal(
> + phys_addr_t size, phys_addr_t align,
> + phys_addr_t min_addr, phys_addr_t max_addr,
> + int nid)
> +{
> + phys_addr_t alloc;
> + void *ptr;
> +
> + if (nid == MAX_NUMNODES)
> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
> + __func__);
"deprecated". I'll fix this (three places).
> + if (WARN_ON_ONCE(slab_is_available()))
> + return kzalloc_node(size, GFP_NOWAIT, nid);
I don't know why this generates a warning. And I bet that if it
generates a warning for some other developer, they won't know either.
Please send a patch to add a suitable code comment here.
> +
> + /*
> + * The min_count is set to 0 so that bootmem allocated blocks
> + * are never reported as leaks.
> + */
> + kmemleak_alloc(ptr, size, 0, 0);
This is not a good comment - it explains "what" (which is fairly
obvious) but it doesn't explain "why". Unfreed bootmem can surely be
considered a leak in some situations so perhaps some people will want
them reported as such. Please send a patch which updates this comment,
fully explaining the reasoning behind this decision.
> + 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
> + * @min_addr: 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, %NUMA_NO_NODE 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 min_addr, 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)min_addr,
> + (u64)max_addr, (void *)_RET_IP_);
Maybe we should teach vsprintf() how to print phys_addr_t's. Similar
to
http://ozlabs.org/~akpm/mmots/broken-out/vsprintf-add-%25pad-extension-for-dma_addr_t-use.patch
Printing a single level of the call stack is often pretty useless.
Have you been using memblock_dbg() and have you found this _RET_IP_
information to be sufficient?
> + return memblock_virt_alloc_internal(size, align, min_addr,
> + max_addr, nid);
> +}
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-10 0:25 ` Andrew Morton
@ 2013-12-10 16:04 ` Santosh Shilimkar
0 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-10 16:04 UTC (permalink / raw)
To: linux-arm-kernel
Andrew,
On Monday 09 December 2013 07:25 PM, Andrew Morton wrote:
> On Mon, 9 Dec 2013 16:50:41 -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 memblock interfaces. The architectures
>> which are still not converted to NO_BOOTMEM continue to function
>> as is because we still maintain the fal lback option of bootmem
>> back-end supporting these new interfaces. So no functional change
>> as such.
>>
>> 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.
>>
>> 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.
>>
[..]
>> +/**
>> + * memblock_virt_alloc_internal - allocate boot memory block
>> + * @size: size of memory block to be allocated in bytes
>> + * @align: alignment of the region and block's size
>> + * @min_addr: the lower bound of the memory region to allocate (phys address)
>> + * @max_addr: the upper bound of the memory region to allocate (phys address)
>> + * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
>> + *
>> + * The @min_addr limit is dropped if it can not be satisfied and the allocation
>> + * will fall back to memory below @min_addr. Also, allocation may fall back
>> + * to any node in the system if the specified node can not
>> + * hold the requested memory.
>> + *
>> + * The allocation is performed from memory region limited by
>> + * memblock.current_limit if @max_addr == %BOOTMEM_ALLOC_ACCESSIBLE.
>> + *
>> + * The memory block is aligned on SMP_CACHE_BYTES if @align == 0.
>> + *
>> + * The phys address of allocated boot memory block is converted to virtual and
>> + * allocated memory is reset to 0.
>> + *
>> + * In addition, function sets the min_count to 0 using kmemleak_alloc for
>> + * allocated boot memory block, 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_internal(
>> + phys_addr_t size, phys_addr_t align,
>> + phys_addr_t min_addr, phys_addr_t max_addr,
>> + int nid)
>> +{
>> + phys_addr_t alloc;
>> + void *ptr;
>> +
>> + if (nid == MAX_NUMNODES)
>> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
>> + __func__);
>
> "deprecated". I'll fix this (three places).
>
Thanks for fixup.
>> + if (WARN_ON_ONCE(slab_is_available()))
>> + return kzalloc_node(size, GFP_NOWAIT, nid);
>
> I don't know why this generates a warning. And I bet that if it
> generates a warning for some other developer, they won't know either.
> Please send a patch to add a suitable code comment here.
>
Ok. This check was actually present in nobootmem memblock wrappers
so we just kept that here as well.
(see mm/__nobootmem.c: _alloc_bootmem_nopanic()).
Seems like a check is detect any accidental use of these APIs
after slab is ready.
>> +
>> + /*
>> + * The min_count is set to 0 so that bootmem allocated blocks
>> + * are never reported as leaks.
>> + */
>> + kmemleak_alloc(ptr, size, 0, 0);
>
> This is not a good comment - it explains "what" (which is fairly
> obvious) but it doesn't explain "why". Unfreed bootmem can surely be
> considered a leak in some situations so perhaps some people will want
> them reported as such. Please send a patch which updates this comment,
> fully explaining the reasoning behind this decision.
>
Same here. (see __alloc_memory_core_early() and alloc_bootmem_bdata()).
looks like it was introduced by commit 008139d9 {kmemleak: Do not report
alloc_bootmem blocks as leaks}.
Looping Catalin who committed this change. From the commit log the
reason seems to be bootmem allocated blocks are only referred via
the physical address which is not looked up by kmemleak.
>> + 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
>> + * @min_addr: 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, %NUMA_NO_NODE 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 min_addr, 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)min_addr,
>> + (u64)max_addr, (void *)_RET_IP_);
>
> Maybe we should teach vsprintf() how to print phys_addr_t's. Similar
> to
> http://ozlabs.org/~akpm/mmots/broken-out/vsprintf-add-%25pad-extension-for-dma_addr_t-use.patch
>
Thanks. We can update it using %pa format specifier in another patch.
> Printing a single level of the call stack is often pretty useless.
> Have you been using memblock_dbg() and have you found this _RET_IP_
> information to be sufficient?
>
Yes. It is - the current API structure allow to see the caller name
properly (at least on ARM)
e.g
memblock_virt_alloc_try_nid_nopanic: 4096 bytes align=0x0 nid=1
from=0x0 max_addr=0x0 pcpu_alloc_alloc_info+0x5c/0xa4
Regards,
Santosh
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-09 21:50 ` [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
2013-12-10 0:25 ` Andrew Morton
@ 2013-12-13 21:37 ` Tejun Heo
2013-12-14 0:52 ` Santosh Shilimkar
1 sibling, 1 reply; 40+ messages in thread
From: Tejun Heo @ 2013-12-13 21:37 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Dec 09, 2013 at 04:50:41PM -0500, Santosh Shilimkar 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.
The overall API looks good to me. Thanks for doing this!
> +static void * __init memblock_virt_alloc_internal(
> + phys_addr_t size, phys_addr_t align,
> + phys_addr_t min_addr, phys_addr_t max_addr,
> + int nid)
> +{
> + phys_addr_t alloc;
> + void *ptr;
> +
> + if (nid == MAX_NUMNODES)
> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
> + __func__);
Why not use WARN_ONCE()? Also, shouldn't nid be set to NUMA_NO_NODE
here?
...
> + if (nid != NUMA_NO_NODE) {
Otherwise, the above test is broken.
> + alloc = memblock_find_in_range_node(size, align, min_addr,
> + max_addr, NUMA_NO_NODE);
> + if (alloc)
> + goto done;
> + }
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-13 21:37 ` Tejun Heo
@ 2013-12-14 0:52 ` Santosh Shilimkar
2013-12-14 11:08 ` Tejun Heo
0 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-14 0:52 UTC (permalink / raw)
To: linux-arm-kernel
On Friday 13 December 2013 04:37 PM, Tejun Heo wrote:
> On Mon, Dec 09, 2013 at 04:50:41PM -0500, Santosh Shilimkar 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.
>
> The overall API looks good to me. Thanks for doing this!
>
>> +static void * __init memblock_virt_alloc_internal(
>> + phys_addr_t size, phys_addr_t align,
>> + phys_addr_t min_addr, phys_addr_t max_addr,
>> + int nid)
>> +{
>> + phys_addr_t alloc;
>> + void *ptr;
>> +
>> + if (nid == MAX_NUMNODES)
>> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
>> + __func__);
>
> Why not use WARN_ONCE()? Also, shouldn't nid be set to NUMA_NO_NODE
> here?
>
You want all the users using MAX_NUMNODES to know about it so that
the wrong usage can be fixed. WARN_ONCE will hide that.
> ...
>> + if (nid != NUMA_NO_NODE) {
>
> Otherwise, the above test is broken.
>
So the idea was just to warn the users and allow them to fix
the code. Well we are just allowing the existing users of using
either MAX_NUMNODES or NUMA_NO_NODE continue to work. Thats what
we discussed, right ?
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-14 0:52 ` Santosh Shilimkar
@ 2013-12-14 11:08 ` Tejun Heo
2013-12-14 19:48 ` Santosh Shilimkar
0 siblings, 1 reply; 40+ messages in thread
From: Tejun Heo @ 2013-12-14 11:08 UTC (permalink / raw)
To: linux-arm-kernel
Hello, Santosh.
On Fri, Dec 13, 2013 at 07:52:42PM -0500, Santosh Shilimkar wrote:
> >> +static void * __init memblock_virt_alloc_internal(
> >> + phys_addr_t size, phys_addr_t align,
> >> + phys_addr_t min_addr, phys_addr_t max_addr,
> >> + int nid)
> >> +{
> >> + phys_addr_t alloc;
> >> + void *ptr;
> >> +
> >> + if (nid == MAX_NUMNODES)
> >> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
> >> + __func__);
> >
> > Why not use WARN_ONCE()? Also, shouldn't nid be set to NUMA_NO_NODE
> > here?
> >
> You want all the users using MAX_NUMNODES to know about it so that
> the wrong usage can be fixed. WARN_ONCE will hide that.
Well, it doesn't really help anyone to be printing multiple messages
without any info on who was the caller and if this thing is gonna be
in mainline triggering of the warning should be rare anyway. It's
more of a tool to gather one-off cases in the wild. WARN_ONCE()
usually is the better choice as otherwise the warnings can swamp the
machine and console output in certain cases.
> > ...
> >> + if (nid != NUMA_NO_NODE) {
> >
> > Otherwise, the above test is broken.
> >
> So the idea was just to warn the users and allow them to fix
> the code. Well we are just allowing the existing users of using
> either MAX_NUMNODES or NUMA_NO_NODE continue to work. Thats what
> we discussed, right ?
Huh? Yeah, sure. You're testing @nid against MAX_NUMNODES at the
beginning of the function. If it's MAX_NUMNODES, you print a warning
but nothing else, so the if() conditional above, which should succeed,
would fail. Am I missing sth here?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-14 11:08 ` Tejun Heo
@ 2013-12-14 19:48 ` Santosh Shilimkar
2013-12-20 22:30 ` Santosh Shilimkar
0 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-14 19:48 UTC (permalink / raw)
To: linux-arm-kernel
On Saturday 14 December 2013 06:08 AM, Tejun Heo wrote:
> Hello, Santosh.
>
> On Fri, Dec 13, 2013 at 07:52:42PM -0500, Santosh Shilimkar wrote:
>>>> +static void * __init memblock_virt_alloc_internal(
>>>> + phys_addr_t size, phys_addr_t align,
>>>> + phys_addr_t min_addr, phys_addr_t max_addr,
>>>> + int nid)
>>>> +{
>>>> + phys_addr_t alloc;
>>>> + void *ptr;
>>>> +
>>>> + if (nid == MAX_NUMNODES)
>>>> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
>>>> + __func__);
>>>
>>> Why not use WARN_ONCE()? Also, shouldn't nid be set to NUMA_NO_NODE
>>> here?
>>>
>> You want all the users using MAX_NUMNODES to know about it so that
>> the wrong usage can be fixed. WARN_ONCE will hide that.
>
> Well, it doesn't really help anyone to be printing multiple messages
> without any info on who was the caller and if this thing is gonna be
> in mainline triggering of the warning should be rare anyway. It's
> more of a tool to gather one-off cases in the wild. WARN_ONCE()
> usually is the better choice as otherwise the warnings can swamp the
> machine and console output in certain cases.
>
Fair enough.
>>> ...
>>>> + if (nid != NUMA_NO_NODE) {
>>>
>>> Otherwise, the above test is broken.
>>>
>> So the idea was just to warn the users and allow them to fix
>> the code. Well we are just allowing the existing users of using
>> either MAX_NUMNODES or NUMA_NO_NODE continue to work. Thats what
>> we discussed, right ?
>
> Huh? Yeah, sure. You're testing @nid against MAX_NUMNODES at the
> beginning of the function. If it's MAX_NUMNODES, you print a warning
> but nothing else, so the if() conditional above, which should succeed,
> would fail. Am I missing sth here?
>
I get it now. Sorry I missed your point in first part. We will fix this.
Regards,
Santosh
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis
2013-12-14 19:48 ` Santosh Shilimkar
@ 2013-12-20 22:30 ` Santosh Shilimkar
0 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-20 22:30 UTC (permalink / raw)
To: linux-arm-kernel
On Saturday 14 December 2013 02:48 PM, Santosh Shilimkar wrote:
> On Saturday 14 December 2013 06:08 AM, Tejun Heo wrote:
>> Hello, Santosh.
>>
>> On Fri, Dec 13, 2013 at 07:52:42PM -0500, Santosh Shilimkar wrote:
>>>>> +static void * __init memblock_virt_alloc_internal(
>>>>> + phys_addr_t size, phys_addr_t align,
>>>>> + phys_addr_t min_addr, phys_addr_t max_addr,
>>>>> + int nid)
>>>>> +{
>>>>> + phys_addr_t alloc;
>>>>> + void *ptr;
>>>>> +
>>>>> + if (nid == MAX_NUMNODES)
>>>>> + pr_warn("%s: usage of MAX_NUMNODES is depricated. Use NUMA_NO_NODE\n",
>>>>> + __func__);
>>>>
>>>> Why not use WARN_ONCE()? Also, shouldn't nid be set to NUMA_NO_NODE
>>>> here?
>>>>
>>> You want all the users using MAX_NUMNODES to know about it so that
>>> the wrong usage can be fixed. WARN_ONCE will hide that.
>>
>> Well, it doesn't really help anyone to be printing multiple messages
>> without any info on who was the caller and if this thing is gonna be
>> in mainline triggering of the warning should be rare anyway. It's
>> more of a tool to gather one-off cases in the wild. WARN_ONCE()
>> usually is the better choice as otherwise the warnings can swamp the
>> machine and console output in certain cases.
>>
> Fair enough.
>
>>>> ...
>>>>> + if (nid != NUMA_NO_NODE) {
>>>>
>>>> Otherwise, the above test is broken.
>>>>
>>> So the idea was just to warn the users and allow them to fix
>>> the code. Well we are just allowing the existing users of using
>>> either MAX_NUMNODES or NUMA_NO_NODE continue to work. Thats what
>>> we discussed, right ?
>>
>> Huh? Yeah, sure. You're testing @nid against MAX_NUMNODES at the
>> beginning of the function. If it's MAX_NUMNODES, you print a warning
>> but nothing else, so the if() conditional above, which should succeed,
>> would fail. Am I missing sth here?
>>
> I get it now. Sorry I missed your point in first part. We will fix this.
>
Posted an incremental fix based on above discussion. You have been
copied on the patch.
Regards,
Santosh
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 09/23] mm/init: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (7 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 08/23] mm/memblock: Add memblock memory allocation apis Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 10/23] mm/printk: " Santosh Shilimkar
` (13 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 fall
back 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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/init/main.c b/init/main.c
index febc511..d3e3cff 100644
--- a/init/main.c
+++ b/init/main.c
@@ -355,9 +355,11 @@ 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);
- initcall_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, 0);
+ initcall_command_line =
+ memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
+ static_command_line = memblock_virt_alloc(strlen(command_line) + 1, 0);
strcpy (saved_command_line, boot_command_line);
strcpy (static_command_line, command_line);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 10/23] mm/printk: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (8 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 09/23] mm/init: Use memblock apis for early memory allocations Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 11/23] mm/page_alloc: " Santosh Shilimkar
` (12 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 be7c86b..f8b41bd 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(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, 0);
}
if (unlikely(!new_log_buf)) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 11/23] mm/page_alloc: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (9 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 10/23] mm/printk: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 12/23] mm/power: " Santosh Shilimkar
` (11 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 580a5f0..ed64107 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4210,7 +4210,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;
/*
@@ -4226,7 +4225,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
@@ -4346,13 +4346,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)
{
@@ -4364,9 +4365,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);
}
}
@@ -4637,8 +4638,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,
@@ -4832,7 +4834,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
@@ -5858,7 +5861,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, 0);
else if (hashdist)
table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL);
else {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 12/23] mm/power: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (10 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 11/23] mm/page_alloc: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 13/23] mm/lib/swiotlb: " Santosh Shilimkar
` (10 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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>
Acked-by: "Rafael J. Wysocki" <rjw@sisk.pl>
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 b38109e..d9f61a1 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), 0);
region->start_pfn = start_pfn;
region->end_pfn = end_pfn;
list_add_tail(®ion->list, &nosave_regions);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 13/23] mm/lib/swiotlb: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (11 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 12/23] mm/power: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
[not found] ` <20131212170857.e36d016a95992c932da824b0@linux-foundation.org>
2013-12-09 21:50 ` [PATCH v3 14/23] mm/lib/cpumask: " Santosh Shilimkar
` (9 subsequent siblings)
22 siblings, 1 reply; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index e4399fa..615f3de 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -172,8 +172,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_nopanic(
+ PAGE_ALIGN(io_tlb_overflow),
+ PAGE_SIZE);
if (!v_overflow_buffer)
return -ENOMEM;
@@ -184,11 +185,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(
+ 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(
+ PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)),
+ PAGE_SIZE);
if (verbose)
swiotlb_print_info();
@@ -215,13 +220,13 @@ 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_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;
}
@@ -357,14 +362,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 14/23] mm/lib/cpumask: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (12 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 13/23] mm/lib/swiotlb: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 15/23] mm/sparse: " Santosh Shilimkar
` (8 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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..b810b75 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(), 0);
}
/**
@@ -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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 15/23] mm/sparse: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (13 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 14/23] mm/lib/cpumask: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 16/23] mm/hugetlb: " Santosh Shilimkar
` (7 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 8cc7be0..63c3ea5 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,
+ 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@first.
*/
size = sizeof(unsigned long *) * NR_MEM_SECTIONS;
- usemap_map = alloc_bootmem(size);
+ usemap_map = memblock_virt_alloc(size, 0);
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, 0);
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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 16/23] mm/hugetlb: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (14 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 15/23] mm/sparse: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 17/23] mm/page_cgroup: " Santosh Shilimkar
` (6 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 dee6cf4..e16c56e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1280,9 +1280,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
@@ -1322,8 +1322,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 17/23] mm/page_cgroup: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (15 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 16/23] mm/hugetlb: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 18/23] mm/percpu: " Santosh Shilimkar
` (5 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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>
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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 18/23] mm/percpu: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (16 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 17/23] mm/page_cgroup: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 19/23] mm/memory_hotplug: " Santosh Shilimkar
` (4 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index 0d10def..65fd8a7 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), 0);
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]), 0);
+ group_sizes = memblock_virt_alloc(ai->nr_groups *
+ sizeof(group_sizes[0]), 0);
+ unit_map = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_map[0]), 0);
+ unit_off = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_off[0]), 0);
for (cpu = 0; cpu < nr_cpu_ids; cpu++)
unit_map[cpu] = UINT_MAX;
@@ -1311,7 +1313,8 @@ 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]), 0);
for (i = 0; i < pcpu_nr_slots; i++)
INIT_LIST_HEAD(&pcpu_slot[i]);
@@ -1322,7 +1325,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, 0);
INIT_LIST_HEAD(&schunk->list);
schunk->base_addr = base_addr;
schunk->map = smap;
@@ -1346,7 +1349,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, 0);
INIT_LIST_HEAD(&dchunk->list);
dchunk->base_addr = base_addr;
dchunk->map = dmap;
@@ -1626,7 +1629,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, 0);
if (!areas) {
rc = -ENOMEM;
goto out_free;
@@ -1712,7 +1715,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 */
@@ -1760,7 +1763,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, 0);
/* allocate pages */
j = 0;
@@ -1823,7 +1826,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;
}
@@ -1848,12 +1851,13 @@ 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_from_nopanic(
+ size, align, __pa(MAX_DMA_ADDRESS));
}
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)
@@ -1896,7 +1900,9 @@ 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_from_nopanic(unit_size,
+ PAGE_SIZE,
+ __pa(MAX_DMA_ADDRESS));
if (!ai || !fc)
panic("Failed to allocate memory for percpu areas.");
/* kmemleak tracks the percpu allocations separately */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 19/23] mm/memory_hotplug: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (17 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 18/23] mm/percpu: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 20/23] mm/firmware: " Santosh Shilimkar
` (3 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 cf1736d..4f158ec 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -268,7 +268,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 20/23] mm/firmware: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (18 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 19/23] mm/memory_hotplug: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 21/23] mm/ARM: kernel: " Santosh Shilimkar
` (2 subsequent siblings)
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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..17cf96c 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), 0);
if (WARN_ON(!entry))
return -ENOMEM;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 21/23] mm/ARM: kernel: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (19 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 20/23] mm/firmware: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 22/23] mm/ARM: mm: " Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 23/23] mm/ARM: OMAP: " Santosh Shilimkar
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 739c3df..5a0041e 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(size, align);
}
void __init arm_dt_memblock_reserve(void)
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 6a1b8a8..fffb978 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -717,7 +717,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), 0);
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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 22/23] mm/ARM: mm: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (20 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 21/23] mm/ARM: kernel: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
2013-12-09 21:50 ` [PATCH v3 23/23] mm/ARM: OMAP: " Santosh Shilimkar
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 3e8f106..bee6d2c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -461,7 +461,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
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v3 23/23] mm/ARM: OMAP: Use memblock apis for early memory allocations
2013-12-09 21:50 [PATCH v3 00/23] mm: Use memblock interface instead of bootmem Santosh Shilimkar
` (21 preceding siblings ...)
2013-12-09 21:50 ` [PATCH v3 22/23] mm/ARM: mm: " Santosh Shilimkar
@ 2013-12-09 21:50 ` Santosh Shilimkar
22 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2013-12-09 21:50 UTC (permalink / raw)
To: linux-arm-kernel
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 e3f0eca..f03f8b8 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2695,9 +2695,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, 0);
*sl = (void *)(*ml) + sizeof(struct omap_hwmod_link);
@@ -2816,9 +2814,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, 0);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 40+ messages in thread