Use helper functions to simplify memory intialization code
Subsystems (25)
v2 cover Use helper functions to simplify memory intialization code
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 infofree_reserved_page():
free a reserved page into the buddy system and adjust page statistics infomark_page_reserved():
mark a page as reserved and adjust page statistics infofree_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(-)
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 1/29 mm: introduce common help functions to deal with reserved/managed pages
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.
--- include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 20 ++++++++++++++++++++ 2 files changed, 68 insertions(+)
include/linux/mm.h +48 -0
@@ -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
mm/page_alloc.c +20 -0
@@ -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
Signature · 1 line
1.7.9.5
Re: [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages
Quoted 7 lines · Jiang Liu
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_pagesandzone->managed_pages, which makes the code much more clear.Signed-off-by Jiang Liu <[email protected]>
I have a few minor comments (see below), but apart from that:
Quoted 10 lines
--- include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 20 ++++++++++++++++++++ 2 files changed, 68 insertions(+)include/linux/mm.h +0
-0
include/linux/mm.h extern void free_area_init_node(int nid, unsigned long * zones_size, · line 1301
Quoted 7 lines
include/linux/mm.h +4
-0@@ -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)?
include/linux/mm.h extern void free_area_init_node(int nid, unsigned long * zones_size, · line 1342
Quoted 11 lines
include/linux/mm.h +11
-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.
Quoted 9 lines
include/linux/mm.h +3
-0+ poison, "unused kernel"); +} +mm/page_alloc.c +0
-0
mm/page_alloc.c early_param("movablecore", cmdline_parse_movablecore); · line 5121
Quoted 9 lines
mm/page_alloc.c +5
-0@@ -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)"?
mm/page_alloc.c early_param("movablecore", cmdline_parse_movablecore); · line 5134
Quoted 4 lines
mm/page_alloc.c +4
-0+ s, pages << (PAGE_SHIFT - 10), start, end); + +return pages; +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages
Hi Geert,
Thanks for review!
Quoted 25 lines · Geert Uytterhoeven
Quoted 7 lines · Jiang Liu
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_pagesandzone->managed_pages, which makes the code much more clear.Signed-off-by Jiang Liu <[email protected]>I have a few minor comments (see below), but apart from that:
Quoted 13 lines
--- include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 20 ++++++++++++++++++++ 2 files changed, 68 insertions(+)include/linux/mm.h +0
-0@@ -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 );
Quoted 9 lines
include/linux/mm.h extern void free_area_init_node(int nid, unsigned long * zones_size, · line 1301
Quoted 4 lines
include/linux/mm.h +4
-0+/* +* 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.
Quoted 15 lines
include/linux/mm.h extern void free_area_init_node(int nid, unsigned long * zones_size, · line 1342
Quoted 12 lines
include/linux/mm.h +11
-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, asfree_reserved_area()already does that.
Will remove the redundant ops next version.
Quoted 13 lines
Quoted 13 lines
include/linux/mm.h +3
-0+ poison, "unused kernel"); +} +mm/page_alloc.c +0
-0@@ -5113,6 +5113,26 @@ early_param("movablecore", cmdline_parse_movablecore);#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
Quoted 8 lines
mm/page_alloc.c early_param("movablecore", cmdline_parse_movablecore); · line 5130
Quoted 6 lines
mm/page_alloc.c +5
-0+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
Quoted 17 lines
mm/page_alloc.c early_param("movablecore", cmdline_parse_movablecore); · line 5134
Quoted 5 lines
mm/page_alloc.c +4
-0+ s, pages << (PAGE_SHIFT - 10), start, end); + +return pages; +}Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]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
Re: [PATCH v2, part1 01/29] mm: introduce common help functions to deal with reserved/managed pages
In reply to Jiang LiuQuoted 7 lines · Jiang Liu
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_pagesandzone->managed_pages, which makes the code much more clear.Signed-off-by Jiang Liu <[email protected]>
I have a few minor comments (see below), but apart from that:
Quoted 10 lines
--- include/linux/mm.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 20 ++++++++++++++++++++ 2 files changed, 68 insertions(+)include/linux/mm.h +0
-0
include/linux/mm.h extern void free_area_init_node(int nid, unsigned long * zones_size, · line 1301
Quoted 7 lines
include/linux/mm.h +4
-0@@ -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)?
include/linux/mm.h extern void free_area_init_node(int nid, unsigned long * zones_size, · line 1342
Quoted 11 lines
include/linux/mm.h +11
-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.
Quoted 9 lines
include/linux/mm.h +3
-0+ poison, "unused kernel"); +} +mm/page_alloc.c +0
-0
mm/page_alloc.c early_param("movablecore", cmdline_parse_movablecore); · line 5121
Quoted 9 lines
mm/page_alloc.c +5
-0@@ -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)"?
mm/page_alloc.c early_param("movablecore", cmdline_parse_movablecore); · line 5134
Quoted 4 lines
mm/page_alloc.c +4
-0+ s, pages << (PAGE_SHIFT - 10), start, end); + +return pages; +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
PATCH v2 2/29 mm/alpha: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages. Also include <asm/sections.h> to avoid local declarations.
--- 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(-)
arch/alpha/kernel/sys_nautilus.c +2 -3
@@ -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 ); }
arch/alpha/mm/init.c +3 -21
@@ -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
arch/alpha/mm/numa.c +1 -2
@@ -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 );
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 3/29 mm/ARM: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/arm/mm/init.c | 48 ++++++++++++++++-------------------------------- arch/arm64/mm/init.c | 26 ++------------------------ 2 files changed, 18 insertions(+), 56 deletions(-)
arch/arm/mm/init.c +16 -32
@@ -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" ); } }
arch/arm64/mm/init.c +2 -24
@@ -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" ); } }
Signature · 1 line
1.7.9.5
Re: [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages
Quoted 8 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Cc Russell King <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.org
Hello Jiang Liu,
I'm getting a few new build warnings from this patch in linux-next, can you please have a look what's going on here?
arch/arm/mm/init.c void __init mem_init(void) · line 604
Quoted 8 lines
arch/arm/mm/init.c +1
-2@@ -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,
^arch/arm/mm/init.c void free_initmem(void) · line 732
Quoted 9 lines
arch/arm/mm/init.c +1
-3@@ -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,
^
ArndRe: [PATCH v2, part1 03/29] mm/ARM: use common help functions to free reserved pages
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
Quoted 65 lines · Arnd Bergmann
Quoted 8 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Cc Russell King <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgHello 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?
arch/arm/mm/init.c void __init mem_init(void) · line 604
Quoted 8 lines
arch/arm/mm/init.c +1
-2@@ -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 frominclude/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, ^arch/arm/mm/init.c void free_initmem(void) · line 732
Quoted 9 lines
arch/arm/mm/init.c +1
-3@@ -738,16 +728,12 @@ void free_initmem(void)extern char __tcm_start, __tcm_end;poison_init_mem (&__tcm_start, &__tcm_end - &__tcm_start); - totalram_pages +=free_area (__phys_to_pfn (__pa (&__tcm_start)), -__phys_to_pfn (__pa (&__tcm_end)), -"TCM link" ); +free_reserved_area (&__tcm_start, &__tcm_end,0 ,"TCM link" );#endif Using one of {realview,s3c6400,u300}_defconfig:
/git/arm-soc/arch/arm/mm/init.c: In function '
free_initmem':
/git/arm-soc/arch/arm/mm/init.c:731:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default]
free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
^
In file included from /git/arm-soc/include/linux/mman.h:4:0,from /git/arm-soc/arch/arm/mm/init.c:15: /git/arm-soc/include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'char *' extern unsigned long free_reserved_area(unsigned long start, unsigned long end, ^ Arnd--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH v2 4/29 mm/avr32: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/avr32/mm/init.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
arch/avr32/mm/init.c +2 -22
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 5/29 mm/blackfin: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/blackfin/mm/init.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
arch/blackfin/mm/init.c +3 -19
@@ -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 definedCONFIG_RAMKERNEL && !definedCONFIG_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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 6/29 mm/c6x: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/c6x/mm/init.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-)
arch/c6x/mm/init.c +2 -28
@@ -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 ); }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 7/29 mm/cris: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages. Also include <asm/sections.h> to avoid local declaration.
--- arch/cris/mm/init.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
arch/cris/mm/init.c +2 -14
@@ -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 ); }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 8/29 mm/FRV: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/frv/mm/init.c | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-)
arch/frv/mm/init.c +4 -30
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 9/29 mm/h8300: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/h8300/mm/init.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
arch/h8300/mm/init.c +3 -27
@@ -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 @@ voidfree_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 }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 10/29 mm/IA64: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/ia64/mm/init.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
arch/ia64/mm/init.c +4 -19
@@ -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)); } }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 11/29 mm/m32r: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages. Also include <asm/sections.h> to avoid local declarations.
--- arch/m32r/mm/init.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
arch/m32r/mm/init.c +3 -23
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 12/29 mm/m68k: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/m68k/mm/init.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
arch/m68k/mm/init.c +2 -22
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 12/29] mm/m68k: use common help functions to free reserved pages
Quoted 4 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Cc Geert Uytterhoeven <[email protected]>
24 bytes of text size saved!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 13/29 mm/microblaze: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/microblaze/include/asm/setup.h | 1 - arch/microblaze/mm/init.c | 28 ++-------------------------- 2 files changed, 2 insertions(+), 27 deletions(-)
arch/microblaze/include/asm/setup.h +0 -1
@@ -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);
arch/microblaze/mm/init.c +2 -26
@@ -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 )
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 14/29 mm/MIPS: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/mips/mm/init.c | 31 +++++++++---------------------- arch/mips/sgi-ip27/ip27-memory.c | 4 ++-- 2 files changed, 11 insertions(+), 24 deletions(-)
arch/mips/mm/init.c +9 -22
@@ -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
arch/mips/sgi-ip27/ip27-memory.c +2 -2
@@ -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;
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 15/29 mm/mn10300: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/mn10300/mm/init.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
arch/mn10300/mm/init.c +2 -21
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 16/29 mm/openrisc: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages. Also include <asm/sections.h> to avoid local declarations.
--- arch/openrisc/mm/init.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-)
arch/openrisc/mm/init.c +3 -24
@@ -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 ); }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 16/29] mm/openrisc: use common help functions to free reserved pages
Quoted 5 lines · Jiang Liu
Use common help functions to free reserved pages. Also include <
asm/sections.h> to avoid local declarations.Signed-off-by Jiang Liu <[email protected]>Cc Jonas Bonn <[email protected]>
Tested and works fine on OpenRISC.
/Jonas
Quoted 62 lines
--- arch/openrisc/mm/init.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-)arch/openrisc/mm/init.c +3
-25@@ -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
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 17/29 mm/parisc: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/parisc/mm/init.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
arch/parisc/mm/init.c +2 -21
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 18/29 mm/ppc: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- 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(-)
arch/powerpc/kernel/crash_dump.c +1 -4
@@ -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
arch/powerpc/kernel/fadump.c +1 -4
@@ -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 )); } }
arch/powerpc/kernel/kvm.c +1 -6
@@ -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 )
arch/powerpc/mm/mem.c +2 -27
@@ -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
arch/powerpc/platforms/512x/mpc512x_shared.c +1 -4
@@ -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 )
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 19/29 mm/s390: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/s390/mm/init.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-)
arch/s390/mm/init.c +6 -29
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 20/29 mm/score: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/score/mm/init.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-)
arch/score/mm/init.c +5 -28
@@ -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;
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 21/29 mm/SH: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/sh/mm/init.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
arch/sh/mm/init.c +3 -23
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 22/29 mm/SPARC: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- 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(-)
arch/sparc/kernel/leon_smp.c +3 -12
@@ -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. */
arch/sparc/mm/init_32.c +3 -34
@@ -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
arch/sparc/mm/init_64.c +5 -21
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 22/29] mm/SPARC: use common help functions to free reserved pages
Quoted 5 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Acked-by David S. Miller <[email protected]>Cc Sam Ravnborg <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 23/29 mm/um: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/um/kernel/mem.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
arch/um/kernel/mem.c +1 -9
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 24/29 mm/unicore32: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/unicore32/mm/init.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-)
arch/unicore32/mm/init.c +3 -25
@@ -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)
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 25/29 mm/x86: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/x86/mm/init.c | 5 +---- arch/x86/mm/init_64.c | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-)
arch/x86/mm/init.c +1 -4
@@ -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 }
arch/x86/mm/init_64.c +2 -3
@@ -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);
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 25/29] mm/x86: use common help functions to free reserved pages
Hi Jiang,
Quoted 17 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>--- arch/x86/mm/init.c | 5 +---- arch/x86/mm/init_64.c | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-)arch/x86/mm/init.c +0
-0@@ -516,11 +516,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
arch/x86/mm/init.c void free_init_pages(char *what, unsigned long begin, unsigned long end) · line 522
Quoted 10 lines
arch/x86/mm/init.c +1
-4printk (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
Quoted 10 lines
arch/x86/mm/init.c +0
-0#endif }arch/x86/mm/init_64.c +0
-0@@ -1067,10 +1067,9 @@ void __init mem_init(void)/* clear_bss() already clear the empty_zero_page */
arch/x86/mm/init_64.c void __init mem_init(void) · line 1075
Quoted 10 lines
arch/x86/mm/init_64.c +2
-3- 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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 25/29] mm/x86: use common help functions to free reserved pages
Quoted 34 lines · Yasuaki Ishimatsu
Hi Jiang,
Quoted 17 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>--- arch/x86/mm/init.c | 5 +---- arch/x86/mm/init_64.c | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-)arch/x86/mm/init.c +0
-0@@ -516,11 +516,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)arch/x86/mm/init.c void free_init_pages(char *what, unsigned long begin, unsigned long end) · line 522
Quoted 10 lines
arch/x86/mm/init.c +1
-4printk (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:
Quoted 3 lines
free_reserved_area(addr, end, POISON_FREE_INITMEM, what)Am I wrong?
Hi Yasuaki,
Good catch, will enhance it in following patches. Thanks!
Quoted 22 lines
Thanks,
Yasuaki IshimatsuQuoted 18 lines
arch/x86/mm/init.c +0
-0#endif }arch/x86/mm/init_64.c +2
-3@@ -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 ();
Quoted 4 lines
arch/x86/mm/init_64.c void __init mem_init(void) · line 1075
Quoted 2 lines
arch/x86/mm/init_64.c +0
-0absent_pages =absent_pages_in_range (0 , max_pfn);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 26/29 mm/xtensa: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/xtensa/mm/init.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
arch/xtensa/mm/init.c +3 -18
@@ -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 ); }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 27/29 mm/arc: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/arc/mm/init.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
arch/arc/mm/init.c +2 -21
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 28/29 mm/metag: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- arch/metag/mm/init.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
arch/metag/mm/init.c +2 -19
@@ -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
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 29/29 mm,kexec: use common help functions to free reserved pages
In reply to Jiang LiuUse common help functions to free reserved pages.
--- kernel/kexec.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/kexec.c +2 -6
@@ -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)
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2, part1 29/29] mm,kexec: use common help functions to free reserved pages
Quoted 4 lines · Jiang Liu
Use common help functions to free reserved pages.
Signed-off-by Jiang Liu <[email protected]>Cc Eric Biederman <[email protected]>
Quoted 13 lines
--- kernel/kexec.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)kernel/kexec.c +0
-1@@ -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 ) {
kernel/kexec.c void __weak crash_free_reserved_phys_range(unsigned long begin, · line 1125
Quoted 10 lines
kernel/kexec.c +2
-5-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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>