* [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages
[not found] <1362896833-21104-1-git-send-email-jiang.liu@huawei.com>
@ 2013-03-10 6:26 ` Jiang Liu
2013-04-04 15:47 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: linux-arm-kernel
Use common help functions to free reserved pages.
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 | 48 ++++++++++++++++--------------------------------
arch/arm64/mm/init.c | 26 ++------------------------
2 files changed, 18 insertions(+), 56 deletions(-)
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index ad722f1..40a5bc2 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -424,24 +424,6 @@ void __init bootmem_init(void)
max_pfn = max_high - PHYS_PFN_OFFSET;
}
-static inline int free_area(unsigned long pfn, unsigned long end, char *s)
-{
- unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
-
- for (; pfn < end; pfn++) {
- struct page *page = pfn_to_page(pfn);
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- pages++;
- }
-
- if (size && s)
- printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
-
- return pages;
-}
-
/*
* Poison init memory with an undefined instruction (ARM) or a branch to an
* undefined instruction (Thumb).
@@ -534,6 +516,16 @@ static void __init free_unused_memmap(struct meminfo *mi)
#endif
}
+#ifdef CONFIG_HIGHMEM
+static inline void free_area_high(unsigned long pfn, unsigned long end)
+{
+ for (; pfn < end; pfn++) {
+ __free_reserved_page(pfn_to_page(pfn));
+ totalhigh_pages++;
+ }
+}
+#endif
+
static void __init free_highpages(void)
{
#ifdef CONFIG_HIGHMEM
@@ -569,8 +561,7 @@ static void __init free_highpages(void)
if (res_end > end)
res_end = end;
if (res_start != start)
- totalhigh_pages += free_area(start, res_start,
- NULL);
+ free_area_high(start, res_start);
start = res_end;
if (start == end)
break;
@@ -578,7 +569,7 @@ static void __init free_highpages(void)
/* And now free anything which remains */
if (start < end)
- totalhigh_pages += free_area(start, end, NULL);
+ free_area_high(start, end);
}
totalram_pages += totalhigh_pages;
#endif
@@ -609,8 +600,7 @@ void __init mem_init(void)
#ifdef CONFIG_SA1111
/* now that our DMA memory is actually so designated, we can free it */
- totalram_pages += free_area(PHYS_PFN_OFFSET,
- __phys_to_pfn(__pa(swapper_pg_dir)), NULL);
+ free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
#endif
free_highpages();
@@ -738,16 +728,12 @@ void free_initmem(void)
extern char __tcm_start, __tcm_end;
poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
- totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
- __phys_to_pfn(__pa(&__tcm_end)),
- "TCM link");
+ free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
#endif
poison_init_mem(__init_begin, __init_end - __init_begin);
if (!machine_is_integrator() && !machine_is_cintegrator())
- totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)),
- __phys_to_pfn(__pa(__init_end)),
- "init");
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
@@ -758,9 +744,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
{
if (!keep_initrd) {
poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
- totalram_pages += free_area(__phys_to_pfn(__pa(start)),
- __phys_to_pfn(__pa(end)),
- "initrd");
+ free_reserved_area(start, end, 0, "initrd");
}
}
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 800aac3..f497ca7 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -197,24 +197,6 @@ void __init bootmem_init(void)
max_pfn = max_low_pfn = max;
}
-static inline int free_area(unsigned long pfn, unsigned long end, char *s)
-{
- unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
-
- for (; pfn < end; pfn++) {
- struct page *page = pfn_to_page(pfn);
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- pages++;
- }
-
- if (size && s)
- pr_info("Freeing %s memory: %dK\n", s, size);
-
- return pages;
-}
-
/*
* Poison init memory with an undefined instruction (0x0).
*/
@@ -405,9 +387,7 @@ void __init mem_init(void)
void free_initmem(void)
{
poison_init_mem(__init_begin, __init_end - __init_begin);
- totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)),
- __phys_to_pfn(__pa(__init_end)),
- "init");
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
@@ -418,9 +398,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
{
if (!keep_initrd) {
poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
- totalram_pages += free_area(__phys_to_pfn(__pa(start)),
- __phys_to_pfn(__pa(end)),
- "initrd");
+ free_reserved_area(start, end, 0, "initrd");
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages
2013-03-10 6:26 ` [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages Jiang Liu
@ 2013-04-04 15:47 ` Arnd Bergmann
2013-04-06 14:07 ` Jiang Liu
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2013-04-04 15:47 UTC (permalink / raw)
To: linux-arm-kernel
On Sunday 10 March 2013, Jiang Liu wrote:
> Use common help functions to free reserved pages.
>
> 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
Hello Jiang Liu,
I'm getting a few new build warnings from this patch in linux-next, can you please
have a look what's going on here?
> @@ -609,8 +600,7 @@ void __init mem_init(void)
>
> #ifdef CONFIG_SA1111
> /* now that our DMA memory is actually so designated, we can free it */
> - totalram_pages += free_area(PHYS_PFN_OFFSET,
> - __phys_to_pfn(__pa(swapper_pg_dir)), NULL);
> + free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
> #endif
Using neponset_defconfig:
arch/arm/mm/init.c: In function 'mem_init':
arch/arm/mm/init.c:603:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default]
free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
^
In file included from include/linux/mman.h:4:0,
from arch/arm/mm/init.c:15:
include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'void *'
extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
^
> @@ -738,16 +728,12 @@ void free_initmem(void)
> extern char __tcm_start, __tcm_end;
>
> poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
> - totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
> - __phys_to_pfn(__pa(&__tcm_end)),
> - "TCM link");
> + free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
> #endif
Using one of {realview,s3c6400,u300}_defconfig:
/git/arm-soc/arch/arm/mm/init.c: In function 'free_initmem':
/git/arm-soc/arch/arm/mm/init.c:731:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default]
free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
^
In file included from /git/arm-soc/include/linux/mman.h:4:0,
from /git/arm-soc/arch/arm/mm/init.c:15:
/git/arm-soc/include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'char *'
extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
^
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages
2013-04-04 15:47 ` Arnd Bergmann
@ 2013-04-06 14:07 ` Jiang Liu
0 siblings, 0 replies; 3+ messages in thread
From: Jiang Liu @ 2013-04-06 14:07 UTC (permalink / raw)
To: linux-arm-kernel
Hi Arnd,
Missed some type casts for ARM. Could you please help check the patch at
http://marc.info/?l=linux-mm&m=136525654717201&w=2?
Thanks!
Gerry
On 04/04/2013 11:47 PM, Arnd Bergmann wrote:
> On Sunday 10 March 2013, Jiang Liu wrote:
>> Use common help functions to free reserved pages.
>>
>> 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
>
> Hello Jiang Liu,
>
> I'm getting a few new build warnings from this patch in linux-next, can you please
> have a look what's going on here?
>
>> @@ -609,8 +600,7 @@ void __init mem_init(void)
>>
>> #ifdef CONFIG_SA1111
>> /* now that our DMA memory is actually so designated, we can free it */
>> - totalram_pages += free_area(PHYS_PFN_OFFSET,
>> - __phys_to_pfn(__pa(swapper_pg_dir)), NULL);
>> + free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
>> #endif
>
> Using neponset_defconfig:
>
> arch/arm/mm/init.c: In function 'mem_init':
> arch/arm/mm/init.c:603:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default]
> free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
> ^
> In file included from include/linux/mman.h:4:0,
> from arch/arm/mm/init.c:15:
> include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'void *'
> extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
> ^
>
>> @@ -738,16 +728,12 @@ void free_initmem(void)
>> extern char __tcm_start, __tcm_end;
>>
>> poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
>> - totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
>> - __phys_to_pfn(__pa(&__tcm_end)),
>> - "TCM link");
>> + free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
>> #endif
>
> Using one of {realview,s3c6400,u300}_defconfig:
>
> /git/arm-soc/arch/arm/mm/init.c: In function 'free_initmem':
> /git/arm-soc/arch/arm/mm/init.c:731:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default]
> free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
> ^
> In file included from /git/arm-soc/include/linux/mman.h:4:0,
> from /git/arm-soc/arch/arm/mm/init.c:15:
> /git/arm-soc/include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'char *'
> extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
> ^
>
> Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-06 14:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1362896833-21104-1-git-send-email-jiang.liu@huawei.com>
2013-03-10 6:26 ` [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages Jiang Liu
2013-04-04 15:47 ` Arnd Bergmann
2013-04-06 14:07 ` 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).