* [PATCH v4, part3 13/41] mm/ARM: prepare for removing num_physpages and simplify mem_init()
[not found] <1365258760-30821-1-git-send-email-jiang.liu@huawei.com>
@ 2013-04-06 14:32 ` Jiang Liu
2013-04-19 16:54 ` Russell King - ARM Linux
2013-04-06 14:32 ` [PATCH v4, part3 14/41] mm/ARM64: " Jiang Liu
1 sibling, 1 reply; 4+ messages in thread
From: Jiang Liu @ 2013-04-06 14:32 UTC (permalink / raw)
To: linux-arm-kernel
Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
---
arch/arm/mm/init.c | 47 ++---------------------------------------------
1 file changed, 2 insertions(+), 45 deletions(-)
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index add4fcb..7a911d1 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -582,9 +582,6 @@ static void __init free_highpages(void)
*/
void __init mem_init(void)
{
- unsigned long reserved_pages, free_pages;
- struct memblock_region *reg;
- int i;
#ifdef CONFIG_HAVE_TCM
/* These pointers are filled in on TCM detection */
extern u32 dtcm_end;
@@ -605,47 +602,7 @@ void __init mem_init(void)
free_highpages();
- reserved_pages = free_pages = 0;
-
- for_each_bank(i, &meminfo) {
- struct membank *bank = &meminfo.bank[i];
- unsigned int pfn1, pfn2;
- struct page *page, *end;
-
- pfn1 = bank_pfn_start(bank);
- pfn2 = bank_pfn_end(bank);
-
- page = pfn_to_page(pfn1);
- end = pfn_to_page(pfn2 - 1) + 1;
-
- do {
- if (PageReserved(page))
- reserved_pages++;
- else if (!page_count(page))
- free_pages++;
- page++;
- } while (page < end);
- }
-
- /*
- * Since our memory may not be contiguous, calculate the
- * real number of pages we have in this system
- */
- printk(KERN_INFO "Memory:");
- num_physpages = 0;
- for_each_memblock(memory, reg) {
- unsigned long pages = memblock_region_memory_end_pfn(reg) -
- memblock_region_memory_base_pfn(reg);
- num_physpages += pages;
- printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
- }
- printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
- printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
- nr_free_pages() << (PAGE_SHIFT-10),
- free_pages << (PAGE_SHIFT-10),
- reserved_pages << (PAGE_SHIFT-10),
- totalhigh_pages << (PAGE_SHIFT-10));
+ mem_init_print_info(NULL);
#define MLK(b, t) b, t, ((t) - (b)) >> 10
#define MLM(b, t) b, t, ((t) - (b)) >> 20
@@ -711,7 +668,7 @@ void __init mem_init(void)
BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET);
#endif
- if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+ if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
/*
* On a machine this small we won't get
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4, part3 14/41] mm/ARM64: prepare for removing num_physpages and simplify mem_init()
[not found] <1365258760-30821-1-git-send-email-jiang.liu@huawei.com>
2013-04-06 14:32 ` [PATCH v4, part3 13/41] mm/ARM: prepare for removing num_physpages and simplify mem_init() Jiang Liu
@ 2013-04-06 14:32 ` Jiang Liu
1 sibling, 0 replies; 4+ messages in thread
From: Jiang Liu @ 2013-04-06 14:32 UTC (permalink / raw)
To: linux-arm-kernel
Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
---
arch/arm64/mm/init.c | 48 +++---------------------------------------------
1 file changed, 3 insertions(+), 45 deletions(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 0f2cf5d..821e788 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -272,59 +272,17 @@ static void __init free_unused_memmap(void)
*/
void __init mem_init(void)
{
- unsigned long reserved_pages, free_pages;
- struct memblock_region *reg;
-
arm64_swiotlb_init();
max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
#ifndef CONFIG_SPARSEMEM_VMEMMAP
- /* this will put all unused low memory onto the freelists */
free_unused_memmap();
#endif
-
+ /* this will put all unused low memory onto the freelists */
free_all_bootmem();
- reserved_pages = free_pages = 0;
-
- for_each_memblock(memory, reg) {
- unsigned int pfn1, pfn2;
- struct page *page, *end;
-
- pfn1 = __phys_to_pfn(reg->base);
- pfn2 = pfn1 + __phys_to_pfn(reg->size);
-
- page = pfn_to_page(pfn1);
- end = pfn_to_page(pfn2 - 1) + 1;
-
- do {
- if (PageReserved(page))
- reserved_pages++;
- else if (!page_count(page))
- free_pages++;
- page++;
- } while (page < end);
- }
-
- /*
- * Since our memory may not be contiguous, calculate the real number
- * of pages we have in this system.
- */
- pr_info("Memory:");
- num_physpages = 0;
- for_each_memblock(memory, reg) {
- unsigned long pages = memblock_region_memory_end_pfn(reg) -
- memblock_region_memory_base_pfn(reg);
- num_physpages += pages;
- printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
- }
- printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
- pr_notice("Memory: %luk/%luk available, %luk reserved\n",
- nr_free_pages() << (PAGE_SHIFT-10),
- free_pages << (PAGE_SHIFT-10),
- reserved_pages << (PAGE_SHIFT-10));
+ mem_init_print_info();
#define MLK(b, t) b, t, ((t) - (b)) >> 10
#define MLM(b, t) b, t, ((t) - (b)) >> 20
@@ -366,7 +324,7 @@ void __init mem_init(void)
BUILD_BUG_ON(TASK_SIZE_64 > MODULES_VADDR);
BUG_ON(TASK_SIZE_64 > MODULES_VADDR);
- if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+ if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
/*
* On a machine this small we won't get anywhere without
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4, part3 13/41] mm/ARM: prepare for removing num_physpages and simplify mem_init()
2013-04-06 14:32 ` [PATCH v4, part3 13/41] mm/ARM: prepare for removing num_physpages and simplify mem_init() Jiang Liu
@ 2013-04-19 16:54 ` Russell King - ARM Linux
2013-04-20 15:19 ` Jiang Liu
0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2013-04-19 16:54 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Apr 06, 2013 at 10:32:12PM +0800, Jiang Liu wrote:
> Prepare for removing num_physpages and simplify mem_init().
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-kernel at vger.kernel.org
> ---
> arch/arm/mm/init.c | 47 ++---------------------------------------------
> 1 file changed, 2 insertions(+), 45 deletions(-)
>
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index add4fcb..7a911d1 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -582,9 +582,6 @@ static void __init free_highpages(void)
> */
> void __init mem_init(void)
> {
> - unsigned long reserved_pages, free_pages;
> - struct memblock_region *reg;
> - int i;
> #ifdef CONFIG_HAVE_TCM
> /* These pointers are filled in on TCM detection */
> extern u32 dtcm_end;
> @@ -605,47 +602,7 @@ void __init mem_init(void)
>
> free_highpages();
>
> - reserved_pages = free_pages = 0;
> -
> - for_each_bank(i, &meminfo) {
> - struct membank *bank = &meminfo.bank[i];
> - unsigned int pfn1, pfn2;
> - struct page *page, *end;
> -
> - pfn1 = bank_pfn_start(bank);
> - pfn2 = bank_pfn_end(bank);
> -
> - page = pfn_to_page(pfn1);
> - end = pfn_to_page(pfn2 - 1) + 1;
> -
> - do {
> - if (PageReserved(page))
> - reserved_pages++;
> - else if (!page_count(page))
> - free_pages++;
> - page++;
> - } while (page < end);
> - }
> -
> - /*
> - * Since our memory may not be contiguous, calculate the
> - * real number of pages we have in this system
> - */
> - printk(KERN_INFO "Memory:");
> - num_physpages = 0;
> - for_each_memblock(memory, reg) {
> - unsigned long pages = memblock_region_memory_end_pfn(reg) -
> - memblock_region_memory_base_pfn(reg);
> - num_physpages += pages;
> - printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
> - }
> - printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
> -
> - printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
> - nr_free_pages() << (PAGE_SHIFT-10),
> - free_pages << (PAGE_SHIFT-10),
> - reserved_pages << (PAGE_SHIFT-10),
> - totalhigh_pages << (PAGE_SHIFT-10));
> + mem_init_print_info(NULL);
I'm concerned about this. We explicitly do not use the memblock information
when walking the memory above for the reserved/free pages because memblock
merges the various banks of memory together - and those may cross sparsemem
boundaries. Any crossing of the sparsemem boundaries needs the struct page
pointer to be re-evaluated because it can be part of a different array of
such things.
Where's the rest of the patches?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4, part3 13/41] mm/ARM: prepare for removing num_physpages and simplify mem_init()
2013-04-19 16:54 ` Russell King - ARM Linux
@ 2013-04-20 15:19 ` Jiang Liu
0 siblings, 0 replies; 4+ messages in thread
From: Jiang Liu @ 2013-04-20 15:19 UTC (permalink / raw)
To: linux-arm-kernel
On 04/20/2013 12:54 AM, Russell King - ARM Linux wrote:
> On Sat, Apr 06, 2013 at 10:32:12PM +0800, Jiang Liu wrote:
>> Prepare for removing num_physpages and simplify mem_init().
>>
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: linux-arm-kernel at lists.infradead.org
>> Cc: linux-kernel at vger.kernel.org
>> ---
>> arch/arm/mm/init.c | 47 ++---------------------------------------------
>> 1 file changed, 2 insertions(+), 45 deletions(-)
>>
>> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
>> index add4fcb..7a911d1 100644
>> --- a/arch/arm/mm/init.c
>> +++ b/arch/arm/mm/init.c
>> @@ -582,9 +582,6 @@ static void __init free_highpages(void)
>> */
>> void __init mem_init(void)
>> {
>> - unsigned long reserved_pages, free_pages;
>> - struct memblock_region *reg;
>> - int i;
>> #ifdef CONFIG_HAVE_TCM
>> /* These pointers are filled in on TCM detection */
>> extern u32 dtcm_end;
>> @@ -605,47 +602,7 @@ void __init mem_init(void)
>>
>> free_highpages();
>>
>> - reserved_pages = free_pages = 0;
>> -
>> - for_each_bank(i, &meminfo) {
>> - struct membank *bank = &meminfo.bank[i];
>> - unsigned int pfn1, pfn2;
>> - struct page *page, *end;
>> -
>> - pfn1 = bank_pfn_start(bank);
>> - pfn2 = bank_pfn_end(bank);
>> -
>> - page = pfn_to_page(pfn1);
>> - end = pfn_to_page(pfn2 - 1) + 1;
>> -
>> - do {
>> - if (PageReserved(page))
>> - reserved_pages++;
>> - else if (!page_count(page))
>> - free_pages++;
>> - page++;
>> - } while (page < end);
>> - }
>> -
>> - /*
>> - * Since our memory may not be contiguous, calculate the
>> - * real number of pages we have in this system
>> - */
>> - printk(KERN_INFO "Memory:");
>> - num_physpages = 0;
>> - for_each_memblock(memory, reg) {
>> - unsigned long pages = memblock_region_memory_end_pfn(reg) -
>> - memblock_region_memory_base_pfn(reg);
>> - num_physpages += pages;
>> - printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
>> - }
>> - printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
>> -
>> - printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
>> - nr_free_pages() << (PAGE_SHIFT-10),
>> - free_pages << (PAGE_SHIFT-10),
>> - reserved_pages << (PAGE_SHIFT-10),
>> - totalhigh_pages << (PAGE_SHIFT-10));
>> + mem_init_print_info(NULL);
>
> I'm concerned about this. We explicitly do not use the memblock information
> when walking the memory above for the reserved/free pages because memblock
> merges the various banks of memory together - and those may cross sparsemem
> boundaries. Any crossing of the sparsemem boundaries needs the struct page
> pointer to be re-evaluated because it can be part of a different array of
> such things.
>
> Where's the rest of the patches?
>
Hi Russel,
Thanks for review the patch. You may find the patch introducing
mem_init_print_info() at: http://marc.info/?l=linux-mm&m=136525938817934&w=2
Basically it prints standard memory statistics info as below for all architectures
without walking the page structure array.
Memory: 7744624K/8074824K available (6969K kernel code, 1011K data, 2828K rodata, 1016K init, 9640K bss, 330200K reserved)
On the other hand, the patch does change information printed on boot, especially
it doesn't print size of each memory block. If needed, I can revert the code to
print size of each memory block.
Regards!
Gerry
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-20 15:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1365258760-30821-1-git-send-email-jiang.liu@huawei.com>
2013-04-06 14:32 ` [PATCH v4, part3 13/41] mm/ARM: prepare for removing num_physpages and simplify mem_init() Jiang Liu
2013-04-19 16:54 ` Russell King - ARM Linux
2013-04-20 15:19 ` Jiang Liu
2013-04-06 14:32 ` [PATCH v4, part3 14/41] mm/ARM64: " Jiang Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).