* [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code
@ 2013-03-10 6:26 Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
` (28 more replies)
0 siblings, 29 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, Anatolij Gustschin, Aurelien Jacquiot,
Benjamin Herrenschmidt, Catalin Marinas, Chen Liqin,
Chris Metcalf, Chris Zankel, David Howells, David S. Miller,
Eric Biederman, Fenghua Yu, Geert Uytterhoeven, Guan Xuetao,
Haavard Skinnemoen, Hans-Christian Egtvedt, Heiko Carstens,
Helge Deller, James Hogan, Hirokazu Takata, H. Peter Anvin,
Ingo Molnar, Ivan Kokshaysky, James E.J. Bottomley, Jeff Dike,
Jeremy Fitzhardinge, Jonas Bonn, Koichi Yasutake,
Konrad Rzeszutek Wilk, Lennox Wu, Mark Salter, Martin Schwidefsky,
Matt Turner, Max Filippov, Michael S. Tsirkin, Michal Simek,
Michel Lespinasse, Mikael Starvik, Mike Frysinger, Paul Mackerras,
Paul Mundt, Ralf Baechle, Richard Henderson, Rik van Riel,
Russell King, Rusty Russell, Sam Ravnborg, Tang Chen,
Thomas Gleixner, Tony Luck, Will Deacon, Yasuaki Ishimatsu,
Yinghai Lu, Yoshinori Sato, x86, xen-devel, linux-kernel,
linux-mm, linux-arm-kernel, Vineet Gupta, linux-snps-arc,
virtualization
The original goal of this patchset is to fix the bug reported by
https://bugzilla.kernel.org/show_bug.cgi?id=53501
Now it has also been expanded to reduce common code used by memory
initializion.
This is the first part, which applies to v3.9-rc1.
It introduces following common helper functions to simplify
free_initmem() and free_initrd_mem() on different architectures:
adjust_managed_page_count():
will be used to adjust totalram_pages, totalhigh_pages,
zone->managed_pages when reserving/unresering a page.
__free_reserved_page():
free a reserved page into the buddy system without adjusting
page statistics info
free_reserved_page():
free a reserved page into the buddy system and adjust page
statistics info
mark_page_reserved():
mark a page as reserved and adjust page statistics info
free_reserved_area():
free a continous ranges of pages by calling free_reserved_page()
free_initmem_default():
default method to free __init pages.
We have only tested these patchset on x86 platforms, and have done basic
compliation tests using cross-compilers from ftp.kernel.org. That means
some code may not pass compilation on some architectures. So any help
to test this patchset are welcomed!
There are several other parts still under development:
Part2: introduce free_highmem_page() to simplify freeing highmem pages
Part3: refine code to manage totalram_pages, totalhigh_pages and
zone->managed_pages
Part4: introduce helper functions to simplify mem_init() and remove the
global variable num_physpages.
Jiang Liu (29):
mm: introduce common help functions to deal with reserved/managed
pages
mm/alpha: use common help functions to free reserved pages
mm/ARM: use common help functions to free reserved pages
mm/avr32: use common help functions to free reserved pages
mm/blackfin: use common help functions to free reserved pages
mm/c6x: use common help functions to free reserved pages
mm/cris: use common help functions to free reserved pages
mm/FRV: use common help functions to free reserved pages
mm/h8300: use common help functions to free reserved pages
mm/IA64: use common help functions to free reserved pages
mm/m32r: use common help functions to free reserved pages
mm/m68k: use common help functions to free reserved pages
mm/microblaze: use common help functions to free reserved pages
mm/MIPS: use common help functions to free reserved pages
mm/mn10300: use common help functions to free reserved pages
mm/openrisc: use common help functions to free reserved pages
mm/parisc: use common help functions to free reserved pages
mm/ppc: use common help functions to free reserved pages
mm/s390: use common help functions to free reserved pages
mm/score: use common help functions to free reserved pages
mm/SH: use common help functions to free reserved pages
mm/SPARC: use common help functions to free reserved pages
mm/um: use common help functions to free reserved pages
mm/unicore32: use common help functions to free reserved pages
mm/x86: use common help functions to free reserved pages
mm/xtensa: use common help functions to free reserved pages
mm/arc: use common help functions to free reserved pages
mm/metag: use common help functions to free reserved pages
mm,kexec: use common help functions to free reserved pages
arch/alpha/kernel/sys_nautilus.c | 5 ++-
arch/alpha/mm/init.c | 24 ++-----------
arch/alpha/mm/numa.c | 3 +-
arch/arc/mm/init.c | 23 ++----------
arch/arm/mm/init.c | 48 +++++++++-----------------
arch/arm64/mm/init.c | 26 ++------------
arch/avr32/mm/init.c | 24 ++-----------
arch/blackfin/mm/init.c | 22 ++----------
arch/c6x/mm/init.c | 30 ++--------------
arch/cris/mm/init.c | 16 ++-------
arch/frv/mm/init.c | 34 +++---------------
arch/h8300/mm/init.c | 30 ++--------------
arch/ia64/mm/init.c | 23 +++---------
arch/m32r/mm/init.c | 26 ++------------
arch/m68k/mm/init.c | 24 ++-----------
arch/metag/mm/init.c | 21 ++---------
arch/microblaze/include/asm/setup.h | 1 -
arch/microblaze/mm/init.c | 28 ++-------------
arch/mips/mm/init.c | 31 +++++------------
arch/mips/sgi-ip27/ip27-memory.c | 4 +--
arch/mn10300/mm/init.c | 23 ++----------
arch/openrisc/mm/init.c | 27 ++-------------
arch/parisc/mm/init.c | 23 ++----------
arch/powerpc/kernel/crash_dump.c | 5 +--
arch/powerpc/kernel/fadump.c | 5 +--
arch/powerpc/kernel/kvm.c | 7 +---
arch/powerpc/mm/mem.c | 29 ++--------------
arch/powerpc/platforms/512x/mpc512x_shared.c | 5 +--
arch/s390/mm/init.c | 35 ++++---------------
arch/score/mm/init.c | 33 +++---------------
arch/sh/mm/init.c | 26 ++------------
arch/sparc/kernel/leon_smp.c | 15 ++------
arch/sparc/mm/init_32.c | 37 ++------------------
arch/sparc/mm/init_64.c | 26 +++-----------
arch/um/kernel/mem.c | 10 +-----
arch/unicore32/mm/init.c | 28 ++-------------
arch/x86/mm/init.c | 5 +--
arch/x86/mm/init_64.c | 5 ++-
arch/xtensa/mm/init.c | 21 ++---------
include/linux/mm.h | 48 ++++++++++++++++++++++++++
kernel/kexec.c | 8 ++---
mm/page_alloc.c | 20 +++++++++++
42 files changed, 184 insertions(+), 700 deletions(-)
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 9:20 ` Geert Uytterhoeven
2013-03-10 6:26 ` [PATCH v2, part1 02/29] mm/alpha: use common help functions to free reserved pages Jiang Liu
` (27 subsequent siblings)
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, Anatolij Gustschin, Aurelien Jacquiot,
Benjamin Herrenschmidt, Catalin Marinas, Chen Liqin,
Chris Metcalf, Chris Zankel, David Howells, David S. Miller,
Eric Biederman, Fenghua Yu, Geert Uytterhoeven, Guan Xuetao,
Haavard Skinnemoen, Hans-Christian Egtvedt, Heiko Carstens,
Helge Deller, James Hogan, Hirokazu Takata, H. Peter Anvin,
Ingo Molnar, Ivan Kokshaysky, James E.J. Bottomley, Jeff Dike,
Jeremy Fitzhardinge, Jonas Bonn, Koichi Yasutake,
Konrad Rzeszutek Wilk, Lennox Wu, Mark Salter, Martin Schwidefsky,
Matt Turner, Max Filippov, Michael S. Tsirkin, Michal Simek,
Michel Lespinasse, Mikael Starvik, Mike Frysinger, Paul Mackerras,
Paul Mundt, Ralf Baechle, Richard Henderson, Rik van Riel,
Russell King, Rusty Russell, Sam Ravnborg, Tang Chen,
Thomas Gleixner, Tony Luck, Will Deacon, Yasuaki Ishimatsu,
Yinghai Lu, Yoshinori Sato, x86, xen-devel, linux-kernel,
linux-mm, linux-arm-kernel, Vineet Gupta, linux-snps-arc,
virtualization
Code to deal with reserved/managed pages are duplicated by many
architectures, so introduce common help functions to reduce duplicated
code. These common help functions will also be used to concentrate code
to modify totalram_pages and zone->managed_pages, which makes the code
much more clear.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
mm/page_alloc.c | 20 ++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7acc9dc..d75c14b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1295,6 +1295,54 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
unsigned long zone_start_pfn, unsigned long *zholes_size);
extern void free_initmem(void);
+/*
+ * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK)
+ * into the buddy system. The freed pages will be poisoned with pattern
+ * "poison" if it's non-zero.
+ * Return pages freed into the buddy system.
+ */
+extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
+ int poison, char *s);
+
+static inline void adjust_managed_page_count(struct page *page, long count)
+{
+ totalram_pages += count;
+}
+
+/* Free the reserved page into the buddy system, so it gets managed. */
+static inline void __free_reserved_page(struct page *page)
+{
+ ClearPageReserved(page);
+ init_page_count(page);
+ __free_page(page);
+}
+
+static inline void free_reserved_page(struct page *page)
+{
+ __free_reserved_page(page);
+ adjust_managed_page_count(page, 1);
+}
+
+static inline void mark_page_reserved(struct page *page)
+{
+ SetPageReserved(page);
+ adjust_managed_page_count(page, -1);
+}
+
+/*
+ * Default method to free all the __init memory into the buddy system.
+ * The freed pages will be poisoned with pattern "poison" if it is
+ * non-zero. Return pages freed into the buddy system.
+ */
+static inline unsigned long free_initmem_default(int poison)
+{
+ extern char __init_begin[], __init_end[];
+
+ return free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) ,
+ ((unsigned long)&__init_end) & PAGE_MASK,
+ poison, "unused kernel");
+}
+
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
/*
* With CONFIG_HAVE_MEMBLOCK_NODE_MAP set, an architecture may initialise its
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8fcced7..0fadb09 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5113,6 +5113,26 @@ early_param("movablecore", cmdline_parse_movablecore);
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+unsigned long free_reserved_area(unsigned long start, unsigned long end,
+ int poison, char *s)
+{
+ unsigned long pages, pos;
+
+ pos = start = PAGE_ALIGN(start);
+ end &= PAGE_MASK;
+ for (pages = 0; pos < end; pos += PAGE_SIZE, pages++) {
+ if (poison)
+ memset((void *)pos, poison, PAGE_SIZE);
+ free_reserved_page(virt_to_page(pos));
+ }
+
+ if (pages && s)
+ pr_info("Freeing %s memory: %ldK (%lx - %lx)\n",
+ s, pages << (PAGE_SHIFT - 10), start, end);
+
+ return pages;
+}
+
/**
* set_dma_reserve - set the specified number of pages reserved in the first zone
* @new_dma_reserve: The number of pages to mark reserved
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 02/29] mm/alpha: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 03/29] mm/ARM: " Jiang Liu
` (26 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel,
Richard Henderson, Ivan Kokshaysky, Matt Turner
Use common help functions to free reserved pages.
Also include <asm/sections.h> to avoid local declarations.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
---
arch/alpha/kernel/sys_nautilus.c | 5 ++---
arch/alpha/mm/init.c | 24 +++---------------------
arch/alpha/mm/numa.c | 3 +--
3 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 4d4c046..a8b9d66 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -185,7 +185,6 @@ nautilus_machine_check(unsigned long vector, unsigned long la_ptr)
mb();
}
-extern void free_reserved_mem(void *, void *);
extern void pcibios_claim_one_bus(struct pci_bus *);
static struct resource irongate_mem = {
@@ -234,8 +233,8 @@ nautilus_init_pci(void)
if (pci_mem < memtop)
memtop = pci_mem;
if (memtop > alpha_mv.min_mem_address) {
- free_reserved_mem(__va(alpha_mv.min_mem_address),
- __va(memtop));
+ free_reserved_area((unsigned long)__va(alpha_mv.min_mem_address),
+ (unsigned long)__va(memtop), 0, NULL);
printk("nautilus_init_pci: %ldk freed\n",
(memtop - alpha_mv.min_mem_address) >> 10);
}
diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 1ad6ca7..0ba85ee 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -31,6 +31,7 @@
#include <asm/console.h>
#include <asm/tlb.h>
#include <asm/setup.h>
+#include <asm/sections.h>
extern void die_if_kernel(char *,struct pt_regs *,long);
@@ -281,8 +282,6 @@ printk_memory_info(void)
{
unsigned long codesize, reservedpages, datasize, initsize, tmp;
extern int page_is_ram(unsigned long) __init;
- extern char _text, _etext, _data, _edata;
- extern char __init_begin, __init_end;
/* printk all informations */
reservedpages = 0;
@@ -318,32 +317,15 @@ mem_init(void)
#endif /* CONFIG_DISCONTIGMEM */
void
-free_reserved_mem(void *start, void *end)
-{
- void *__start = start;
- for (; __start < end; __start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(__start));
- init_page_count(virt_to_page(__start));
- free_page((long)__start);
- totalram_pages++;
- }
-}
-
-void
free_initmem(void)
{
- extern char __init_begin, __init_end;
-
- free_reserved_mem(&__init_begin, &__init_end);
- printk ("Freeing unused kernel memory: %ldk freed\n",
- (&__init_end - &__init_begin) >> 10);
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
void
free_initrd_mem(unsigned long start, unsigned long end)
{
- free_reserved_mem((void *)start, (void *)end);
- printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index 3973ae3..3388504 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -17,6 +17,7 @@
#include <asm/hwrpb.h>
#include <asm/pgalloc.h>
+#include <asm/sections.h>
pg_data_t node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);
@@ -325,8 +326,6 @@ void __init mem_init(void)
{
unsigned long codesize, reservedpages, datasize, initsize, pfn;
extern int page_is_ram(unsigned long) __init;
- extern char _text, _etext, _data, _edata;
- extern char __init_begin, __init_end;
unsigned long nid, i;
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ 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 00/29] Use helper functions to simplify memory intialization code Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 02/29] mm/alpha: use common help functions to free reserved pages Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-04-04 15:47 ` Arnd Bergmann
2013-03-10 6:26 ` [PATCH v2, part1 04/29] mm/avr32: " Jiang Liu
` (25 subsequent siblings)
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Russell King,
Catalin Marinas, Will Deacon, 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@lists.infradead.org
Cc: linux-kernel@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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 04/29] mm/avr32: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (2 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 03/29] mm/ARM: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 05/29] mm/blackfin: " Jiang Liu
` (24 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel,
Haavard Skinnemoen
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
---
arch/avr32/mm/init.c | 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)
diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index 2798c2d..e66e840 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -146,34 +146,14 @@ void __init mem_init(void)
initsize >> 10);
}
-static inline void free_area(unsigned long addr, unsigned long end, char *s)
-{
- unsigned int size = (end - addr) >> 10;
-
- for (; addr < end; addr += PAGE_SIZE) {
- struct page *page = virt_to_page(addr);
- ClearPageReserved(page);
- init_page_count(page);
- free_page(addr);
- totalram_pages++;
- }
-
- if (size && s)
- printk(KERN_INFO "Freeing %s memory: %dK (%lx - %lx)\n",
- s, size, end - (size << 10), end);
-}
-
void free_initmem(void)
{
- free_area((unsigned long)__init_begin, (unsigned long)__init_end,
- "init");
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
-
void free_initrd_mem(unsigned long start, unsigned long end)
{
- free_area(start, end, "initrd");
+ free_reserved_area(start, end, 0, "initrd");
}
-
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 05/29] mm/blackfin: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (3 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 04/29] mm/avr32: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 06/29] mm/c6x: " Jiang Liu
` (23 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Mike Frysinger
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
arch/blackfin/mm/init.c | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index 9cb8553..82d01a7 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -103,7 +103,7 @@ void __init mem_init(void)
max_mapnr = num_physpages = MAP_NR(high_memory);
printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", num_physpages);
- /* This will put all memory onto the freelists. */
+ /* This will put all low memory onto the freelists. */
totalram_pages = free_all_bootmem();
reservedpages = 0;
@@ -129,24 +129,11 @@ void __init mem_init(void)
initk, codek, datak, DMA_UNCACHED_REGION >> 10, (reservedpages << (PAGE_SHIFT-10)));
}
-static void __init free_init_pages(const char *what, unsigned long begin, unsigned long end)
-{
- unsigned long addr;
- /* next to check that the page we free is not a partial page */
- for (addr = begin; addr + PAGE_SIZE <= end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
-}
-
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
#ifndef CONFIG_MPU
- free_init_pages("initrd memory", start, end);
+ free_reserved_area(start, end, 0, "initrd");
#endif
}
#endif
@@ -154,10 +141,7 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)
void __init_refok free_initmem(void)
{
#if defined CONFIG_RAMKERNEL && !defined CONFIG_MPU
- free_init_pages("unused kernel memory",
- (unsigned long)(&__init_begin),
- (unsigned long)(&__init_end));
-
+ free_initmem_default(0);
if (memory_start == (unsigned long)(&__init_end))
memory_start = (unsigned long)(&__init_begin);
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 06/29] mm/c6x: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (4 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 05/29] mm/blackfin: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 07/29] mm/cris: " Jiang Liu
` (22 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Mark Salter,
Aurelien Jacquiot
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
---
arch/c6x/mm/init.c | 30 ++----------------------------
1 file changed, 2 insertions(+), 28 deletions(-)
diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c
index 89395f0..a9fcd89 100644
--- a/arch/c6x/mm/init.c
+++ b/arch/c6x/mm/init.c
@@ -77,37 +77,11 @@ void __init mem_init(void)
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
- int pages = 0;
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- pages++;
- }
- printk(KERN_INFO "Freeing initrd memory: %luk freed\n",
- (pages * PAGE_SIZE) >> 10);
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
void __init free_initmem(void)
{
- unsigned long addr;
-
- /*
- * The following code should be cool even if these sections
- * are not page aligned.
- */
- addr = PAGE_ALIGN((unsigned long)(__init_begin));
-
- /* next to check that the page we free is not a partial page */
- for (; addr + PAGE_SIZE < (unsigned long)(__init_end);
- addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing unused kernel memory: %dK freed\n",
- (int) ((addr - PAGE_ALIGN((long) &__init_begin)) >> 10));
+ free_initmem_default(0);
}
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 07/29] mm/cris: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (5 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 06/29] mm/c6x: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 08/29] mm/FRV: " Jiang Liu
` (21 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Mikael Starvik
Use common help functions to free reserved pages.
Also include <asm/sections.h> to avoid local declaration.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Mikael Starvik <starvik@axis.com>
---
arch/cris/mm/init.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/arch/cris/mm/init.c b/arch/cris/mm/init.c
index d72ab58..9ac8094 100644
--- a/arch/cris/mm/init.c
+++ b/arch/cris/mm/init.c
@@ -12,12 +12,10 @@
#include <linux/init.h>
#include <linux/bootmem.h>
#include <asm/tlb.h>
+#include <asm/sections.h>
unsigned long empty_zero_page;
-extern char _stext, _edata, _etext; /* From linkerscript */
-extern char __init_begin, __init_end;
-
void __init
mem_init(void)
{
@@ -67,15 +65,5 @@ mem_init(void)
void
free_initmem(void)
{
- unsigned long addr;
-
- addr = (unsigned long)(&__init_begin);
- for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk (KERN_INFO "Freeing unused kernel memory: %luk freed\n",
- (unsigned long)((&__init_end - &__init_begin) >> 10));
+ free_initmem_default(0);
}
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 08/29] mm/FRV: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (6 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 07/29] mm/cris: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 09/29] mm/h8300: " Jiang Liu
` (20 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, David Howells
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: David Howells <dhowells@redhat.com>
---
arch/frv/mm/init.c | 34 ++++------------------------------
1 file changed, 4 insertions(+), 30 deletions(-)
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 92e97b0..21b9290 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -122,7 +122,7 @@ void __init mem_init(void)
#endif
int codek = 0, datak = 0;
- /* this will put all memory onto the freelists */
+ /* this will put all low memory onto the freelists */
totalram_pages = free_all_bootmem();
#ifdef CONFIG_MMU
@@ -132,11 +132,7 @@ void __init mem_init(void)
#ifdef CONFIG_HIGHMEM
for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--) {
- struct page *page = &mem_map[pfn];
-
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
+ __free_reserved_page(&mem_map[pfn]);
totalram_pages++;
}
#endif
@@ -168,21 +164,7 @@ void __init mem_init(void)
void free_initmem(void)
{
#if defined(CONFIG_RAMKERNEL) && !defined(CONFIG_PROTECT_KERNEL)
- unsigned long start, end, addr;
-
- start = PAGE_ALIGN((unsigned long) &__init_begin); /* round up */
- end = ((unsigned long) &__init_end) & PAGE_MASK; /* round down */
-
- /* next to check that the page we free is not a partial page */
- for (addr = start; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
-
- printk("Freeing unused kernel memory: %ldKiB freed (0x%lx - 0x%lx)\n",
- (end - start) >> 10, start, end);
+ free_initmem_default(0);
#endif
} /* end free_initmem() */
@@ -193,14 +175,6 @@ void free_initmem(void)
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
- int pages = 0;
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- pages++;
- }
- printk("Freeing initrd memory: %dKiB freed\n", (pages * PAGE_SIZE) >> 10);
+ free_reserved_area(start, end, 0, "initrd");
} /* end free_initrd_mem() */
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 09/29] mm/h8300: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (7 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 08/29] mm/FRV: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 10/29] mm/IA64: " Jiang Liu
` (19 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Yoshinori Sato
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
---
arch/h8300/mm/init.c | 30 +++---------------------------
1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 981e250..ff349d7 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -139,7 +139,7 @@ void __init mem_init(void)
start_mem = PAGE_ALIGN(start_mem);
max_mapnr = num_physpages = MAP_NR(high_memory);
- /* this will put all memory onto the freelists */
+ /* this will put all low memory onto the freelists */
totalram_pages = free_all_bootmem();
codek = (_etext - _stext) >> 10;
@@ -161,15 +161,7 @@ void __init mem_init(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- int pages = 0;
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- pages++;
- }
- printk ("Freeing initrd memory: %dk freed\n", pages);
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
@@ -177,23 +169,7 @@ void
free_initmem(void)
{
#ifdef CONFIG_RAMKERNEL
- unsigned long addr;
-/*
- * the following code should be cool even if these sections
- * are not page aligned.
- */
- addr = PAGE_ALIGN((unsigned long)(__init_begin));
- /* next to check that the page we free is not a partial page */
- for (; addr + PAGE_SIZE < (unsigned long)__init_end; addr +=PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
- (addr - PAGE_ALIGN((long) __init_begin)) >> 10,
- (int)(PAGE_ALIGN((unsigned long)__init_begin)),
- (int)(addr - PAGE_SIZE));
+ free_initmem_default(0);
#endif
}
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 10/29] mm/IA64: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (8 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 09/29] mm/h8300: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 11/29] mm/m32r: " Jiang Liu
` (18 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Tony Luck,
Fenghua Yu
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
arch/ia64/mm/init.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 20bc967..d1fe4b4 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -154,25 +154,14 @@ ia64_init_addr_space (void)
void
free_initmem (void)
{
- unsigned long addr, eaddr;
-
- addr = (unsigned long) ia64_imva(__init_begin);
- eaddr = (unsigned long) ia64_imva(__init_end);
- while (addr < eaddr) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- ++totalram_pages;
- addr += PAGE_SIZE;
- }
- printk(KERN_INFO "Freeing unused kernel memory: %ldkB freed\n",
- (__init_end - __init_begin) >> 10);
+ free_reserved_area((unsigned long)ia64_imva(__init_begin),
+ (unsigned long)ia64_imva(__init_end),
+ 0, "unused kernel");
}
void __init
free_initrd_mem (unsigned long start, unsigned long end)
{
- struct page *page;
/*
* EFI uses 4KB pages while the kernel can use 4KB or bigger.
* Thus EFI and the kernel may have different page sizes. It is
@@ -213,11 +202,7 @@ free_initrd_mem (unsigned long start, unsigned long end)
for (; start < end; start += PAGE_SIZE) {
if (!virt_addr_valid(start))
continue;
- page = virt_to_page(start);
- ClearPageReserved(page);
- init_page_count(page);
- free_page(start);
- ++totalram_pages;
+ free_reserved_page(virt_to_page(start));
}
}
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 11/29] mm/m32r: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (9 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 10/29] mm/IA64: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 12/29] mm/m68k: " Jiang Liu
` (17 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Hirokazu Takata
Use common help functions to free reserved pages.
Also include <asm/sections.h> to avoid local declarations.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
---
arch/m32r/mm/init.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index 78b660e..ab4cbce 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -28,10 +28,7 @@
#include <asm/mmu_context.h>
#include <asm/setup.h>
#include <asm/tlb.h>
-
-/* References to section boundaries */
-extern char _text, _etext, _edata;
-extern char __init_begin, __init_end;
+#include <asm/sections.h>
pgd_t swapper_pg_dir[1024];
@@ -184,17 +181,7 @@ void __init mem_init(void)
*======================================================================*/
void free_initmem(void)
{
- unsigned long addr;
-
- addr = (unsigned long)(&__init_begin);
- for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", \
- (int)(&__init_end - &__init_begin) >> 10);
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
@@ -204,13 +191,6 @@ void free_initmem(void)
*======================================================================*/
void free_initrd_mem(unsigned long start, unsigned long end)
{
- unsigned long p;
- for (p = start; p < end; p += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(p));
- init_page_count(virt_to_page(p));
- free_page(p);
- totalram_pages++;
- }
- printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 12/29] mm/m68k: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (10 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 11/29] mm/m32r: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 9:21 ` Geert Uytterhoeven
2013-03-10 6:26 ` [PATCH v2, part1 13/29] mm/microblaze: " Jiang Liu
` (16 subsequent siblings)
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel,
Geert Uytterhoeven
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
arch/m68k/mm/init.c | 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index afd8106f..b5c1ab1 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -110,18 +110,7 @@ void __init paging_init(void)
void free_initmem(void)
{
#ifndef CONFIG_MMU_SUN3
- unsigned long addr;
-
- addr = (unsigned long) __init_begin;
- for (; addr < ((unsigned long) __init_end); addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- pr_notice("Freeing unused kernel memory: %luk freed (0x%x - 0x%x)\n",
- (addr - (unsigned long) __init_begin) >> 10,
- (unsigned int) __init_begin, (unsigned int) __init_end);
+ free_initmem_default(0);
#endif /* CONFIG_MMU_SUN3 */
}
@@ -213,15 +202,6 @@ void __init mem_init(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- int pages = 0;
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- pages++;
- }
- pr_notice("Freeing initrd memory: %dk freed\n",
- pages << (PAGE_SHIFT - 10));
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 13/29] mm/microblaze: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (11 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 12/29] mm/m68k: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 14/29] mm/MIPS: " Jiang Liu
` (15 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Michal Simek
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Michal Simek <monstr@monstr.eu>
---
arch/microblaze/include/asm/setup.h | 1 -
arch/microblaze/mm/init.c | 28 ++--------------------------
2 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index 0e0b0a5..f05df56 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -46,7 +46,6 @@ void machine_shutdown(void);
void machine_halt(void);
void machine_power_off(void);
-void free_init_pages(char *what, unsigned long begin, unsigned long end);
extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 8f8b367..9be5302 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -236,40 +236,16 @@ void __init setup_memory(void)
paging_init();
}
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
-{
- unsigned long addr;
-
- for (addr = begin; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- pr_info("Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
-}
-
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- int pages = 0;
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- pages++;
- }
- pr_notice("Freeing initrd memory: %dk freed\n",
- (int)(pages * (PAGE_SIZE / 1024)));
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
void free_initmem(void)
{
- free_init_pages("unused kernel memory",
- (unsigned long)(&__init_begin),
- (unsigned long)(&__init_end));
+ free_initmem_default(0);
}
void __init mem_init(void)
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 14/29] mm/MIPS: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (12 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 13/29] mm/microblaze: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 15/29] mm/mn10300: " Jiang Liu
` (14 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Ralf Baechle
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
arch/mips/mm/init.c | 31 +++++++++----------------------
arch/mips/sgi-ip27/ip27-memory.c | 4 ++--
2 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 6792925..60f7c61 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -77,10 +77,9 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
/*
* Not static inline because used by IP27 special magic initialization code
*/
-unsigned long setup_zero_pages(void)
+void setup_zero_pages(void)
{
- unsigned int order;
- unsigned long size;
+ unsigned int order, i;
struct page *page;
if (cpu_has_vce)
@@ -94,15 +93,10 @@ unsigned long setup_zero_pages(void)
page = virt_to_page((void *)empty_zero_page);
split_page(page, order);
- while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) {
- SetPageReserved(page);
- page++;
- }
-
- size = PAGE_SIZE << order;
- zero_page_mask = (size - 1) & PAGE_MASK;
+ for (i = 0; i < (1 << order); i++, page++)
+ mark_page_reserved(page);
- return 1UL << order;
+ zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
}
#ifdef CONFIG_MIPS_MT_SMTC
@@ -380,7 +374,7 @@ void __init mem_init(void)
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
totalram_pages += free_all_bootmem();
- totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */
+ setup_zero_pages(); /* Setup zeroed pages. */
reservedpages = ram = 0;
for (tmp = 0; tmp < max_low_pfn; tmp++)
@@ -440,11 +434,8 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
struct page *page = pfn_to_page(pfn);
void *addr = phys_to_virt(PFN_PHYS(pfn));
- ClearPageReserved(page);
- init_page_count(page);
memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
- __free_page(page);
- totalram_pages++;
+ free_reserved_page(page);
}
printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
}
@@ -452,18 +443,14 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- free_init_pages("initrd memory",
- virt_to_phys((void *)start),
- virt_to_phys((void *)end));
+ free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
}
#endif
void __init_refok free_initmem(void)
{
prom_free_prom_memory();
- free_init_pages("unused kernel memory",
- __pa_symbol(&__init_begin),
- __pa_symbol(&__init_end));
+ free_initmem_default(POISON_FREE_INITMEM);
}
#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 3505d08..5f2bddb 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -457,7 +457,7 @@ void __init prom_free_prom_memory(void)
/* We got nothing to free here ... */
}
-extern unsigned long setup_zero_pages(void);
+extern void setup_zero_pages(void);
void __init paging_init(void)
{
@@ -492,7 +492,7 @@ void __init mem_init(void)
totalram_pages += free_all_bootmem_node(NODE_DATA(node));
}
- totalram_pages -= setup_zero_pages(); /* This comes from node 0 */
+ setup_zero_pages(); /* This comes from node 0 */
codesize = (unsigned long) &_etext - (unsigned long) &_text;
datasize = (unsigned long) &_edata - (unsigned long) &_etext;
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 15/29] mm/mn10300: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (13 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 14/29] mm/MIPS: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 16/29] mm/openrisc: " Jiang Liu
` (13 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Koichi Yasutake
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
---
arch/mn10300/mm/init.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c
index e57e5bc..5a8ace6 100644
--- a/arch/mn10300/mm/init.c
+++ b/arch/mn10300/mm/init.c
@@ -139,30 +139,11 @@ void __init mem_init(void)
}
/*
- *
- */
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
-{
- unsigned long addr;
-
- for (addr = begin; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- memset((void *) addr, 0xcc, PAGE_SIZE);
- free_page(addr);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
-}
-
-/*
* recycle memory containing stuff only required for initialisation
*/
void free_initmem(void)
{
- free_init_pages("unused kernel memory",
- (unsigned long) &__init_begin,
- (unsigned long) &__init_end);
+ free_initmem_default(POISON_FREE_INITMEM);
}
/*
@@ -171,6 +152,6 @@ void free_initmem(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- free_init_pages("initrd memory", start, end);
+ free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 16/29] mm/openrisc: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (14 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 15/29] mm/mn10300: " Jiang Liu
@ 2013-03-10 6:26 ` Jiang Liu
2013-04-02 5:31 ` Jonas Bonn
2013-03-10 6:27 ` [PATCH v2, part1 17/29] mm/parisc: " Jiang Liu
` (12 subsequent siblings)
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:26 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Jonas Bonn
Use common help functions to free reserved pages.
Also include <asm/sections.h> to avoid local declarations.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Jonas Bonn <jonas@southpole.se>
---
arch/openrisc/mm/init.c | 27 +++------------------------
1 file changed, 3 insertions(+), 24 deletions(-)
diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c
index e7fdc50..b3cbc67 100644
--- a/arch/openrisc/mm/init.c
+++ b/arch/openrisc/mm/init.c
@@ -43,6 +43,7 @@
#include <asm/kmap_types.h>
#include <asm/fixmap.h>
#include <asm/tlbflush.h>
+#include <asm/sections.h>
int mem_init_done;
@@ -201,9 +202,6 @@ void __init paging_init(void)
/* References to section boundaries */
-extern char _stext, _etext, _edata, __bss_start, _end;
-extern char __init_begin, __init_end;
-
static int __init free_pages_init(void)
{
int reservedpages, pfn;
@@ -263,30 +261,11 @@ void __init mem_init(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
- (end - start) >> 10);
-
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- }
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
void free_initmem(void)
{
- unsigned long addr;
-
- addr = (unsigned long)(&__init_begin);
- for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing unused kernel memory: %luk freed\n",
- ((unsigned long)&__init_end -
- (unsigned long)&__init_begin) >> 10);
+ free_initmem_default(0);
}
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 17/29] mm/parisc: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (15 preceding siblings ...)
2013-03-10 6:26 ` [PATCH v2, part1 16/29] mm/openrisc: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 18/29] mm/ppc: " Jiang Liu
` (11 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel,
James E.J. Bottomley, Helge Deller
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
---
arch/parisc/mm/init.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 3ac462d..de2159a 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -505,7 +505,6 @@ static void __init map_pages(unsigned long start_vaddr,
void free_initmem(void)
{
- unsigned long addr;
unsigned long init_begin = (unsigned long)__init_begin;
unsigned long init_end = (unsigned long)__init_end;
@@ -533,19 +532,10 @@ void free_initmem(void)
* pages are no-longer executable */
flush_icache_range(init_begin, init_end);
- for (addr = init_begin; addr < init_end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- num_physpages++;
- totalram_pages++;
- }
+ num_physpages += free_initmem_default(0);
/* set up a new led state on systems shipped LED State panel */
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
-
- printk(KERN_INFO "Freeing unused kernel memory: %luk freed\n",
- (init_end - init_begin) >> 10);
}
@@ -1107,15 +1097,6 @@ void flush_tlb_all(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- if (start >= end)
- return;
- printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- num_physpages++;
- totalram_pages++;
- }
+ num_physpages += free_reserved_area(start, end, 0, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 18/29] mm/ppc: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (16 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 17/29] mm/parisc: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 19/29] mm/s390: " Jiang Liu
` (10 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel,
Benjamin Herrenschmidt, Paul Mackerras, Anatolij Gustschin
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Anatolij Gustschin <agust@denx.de>
---
arch/powerpc/kernel/crash_dump.c | 5 +----
arch/powerpc/kernel/fadump.c | 5 +----
arch/powerpc/kernel/kvm.c | 7 +------
arch/powerpc/mm/mem.c | 29 ++------------------------
arch/powerpc/platforms/512x/mpc512x_shared.c | 5 +----
5 files changed, 6 insertions(+), 45 deletions(-)
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index b3ba516..9ec3fe1 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -150,10 +150,7 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
if (addr <= rtas_end && ((addr + PAGE_SIZE) > rtas_start))
continue;
- ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT));
- init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
- free_page((unsigned long)__va(addr));
- totalram_pages++;
+ free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
}
}
#endif
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 06c8202..2230fd0 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1045,10 +1045,7 @@ static void fadump_release_memory(unsigned long begin, unsigned long end)
if (addr <= ra_end && ((addr + PAGE_SIZE) > ra_start))
continue;
- ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT));
- init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
- free_page((unsigned long)__va(addr));
- totalram_pages++;
+ free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
}
}
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index a61b133..6782221 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -756,12 +756,7 @@ static __init void kvm_free_tmp(void)
end = (ulong)&kvm_tmp[ARRAY_SIZE(kvm_tmp)] & PAGE_MASK;
/* Free the tmp space we don't need */
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- }
+ free_reserved_area(start, end, 0, NULL);
}
static int __init kvm_guest_init(void)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index f1f7409..c756713 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -405,39 +405,14 @@ void __init mem_init(void)
void free_initmem(void)
{
- unsigned long addr;
-
ppc_md.progress = ppc_printk_progress;
-
- addr = (unsigned long)__init_begin;
- for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
- memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- pr_info("Freeing unused kernel memory: %luk freed\n",
- ((unsigned long)__init_end -
- (unsigned long)__init_begin) >> 10);
+ free_initmem_default(POISON_FREE_INITMEM);
}
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
- if (start >= end)
- return;
-
- start = _ALIGN_DOWN(start, PAGE_SIZE);
- end = _ALIGN_UP(end, PAGE_SIZE);
- pr_info("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
-
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- }
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index d30235b..db6ac38 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -172,12 +172,9 @@ static struct fsl_diu_shared_fb __attribute__ ((__aligned__(8))) diu_shared_fb;
static inline void mpc512x_free_bootmem(struct page *page)
{
- __ClearPageReserved(page);
BUG_ON(PageTail(page));
BUG_ON(atomic_read(&page->_count) > 1);
- atomic_set(&page->_count, 1);
- __free_page(page);
- totalram_pages++;
+ free_reserved_page(page);
}
void mpc512x_release_bootmem(void)
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 19/29] mm/s390: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (17 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 18/29] mm/ppc: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 20/29] mm/score: " Jiang Liu
` (9 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel,
Martin Schwidefsky, Heiko Carstens
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
---
arch/s390/mm/init.c | 35 ++++++-----------------------------
1 file changed, 6 insertions(+), 29 deletions(-)
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 49ce6bb..70bda9e 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -42,11 +42,10 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
unsigned long empty_zero_page, zero_page_mask;
EXPORT_SYMBOL(empty_zero_page);
-static unsigned long __init setup_zero_pages(void)
+static void __init setup_zero_pages(void)
{
struct cpuid cpu_id;
unsigned int order;
- unsigned long size;
struct page *page;
int i;
@@ -75,14 +74,11 @@ static unsigned long __init setup_zero_pages(void)
page = virt_to_page((void *) empty_zero_page);
split_page(page, order);
for (i = 1 << order; i > 0; i--) {
- SetPageReserved(page);
+ mark_page_reserved(page);
page++;
}
- size = PAGE_SIZE << order;
- zero_page_mask = (size - 1) & PAGE_MASK;
-
- return 1UL << order;
+ zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
}
/*
@@ -139,7 +135,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */
totalram_pages += free_all_bootmem();
- totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */
+ setup_zero_pages(); /* Setup zeroed pages. */
reservedpages = 0;
@@ -158,34 +154,15 @@ void __init mem_init(void)
PFN_ALIGN((unsigned long)&_eshared) - 1);
}
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
-{
- unsigned long addr = begin;
-
- if (begin >= end)
- return;
- for (; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- memset((void *)(addr & PAGE_MASK), POISON_FREE_INITMEM,
- PAGE_SIZE);
- free_page(addr);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
-}
-
void free_initmem(void)
{
- free_init_pages("unused kernel memory",
- (unsigned long)&__init_begin,
- (unsigned long)&__init_end);
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
- free_init_pages("initrd memory", start, end);
+ free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 20/29] mm/score: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (18 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 19/29] mm/s390: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 21/29] mm/SH: " Jiang Liu
` (8 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Chen Liqin,
Lennox Wu
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
---
arch/score/mm/init.c | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/arch/score/mm/init.c b/arch/score/mm/init.c
index cee6bce..1592aad 100644
--- a/arch/score/mm/init.c
+++ b/arch/score/mm/init.c
@@ -43,7 +43,7 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
static struct kcore_list kcore_mem, kcore_vmalloc;
-static unsigned long setup_zero_page(void)
+static void setup_zero_page(void)
{
struct page *page;
@@ -52,9 +52,7 @@ static unsigned long setup_zero_page(void)
panic("Oh boy, that early out of memory?");
page = virt_to_page((void *) empty_zero_page);
- SetPageReserved(page);
-
- return 1UL;
+ mark_page_reserved(page);
}
#ifndef CONFIG_NEED_MULTIPLE_NODES
@@ -84,7 +82,7 @@ void __init mem_init(void)
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
totalram_pages += free_all_bootmem();
- totalram_pages -= setup_zero_page(); /* Setup zeroed pages. */
+ setup_zero_page(); /* Setup zeroed pages. */
reservedpages = 0;
for (tmp = 0; tmp < max_low_pfn; tmp++)
@@ -109,37 +107,16 @@ void __init mem_init(void)
}
#endif /* !CONFIG_NEED_MULTIPLE_NODES */
-static void free_init_pages(const char *what, unsigned long begin, unsigned long end)
-{
- unsigned long pfn;
-
- for (pfn = PFN_UP(begin); pfn < PFN_DOWN(end); pfn++) {
- struct page *page = pfn_to_page(pfn);
- void *addr = phys_to_virt(PFN_PHYS(pfn));
-
- ClearPageReserved(page);
- init_page_count(page);
- memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
- __free_page(page);
- totalram_pages++;
- }
- printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
-}
-
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- free_init_pages("initrd memory",
- virt_to_phys((void *) start),
- virt_to_phys((void *) end));
+ free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
}
#endif
void __init_refok free_initmem(void)
{
- free_init_pages("unused kernel memory",
- __pa(&__init_begin),
- __pa(&__init_end));
+ free_initmem_default(POISON_FREE_INITMEM);
}
unsigned long pgd_current;
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 21/29] mm/SH: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (19 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 20/29] mm/score: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 22/29] mm/SPARC: " Jiang Liu
` (7 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
arch/sh/mm/init.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 1057940..20f9ead 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -417,15 +417,13 @@ void __init mem_init(void)
for_each_online_node(nid) {
pg_data_t *pgdat = NODE_DATA(nid);
- unsigned long node_pages = 0;
void *node_high_memory;
num_physpages += pgdat->node_present_pages;
if (pgdat->node_spanned_pages)
- node_pages = free_all_bootmem_node(pgdat);
+ totalram_pages += free_all_bootmem_node(pgdat);
- totalram_pages += node_pages;
node_high_memory = (void *)__va((pgdat->node_start_pfn +
pgdat->node_spanned_pages) <<
@@ -501,31 +499,13 @@ void __init mem_init(void)
void free_initmem(void)
{
- unsigned long addr;
-
- addr = (unsigned long)(&__init_begin);
- for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
- printk("Freeing unused kernel memory: %ldk freed\n",
- ((unsigned long)&__init_end -
- (unsigned long)&__init_begin) >> 10);
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- unsigned long p;
- for (p = start; p < end; p += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(p));
- init_page_count(virt_to_page(p));
- free_page(p);
- totalram_pages++;
- }
- printk("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 22/29] mm/SPARC: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (20 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 21/29] mm/SH: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 7:28 ` Sam Ravnborg
2013-03-10 6:27 ` [PATCH v2, part1 23/29] mm/um: " Jiang Liu
` (6 subsequent siblings)
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Sam Ravnborg
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
arch/sparc/kernel/leon_smp.c | 15 +++------------
arch/sparc/mm/init_32.c | 37 +++----------------------------------
arch/sparc/mm/init_64.c | 26 +++++---------------------
3 files changed, 11 insertions(+), 67 deletions(-)
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 9b40c9c..6cfc1b0 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -253,24 +253,15 @@ void __init leon_smp_done(void)
/* Free unneeded trap tables */
if (!cpu_present(1)) {
- ClearPageReserved(virt_to_page(&trapbase_cpu1));
- init_page_count(virt_to_page(&trapbase_cpu1));
- free_page((unsigned long)&trapbase_cpu1);
- totalram_pages++;
+ free_reserved_page(virt_to_page(&trapbase_cpu1));
num_physpages++;
}
if (!cpu_present(2)) {
- ClearPageReserved(virt_to_page(&trapbase_cpu2));
- init_page_count(virt_to_page(&trapbase_cpu2));
- free_page((unsigned long)&trapbase_cpu2);
- totalram_pages++;
+ free_reserved_page(virt_to_page(&trapbase_cpu2));
num_physpages++;
}
if (!cpu_present(3)) {
- ClearPageReserved(virt_to_page(&trapbase_cpu3));
- init_page_count(virt_to_page(&trapbase_cpu3));
- free_page((unsigned long)&trapbase_cpu3);
- totalram_pages++;
+ free_reserved_page(virt_to_page(&trapbase_cpu3));
num_physpages++;
}
/* Ok, they are spinning and ready to go. */
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index 48e0c03..13d6fee 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -374,45 +374,14 @@ void __init mem_init(void)
void free_initmem (void)
{
- unsigned long addr;
- unsigned long freed;
-
- addr = (unsigned long)(&__init_begin);
- freed = (unsigned long)(&__init_end) - addr;
- for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
- struct page *p;
-
- memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
- p = virt_to_page(addr);
-
- ClearPageReserved(p);
- init_page_count(p);
- __free_page(p);
- totalram_pages++;
- num_physpages++;
- }
- printk(KERN_INFO "Freeing unused kernel memory: %ldk freed\n",
- freed >> 10);
+ num_physpages += free_initmem_default(POISON_FREE_INITMEM);
}
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- if (start < end)
- printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
- (end - start) >> 10);
- for (; start < end; start += PAGE_SIZE) {
- struct page *p;
-
- memset((void *)start, POISON_FREE_INITMEM, PAGE_SIZE);
- p = virt_to_page(start);
-
- ClearPageReserved(p);
- init_page_count(p);
- __free_page(p);
- totalram_pages++;
- num_physpages++;
- }
+ num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM,
+ "initrd");
}
#endif
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 1588d33..3f559d1 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2060,8 +2060,7 @@ void __init mem_init(void)
/* We subtract one to account for the mem_map_zero page
* allocated below.
*/
- totalram_pages -= 1;
- num_physpages = totalram_pages;
+ num_physpages = totalram_pages - 1;
/*
* Set up the zero page, mark it reserved, so that page count
@@ -2072,7 +2071,7 @@ void __init mem_init(void)
prom_printf("paging_init: Cannot alloc zero page.\n");
prom_halt();
}
- SetPageReserved(mem_map_zero);
+ mark_page_reserved(mem_map_zero);
codepages = (((unsigned long) _etext) - ((unsigned long) _start));
codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
@@ -2112,7 +2111,6 @@ void free_initmem(void)
initend = (unsigned long)(__init_end) & PAGE_MASK;
for (; addr < initend; addr += PAGE_SIZE) {
unsigned long page;
- struct page *p;
page = (addr +
((unsigned long) __va(kern_base)) -
@@ -2120,13 +2118,8 @@ void free_initmem(void)
memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
if (do_free) {
- p = virt_to_page(page);
-
- ClearPageReserved(p);
- init_page_count(p);
- __free_page(p);
+ free_reserved_page(virt_to_page(page));
num_physpages++;
- totalram_pages++;
}
}
}
@@ -2134,17 +2127,8 @@ void free_initmem(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- if (start < end)
- printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
- for (; start < end; start += PAGE_SIZE) {
- struct page *p = virt_to_page(start);
-
- ClearPageReserved(p);
- init_page_count(p);
- __free_page(p);
- num_physpages++;
- totalram_pages++;
- }
+ num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM,
+ "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 23/29] mm/um: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (21 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 22/29] mm/SPARC: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 24/29] mm/unicore32: " Jiang Liu
` (5 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Jeff Dike
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Jeff Dike <jdike@addtoit.com>
---
arch/um/kernel/mem.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 5abcbfb..d5ac802 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -254,15 +254,7 @@ void free_initmem(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- if (start < end)
- printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
- (end - start) >> 10);
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- }
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 24/29] mm/unicore32: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (22 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 23/29] mm/um: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 25/29] mm/x86: " Jiang Liu
` (4 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Guan Xuetao
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
arch/unicore32/mm/init.c | 28 +++-------------------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index de186bd..c5817b0 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -313,24 +313,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;
-}
-
static inline void
free_memmap(unsigned long start_pfn, unsigned long end_pfn)
{
@@ -404,9 +386,9 @@ void __init mem_init(void)
max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
- /* this will put all unused low memory onto the freelists */
free_unused_memmap(&meminfo);
+ /* this will put all unused low memory onto the freelists */
totalram_pages += free_all_bootmem();
reserved_pages = free_pages = 0;
@@ -491,9 +473,7 @@ void __init mem_init(void)
void free_initmem(void)
{
- 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
@@ -503,9 +483,7 @@ static int keep_initrd;
void free_initrd_mem(unsigned long start, unsigned long end)
{
if (!keep_initrd)
- totalram_pages += free_area(__phys_to_pfn(__pa(start)),
- __phys_to_pfn(__pa(end)),
- "initrd");
+ free_reserved_area(start, end, 0, "initrd");
}
static int __init keepinitrd_setup(char *__unused)
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 25/29] mm/x86: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (23 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 24/29] mm/unicore32: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-13 5:38 ` Yasuaki Ishimatsu
2013-03-10 6:27 ` [PATCH v2, part1 26/29] mm/xtensa: " Jiang Liu
` (3 subsequent siblings)
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Thomas Gleixner,
Ingo Molnar, H. Peter Anvin
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/mm/init.c | 5 +----
arch/x86/mm/init_64.c | 5 ++---
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 4903a03..4a705e6 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -516,11 +516,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
for (; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
- free_page(addr);
- totalram_pages++;
+ free_reserved_page(virt_to_page(addr));
}
#endif
}
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 474e28f..2ef81f1 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1067,10 +1067,9 @@ void __init mem_init(void)
/* clear_bss() already clear the empty_zero_page */
- reservedpages = 0;
-
- /* this will put all low memory onto the freelists */
register_page_bootmem_info();
+
+ /* this will put all memory onto the freelists */
totalram_pages = free_all_bootmem();
absent_pages = absent_pages_in_range(0, max_pfn);
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 26/29] mm/xtensa: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (24 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 25/29] mm/x86: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 27/29] mm/arc: " Jiang Liu
` (2 subsequent siblings)
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Chris Zankel,
Max Filippov
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
---
arch/xtensa/mm/init.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index 7a5156f..bba125b 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -208,32 +208,17 @@ void __init mem_init(void)
highmemsize >> 10);
}
-void
-free_reserved_mem(void *start, void *end)
-{
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page((unsigned long)start);
- totalram_pages++;
- }
-}
-
#ifdef CONFIG_BLK_DEV_INITRD
extern int initrd_is_mapped;
void free_initrd_mem(unsigned long start, unsigned long end)
{
- if (initrd_is_mapped) {
- free_reserved_mem((void*)start, (void*)end);
- printk ("Freeing initrd memory: %ldk freed\n",(end-start)>>10);
- }
+ if (initrd_is_mapped)
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
void free_initmem(void)
{
- free_reserved_mem(__init_begin, __init_end);
- printk("Freeing unused kernel memory: %zuk freed\n",
- (__init_end - __init_begin) >> 10);
+ free_initmem_default(0);
}
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 27/29] mm/arc: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (25 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 26/29] mm/xtensa: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 28/29] mm/metag: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 29/29] mm,kexec: " Jiang Liu
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, linux-snps-arc
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Cc: linux-snps-arc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org (open list)
---
arch/arc/mm/init.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index caf797d..727d479 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -144,37 +144,18 @@ void __init mem_init(void)
PAGES_TO_KB(reserved_pages));
}
-static void __init free_init_pages(const char *what, unsigned long begin,
- unsigned long end)
-{
- unsigned long addr;
-
- pr_info("Freeing %s: %ldk [%lx] to [%lx]\n",
- what, TO_KB(end - begin), begin, end);
-
- /* need to check that the page we free is not a partial page */
- for (addr = begin; addr + PAGE_SIZE <= end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
-}
-
/*
* free_initmem: Free all the __init memory.
*/
void __init_refok free_initmem(void)
{
- free_init_pages("unused kernel memory",
- (unsigned long)__init_begin,
- (unsigned long)__init_end);
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
- free_init_pages("initrd memory", start, end);
+ free_reserved_area(start, end, 0, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 28/29] mm/metag: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (26 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 27/29] mm/arc: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 29/29] mm,kexec: " Jiang Liu
28 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, James Hogan
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-kernel@vger.kernel.org
---
arch/metag/mm/init.c | 21 ++-------------------
1 file changed, 2 insertions(+), 19 deletions(-)
diff --git a/arch/metag/mm/init.c b/arch/metag/mm/init.c
index 504a398..c6784fb 100644
--- a/arch/metag/mm/init.c
+++ b/arch/metag/mm/init.c
@@ -412,32 +412,15 @@ void __init mem_init(void)
return;
}
-static void free_init_pages(char *what, unsigned long begin, unsigned long end)
-{
- unsigned long addr;
-
- for (addr = begin; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
- free_page(addr);
- totalram_pages++;
- }
- pr_info("Freeing %s: %luk freed\n", what, (end - begin) >> 10);
-}
-
void free_initmem(void)
{
- free_init_pages("unused kernel memory",
- (unsigned long)(&__init_begin),
- (unsigned long)(&__init_end));
+ free_initmem_default(POISON_FREE_INITMEM);
}
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- end = end & PAGE_MASK;
- free_init_pages("initrd memory", start, end);
+ free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
}
#endif
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2, part1 29/29] mm,kexec: use common help functions to free reserved pages
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
` (27 preceding siblings ...)
2013-03-10 6:27 ` [PATCH v2, part1 28/29] mm/metag: " Jiang Liu
@ 2013-03-10 6:27 ` Jiang Liu
2013-03-11 5:16 ` Zhang Yanfei
28 siblings, 1 reply; 40+ messages in thread
From: Jiang Liu @ 2013-03-10 6:27 UTC (permalink / raw)
To: Andrew Morton, David Rientjes
Cc: Jiang Liu, Wen Congyang, Maciej Rutecki, Chris Clayton,
Rafael J . Wysocki, Mel Gorman, Minchan Kim, KAMEZAWA Hiroyuki,
Michal Hocko, Jianguo Wu, linux-mm, linux-kernel, Eric Biederman
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Eric Biederman <ebiederm@xmission.com>
---
kernel/kexec.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/kernel/kexec.c b/kernel/kexec.c
index bddd3d7..be95397 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1118,12 +1118,8 @@ void __weak crash_free_reserved_phys_range(unsigned long begin,
{
unsigned long addr;
- for (addr = begin; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT));
- init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
- free_page((unsigned long)__va(addr));
- totalram_pages++;
- }
+ for (addr = begin; addr < end; addr += PAGE_SIZE)
+ free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
}
int crash_shrink_memory(unsigned long new_size)
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 22/29] mm/SPARC: use common help functions to free reserved pages
2013-03-10 6:27 ` [PATCH v2, part1 22/29] mm/SPARC: " Jiang Liu
@ 2013-03-10 7:28 ` Sam Ravnborg
0 siblings, 0 replies; 40+ messages in thread
From: Sam Ravnborg @ 2013-03-10 7:28 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel
On Sun, Mar 10, 2013 at 02:27:05PM +0800, Jiang Liu wrote:
> Use common help functions to free reserved pages.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Acked-by: David S. Miller <davem@davemloft.net>
> Cc: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages
2013-03-10 6:26 ` [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
@ 2013-03-10 9:20 ` Geert Uytterhoeven
2013-03-11 22:17 ` Jiang Liu
0 siblings, 1 reply; 40+ messages in thread
From: Geert Uytterhoeven @ 2013-03-10 9:20 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
Anatolij Gustschin, Aurelien Jacquiot, Benjamin Herrenschmidt,
Catalin Marinas, Chen Liqin, Chris Metcalf, Chris Zankel,
David Howells, David S. Miller, Eric Biederman, Fenghua Yu,
Guan Xuetao, Haavard Skinnemoen, Hans-Christian Egtvedt,
Heiko Carstens, Helge Deller, James Hogan, Hirokazu Takata,
H. Peter Anvin, Ingo Molnar, Ivan Kokshaysky,
James E.J. Bottomley, Jeff Dike, Jeremy Fitzhardinge, Jonas Bonn,
Koichi Yasutake, Konrad Rzeszutek Wilk, Lennox Wu, Mark Salter,
Martin Schwidefsky, Matt Turner, Max Filippov, Michael S. Tsirkin,
Michal Simek, Michel Lespinasse, Mikael Starvik, Mike Frysinger,
Paul Mackerras, Paul Mundt, Ralf Baechle, Richard Henderson,
Rik van Riel, Russell King, Rusty Russell, Sam Ravnborg,
Tang Chen, Thomas Gleixner, Tony Luck, Will Deacon,
Yasuaki Ishimatsu, Yinghai Lu, Yoshinori Sato, x86, xen-devel,
linux-kernel, linux-mm, linux-arm-kernel, Vineet Gupta,
linux-snps-arc, virtualization
On Sun, Mar 10, 2013 at 7:26 AM, Jiang Liu <liuj97@gmail.com> wrote:
> Code to deal with reserved/managed pages are duplicated by many
> architectures, so introduce common help functions to reduce duplicated
> code. These common help functions will also be used to concentrate code
> to modify totalram_pages and zone->managed_pages, which makes the code
> much more clear.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
I have a few minor comments (see below), but apart from that:
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> mm/page_alloc.c | 20 ++++++++++++++++++++
> 2 files changed, 68 insertions(+)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 7acc9dc..d75c14b 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1295,6 +1295,54 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
> unsigned long zone_start_pfn, unsigned long *zholes_size);
> extern void free_initmem(void);
>
> +/*
> + * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK)
> + * into the buddy system. The freed pages will be poisoned with pattern
> + * "poison" if it's non-zero.
What if you want to poison with zero?
As poison is a full int, but memset only uses the least-significant
byte, you can
change it to poison if it's positive (i.e. >= 0)?
> +/*
> + * Default method to free all the __init memory into the buddy system.
> + * The freed pages will be poisoned with pattern "poison" if it is
> + * non-zero. Return pages freed into the buddy system.
> + */
> +static inline unsigned long free_initmem_default(int poison)
> +{
> + extern char __init_begin[], __init_end[];
> +
> + return free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) ,
> + ((unsigned long)&__init_end) & PAGE_MASK,
The "PAGE_ALIGN(...)" and "& PAGE_MASK" are superfluous, as
free_reserved_area() already does that.
> + poison, "unused kernel");
> +}
> +
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 8fcced7..0fadb09 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5113,6 +5113,26 @@ early_param("movablecore", cmdline_parse_movablecore);
>
> #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
>
> +unsigned long free_reserved_area(unsigned long start, unsigned long end,
> + int poison, char *s)
> +{
> + if (pages && s)
> + pr_info("Freeing %s memory: %ldK (%lx - %lx)\n",
"%luKiB (0x%lx - 0x%lx)"?
> + s, pages << (PAGE_SHIFT - 10), start, end);
> +
> + return pages;
> +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 12/29] mm/m68k: use common help functions to free reserved pages
2013-03-10 6:26 ` [PATCH v2, part1 12/29] mm/m68k: " Jiang Liu
@ 2013-03-10 9:21 ` Geert Uytterhoeven
0 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2013-03-10 9:21 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel
On Sun, Mar 10, 2013 at 7:26 AM, Jiang Liu <liuj97@gmail.com> wrote:
> Use common help functions to free reserved pages.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
24 bytes of text size saved!
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 29/29] mm,kexec: use common help functions to free reserved pages
2013-03-10 6:27 ` [PATCH v2, part1 29/29] mm,kexec: " Jiang Liu
@ 2013-03-11 5:16 ` Zhang Yanfei
0 siblings, 0 replies; 40+ messages in thread
From: Zhang Yanfei @ 2013-03-11 5:16 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel, Eric Biederman
于 2013年03月10日 14:27, Jiang Liu 写道:
> Use common help functions to free reserved pages.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Eric Biederman <ebiederm@xmission.com>
Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> ---
> kernel/kexec.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index bddd3d7..be95397 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -1118,12 +1118,8 @@ void __weak crash_free_reserved_phys_range(unsigned long begin,
> {
> unsigned long addr;
>
> - for (addr = begin; addr < end; addr += PAGE_SIZE) {
> - ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT));
> - init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
> - free_page((unsigned long)__va(addr));
> - totalram_pages++;
> - }
> + for (addr = begin; addr < end; addr += PAGE_SIZE)
> + free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
> }
>
> int crash_shrink_memory(unsigned long new_size)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages
2013-03-10 9:20 ` Geert Uytterhoeven
@ 2013-03-11 22:17 ` Jiang Liu
0 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-11 22:17 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
Anatolij Gustschin, Aurelien Jacquiot, Benjamin Herrenschmidt,
Catalin Marinas, Chen Liqin, Chris Metcalf, Chris Zankel,
David Howells, David S. Miller, Eric Biederman, Fenghua Yu,
Guan Xuetao, Haavard Skinnemoen, Hans-Christian Egtvedt,
Heiko Carstens, Helge Deller, James Hogan, Hirokazu Takata,
H. Peter Anvin, Ingo Molnar, Ivan Kokshaysky,
James E.J. Bottomley, Jeff Dike, Jeremy Fitzhardinge, Jonas Bonn,
Koichi Yasutake, Konrad Rzeszutek Wilk, Lennox Wu, Mark Salter,
Martin Schwidefsky, Matt Turner, Max Filippov, Michael S. Tsirkin,
Michal Simek, Michel Lespinasse, Mikael Starvik, Mike Frysinger,
Paul Mackerras, Paul Mundt, Ralf Baechle, Richard Henderson,
Rik van Riel, Russell King, Rusty Russell, Sam Ravnborg,
Tang Chen, Thomas Gleixner, Tony Luck, Will Deacon,
Yasuaki Ishimatsu, Yinghai Lu, Yoshinori Sato, x86, xen-devel,
linux-kernel, linux-mm, linux-arm-kernel, Vineet Gupta,
linux-snps-arc, virtualization
Hi Geert,
Thanks for review!
On 03/10/2013 05:20 PM, Geert Uytterhoeven wrote:
> On Sun, Mar 10, 2013 at 7:26 AM, Jiang Liu <liuj97@gmail.com> wrote:
>> Code to deal with reserved/managed pages are duplicated by many
>> architectures, so introduce common help functions to reduce duplicated
>> code. These common help functions will also be used to concentrate code
>> to modify totalram_pages and zone->managed_pages, which makes the code
>> much more clear.
>>
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>
> I have a few minor comments (see below), but apart from that:
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
>> ---
>> include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>> mm/page_alloc.c | 20 ++++++++++++++++++++
>> 2 files changed, 68 insertions(+)
>>
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index 7acc9dc..d75c14b 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -1295,6 +1295,54 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
>> unsigned long zone_start_pfn, unsigned long *zholes_size);
>> extern void free_initmem(void);
>>
>> +/*
>> + * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK)
>> + * into the buddy system. The freed pages will be poisoned with pattern
>> + * "poison" if it's non-zero.
>
> What if you want to poison with zero?
> As poison is a full int, but memset only uses the least-significant
> byte, you can
> change it to poison if it's positive (i.e. >= 0)?
Good point, ARM64 does poison memory with 0. Will implement that way in next version.
>
>> +/*
>> + * Default method to free all the __init memory into the buddy system.
>> + * The freed pages will be poisoned with pattern "poison" if it is
>> + * non-zero. Return pages freed into the buddy system.
>> + */
>> +static inline unsigned long free_initmem_default(int poison)
>> +{
>> + extern char __init_begin[], __init_end[];
>> +
>> + return free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) ,
>> + ((unsigned long)&__init_end) & PAGE_MASK,
>
> The "PAGE_ALIGN(...)" and "& PAGE_MASK" are superfluous, as
> free_reserved_area() already does that.
Will remove the redundant ops next version.
>
>> + poison, "unused kernel");
>> +}
>> +
>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 8fcced7..0fadb09 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -5113,6 +5113,26 @@ early_param("movablecore", cmdline_parse_movablecore);
>>
>> #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
>>
>> +unsigned long free_reserved_area(unsigned long start, unsigned long end,
>> + int poison, char *s)
>> +{
>
>> + if (pages && s)
>> + pr_info("Freeing %s memory: %ldK (%lx - %lx)\n",
>
> "%luKiB (0x%lx - 0x%lx)"?
Sure.
Regards!
Gerry
>
>> + s, pages << (PAGE_SHIFT - 10), start, end);
>> +
>> + return pages;
>> +}
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 25/29] mm/x86: use common help functions to free reserved pages
2013-03-10 6:27 ` [PATCH v2, part1 25/29] mm/x86: " Jiang Liu
@ 2013-03-13 5:38 ` Yasuaki Ishimatsu
2013-03-13 16:45 ` Jiang Liu
0 siblings, 1 reply; 40+ messages in thread
From: Yasuaki Ishimatsu @ 2013-03-13 5:38 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin
Hi Jiang,
2013/03/10 15:27, Jiang Liu wrote:
> Use common help functions to free reserved pages.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> ---
> arch/x86/mm/init.c | 5 +----
> arch/x86/mm/init_64.c | 5 ++---
> 2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> index 4903a03..4a705e6 100644
> --- a/arch/x86/mm/init.c
> +++ b/arch/x86/mm/init.c
> @@ -516,11 +516,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
> printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
>
> for (; addr < end; addr += PAGE_SIZE) {
> - ClearPageReserved(virt_to_page(addr));
> - init_page_count(virt_to_page(addr));
> memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
> - free_page(addr);
> - totalram_pages++;
> + free_reserved_page(virt_to_page(addr));
> }
If I don't misread your code, avobe codes can replace to free_reserved_area()
as follow:
free_reserved_area(addr, end, POISON_FREE_INITMEM, what)
Am I wrong?
Thanks,
Yasuaki Ishimatsu
> #endif
> }
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 474e28f..2ef81f1 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1067,10 +1067,9 @@ void __init mem_init(void)
>
> /* clear_bss() already clear the empty_zero_page */
>
> - reservedpages = 0;
> -
> - /* this will put all low memory onto the freelists */
> register_page_bootmem_info();
> +
> + /* this will put all memory onto the freelists */
> totalram_pages = free_all_bootmem();
>
> absent_pages = absent_pages_in_range(0, max_pfn);
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 25/29] mm/x86: use common help functions to free reserved pages
2013-03-13 5:38 ` Yasuaki Ishimatsu
@ 2013-03-13 16:45 ` Jiang Liu
0 siblings, 0 replies; 40+ messages in thread
From: Jiang Liu @ 2013-03-13 16:45 UTC (permalink / raw)
To: Yasuaki Ishimatsu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin
On 03/13/2013 01:38 PM, Yasuaki Ishimatsu wrote:
> Hi Jiang,
>
> 2013/03/10 15:27, Jiang Liu wrote:
>> Use common help functions to free reserved pages.
>>
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: "H. Peter Anvin" <hpa@zytor.com>
>> ---
>> arch/x86/mm/init.c | 5 +----
>> arch/x86/mm/init_64.c | 5 ++---
>> 2 files changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
>> index 4903a03..4a705e6 100644
>> --- a/arch/x86/mm/init.c
>> +++ b/arch/x86/mm/init.c
>> @@ -516,11 +516,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
>
>> printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
>>
>> for (; addr < end; addr += PAGE_SIZE) {
>> - ClearPageReserved(virt_to_page(addr));
>> - init_page_count(virt_to_page(addr));
>> memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
>> - free_page(addr);
>> - totalram_pages++;
>> + free_reserved_page(virt_to_page(addr));
>> }
>
> If I don't misread your code, avobe codes can replace to free_reserved_area()
> as follow:
>
> free_reserved_area(addr, end, POISON_FREE_INITMEM, what)
>
> Am I wrong?
Hi Yasuaki,
Good catch, will enhance it in following patches.
Thanks!
>
> Thanks,
> Yasuaki Ishimatsu
>
>> #endif
>> }
>> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
>> index 474e28f..2ef81f1 100644
>> --- a/arch/x86/mm/init_64.c
>> +++ b/arch/x86/mm/init_64.c
>> @@ -1067,10 +1067,9 @@ void __init mem_init(void)
>>
>> /* clear_bss() already clear the empty_zero_page */
>>
>> - reservedpages = 0;
>> -
>> - /* this will put all low memory onto the freelists */
>> register_page_bootmem_info();
>> +
>> + /* this will put all memory onto the freelists */
>> totalram_pages = free_all_bootmem();
>>
>> absent_pages = absent_pages_in_range(0, max_pfn);
>>
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2, part1 16/29] mm/openrisc: use common help functions to free reserved pages
2013-03-10 6:26 ` [PATCH v2, part1 16/29] mm/openrisc: " Jiang Liu
@ 2013-04-02 5:31 ` Jonas Bonn
0 siblings, 0 replies; 40+ messages in thread
From: Jonas Bonn @ 2013-04-02 5:31 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel@vger.kernel.org
On 10 March 2013 07:26, Jiang Liu <liuj97@gmail.com> wrote:
> Use common help functions to free reserved pages.
> Also include <asm/sections.h> to avoid local declarations.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Jonas Bonn <jonas@southpole.se>
Tested and works fine on OpenRISC.
Acked-by: Jonas Bonn <jonas@southpole.se>
/Jonas
> ---
> arch/openrisc/mm/init.c | 27 +++------------------------
> 1 file changed, 3 insertions(+), 24 deletions(-)
>
> diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c
> index e7fdc50..b3cbc67 100644
> --- a/arch/openrisc/mm/init.c
> +++ b/arch/openrisc/mm/init.c
> @@ -43,6 +43,7 @@
> #include <asm/kmap_types.h>
> #include <asm/fixmap.h>
> #include <asm/tlbflush.h>
> +#include <asm/sections.h>
>
> int mem_init_done;
>
> @@ -201,9 +202,6 @@ void __init paging_init(void)
>
> /* References to section boundaries */
>
> -extern char _stext, _etext, _edata, __bss_start, _end;
> -extern char __init_begin, __init_end;
> -
> static int __init free_pages_init(void)
> {
> int reservedpages, pfn;
> @@ -263,30 +261,11 @@ void __init mem_init(void)
> #ifdef CONFIG_BLK_DEV_INITRD
> void free_initrd_mem(unsigned long start, unsigned long end)
> {
> - printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
> - (end - start) >> 10);
> -
> - for (; start < end; start += PAGE_SIZE) {
> - ClearPageReserved(virt_to_page(start));
> - init_page_count(virt_to_page(start));
> - free_page(start);
> - totalram_pages++;
> - }
> + free_reserved_area(start, end, 0, "initrd");
> }
> #endif
>
> void free_initmem(void)
> {
> - unsigned long addr;
> -
> - addr = (unsigned long)(&__init_begin);
> - for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
> - ClearPageReserved(virt_to_page(addr));
> - init_page_count(virt_to_page(addr));
> - free_page(addr);
> - totalram_pages++;
> - }
> - printk(KERN_INFO "Freeing unused kernel memory: %luk freed\n",
> - ((unsigned long)&__init_end -
> - (unsigned long)&__init_begin) >> 10);
> + free_initmem_default(0);
> }
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [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: " Jiang Liu
@ 2013-04-04 15:47 ` Arnd Bergmann
2013-04-06 14:07 ` Jiang Liu
0 siblings, 1 reply; 40+ messages in thread
From: Arnd Bergmann @ 2013-04-04 15:47 UTC (permalink / raw)
To: Jiang Liu
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel, Russell King, Catalin Marinas,
Will Deacon, 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@lists.infradead.org
> Cc: linux-kernel@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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [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; 40+ messages in thread
From: Jiang Liu @ 2013-04-06 14:07 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andrew Morton, David Rientjes, Jiang Liu, Wen Congyang,
Maciej Rutecki, Chris Clayton, Rafael J . Wysocki, Mel Gorman,
Minchan Kim, KAMEZAWA Hiroyuki, Michal Hocko, Jianguo Wu,
linux-mm, linux-kernel, Russell King, Catalin Marinas,
Will Deacon, 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@lists.infradead.org
>> Cc: linux-kernel@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@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2013-04-06 14:07 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-10 6:26 [PATCH v2, part1 00/29] Use helper functions to simplify memory intialization code Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
2013-03-10 9:20 ` Geert Uytterhoeven
2013-03-11 22:17 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 02/29] mm/alpha: use common help functions to free reserved pages Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 03/29] mm/ARM: " Jiang Liu
2013-04-04 15:47 ` Arnd Bergmann
2013-04-06 14:07 ` Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 04/29] mm/avr32: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 05/29] mm/blackfin: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 06/29] mm/c6x: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 07/29] mm/cris: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 08/29] mm/FRV: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 09/29] mm/h8300: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 10/29] mm/IA64: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 11/29] mm/m32r: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 12/29] mm/m68k: " Jiang Liu
2013-03-10 9:21 ` Geert Uytterhoeven
2013-03-10 6:26 ` [PATCH v2, part1 13/29] mm/microblaze: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 14/29] mm/MIPS: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 15/29] mm/mn10300: " Jiang Liu
2013-03-10 6:26 ` [PATCH v2, part1 16/29] mm/openrisc: " Jiang Liu
2013-04-02 5:31 ` Jonas Bonn
2013-03-10 6:27 ` [PATCH v2, part1 17/29] mm/parisc: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 18/29] mm/ppc: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 19/29] mm/s390: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 20/29] mm/score: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 21/29] mm/SH: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 22/29] mm/SPARC: " Jiang Liu
2013-03-10 7:28 ` Sam Ravnborg
2013-03-10 6:27 ` [PATCH v2, part1 23/29] mm/um: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 24/29] mm/unicore32: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 25/29] mm/x86: " Jiang Liu
2013-03-13 5:38 ` Yasuaki Ishimatsu
2013-03-13 16:45 ` Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 26/29] mm/xtensa: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 27/29] mm/arc: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 28/29] mm/metag: " Jiang Liu
2013-03-10 6:27 ` [PATCH v2, part1 29/29] mm,kexec: " Jiang Liu
2013-03-11 5:16 ` Zhang Yanfei
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).