* [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 19:47 ` Sam Ravnborg
2013-03-05 14:54 ` [RFC PATCH v1 02/33] mm/alpha: use common help functions to free reserved pages Jiang Liu
` (31 subsequent siblings)
32 siblings, 1 reply; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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, 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, 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 | 37 +++++++++++++++++++++++++++++++++++++
mm/page_alloc.c | 20 ++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7acc9dc..881461c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1295,6 +1295,43 @@ 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);
+/* Help functions to deal with reserved/managed pages. */
+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;
+}
+
+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);
+}
+
+static inline void free_initmem_default(int poison)
+{
+ extern char __init_begin[], __init_end[];
+
+ 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] 44+ messages in thread
* Re: [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages
2013-03-05 14:54 ` [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
@ 2013-03-05 19:47 ` Sam Ravnborg
2013-03-06 17:21 ` Russell King - ARM Linux
2013-03-09 2:17 ` Jiang Liu
0 siblings, 2 replies; 44+ messages in thread
From: Sam Ravnborg @ 2013-03-05 19: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,
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,
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, Tang Chen,
Thomas Gleixner, Tony Luck, Will Deacon, Yasuaki Ishimatsu,
Yinghai Lu, Yoshinori Sato, x86, xen-devel, linux-kernel,
linux-mm, linux-arm-kernel, virtualization
On Tue, Mar 05, 2013 at 10:54:44PM +0800, Jiang Liu 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>
> ---
> include/linux/mm.h | 37 +++++++++++++++++++++++++++++++++++++
> mm/page_alloc.c | 20 ++++++++++++++++++++
> 2 files changed, 57 insertions(+)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 7acc9dc..881461c 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1295,6 +1295,43 @@ 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);
>
> +/* Help functions to deal with reserved/managed pages. */
> +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;
> +}
What is the purpose of the unused page argument?
> +
> +static inline void __free_reserved_page(struct page *page)
> +{
> + ClearPageReserved(page);
> + init_page_count(page);
> + __free_page(page);
> +}
This method is useful for architectures which implment HIGHMEM,
like 32 bit x86 and 32 bit sparc.
This calls for a name without underscores.
> +
> +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);
> +}
> +
> +static inline void free_initmem_default(int poison)
> +{
Why request user to supply the poison argumet. If this is the default
implmentation then use the default poison value too (POISON_FREE_INITMEM)
> + extern char __init_begin[], __init_end[];
> +
> + free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) ,
> + ((unsigned long)&__init_end) & PAGE_MASK,
> + poison, "unused kernel");
> +}
Maybe it is just me how is not used to this area of the kernel.
But a few comments that describe what the purpose is of each
function would have helped me.
Sam
--
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] 44+ messages in thread
* Re: [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages
2013-03-05 19:47 ` Sam Ravnborg
@ 2013-03-06 17:21 ` Russell King - ARM Linux
2013-03-09 2:17 ` Jiang Liu
1 sibling, 0 replies; 44+ messages in thread
From: Russell King - ARM Linux @ 2013-03-06 17:21 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Jiang Liu, 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,
Geert Uytterhoeven, Guan Xuetao, Haavard Skinnemoen,
Hans-Christian Egtvedt, Heiko Carstens, Helge Deller,
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, Rusty Russell, Tang Chen, Thomas Gleixner,
Tony Luck, Will Deacon, Yasuaki Ishimatsu, Yinghai Lu,
Yoshinori Sato, x86, xen-devel, linux-kernel, linux-mm,
linux-arm-kernel, virtualization
On Tue, Mar 05, 2013 at 08:47:22PM +0100, Sam Ravnborg wrote:
> On Tue, Mar 05, 2013 at 10:54:44PM +0800, Jiang Liu wrote:
> > +static inline void free_initmem_default(int poison)
> > +{
>
> Why request user to supply the poison argumet. If this is the default
> implmentation then use the default poison value too (POISON_FREE_INITMEM)
That poison value is inappropriate on some architectures like ARM - it's
executable. The default poison value leads to:
0: cccccccc stclgt 12, cr12, [ip], {204} ; 0xcc
or
4: cccc ldmia r4!, {r2, r3, r6, r7}
And we might as well forget using any kind of poison in that case.
The value which use is an undefined instruction on ARM and Thumb.
Notice the calls to poison_init_mem() in arch/arm/mm/init.c, which are
left by these patches, allowing us to continue using an appropriate
architecture specific value which will help to ensure that people
calling discarded init functions get appropriately bitten.
--
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] 44+ messages in thread
* Re: [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages
2013-03-05 19:47 ` Sam Ravnborg
2013-03-06 17:21 ` Russell King - ARM Linux
@ 2013-03-09 2:17 ` Jiang Liu
1 sibling, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-09 2:17 UTC (permalink / raw)
To: Sam Ravnborg
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,
Geert Uytterhoeven, Guan Xuetao, Haavard Skinnemoen,
Hans-Christian Egtvedt, Heiko Carstens, Helge Deller,
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, Tang Chen,
Thomas Gleixner, Tony Luck, Will Deacon, Yasuaki Ishimatsu,
Yinghai Lu, Yoshinori Sato, x86, xen-devel, linux-kernel,
linux-mm, linux-arm-kernel, virtualization
Hi Sam,
Thanks for review!
On 03/06/2013 03:47 AM, Sam Ravnborg wrote:
> On Tue, Mar 05, 2013 at 10:54:44PM +0800, Jiang Liu 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>
>> ---
>> include/linux/mm.h | 37 +++++++++++++++++++++++++++++++++++++
>> mm/page_alloc.c | 20 ++++++++++++++++++++
>> 2 files changed, 57 insertions(+)
>>
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index 7acc9dc..881461c 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -1295,6 +1295,43 @@ 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);
>>
>> +/* Help functions to deal with reserved/managed pages. */
>> +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;
>> +}
>
> What is the purpose of the unused page argument?
I will be used in a later patch.
>
>> +
>> +static inline void __free_reserved_page(struct page *page)
>> +{
>> + ClearPageReserved(page);
>> + init_page_count(page);
>> + __free_page(page);
>> +}
> This method is useful for architectures which implment HIGHMEM,
> like 32 bit x86 and 32 bit sparc.
> This calls for a name without underscores.
We will introduce another help function named free_highmem_page()
to free highmem into the buddy system. In normal cases __free_reserved_page()
won't be called directly, it's just used to handle several special cases.
>
>
>> +
>> +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);
>> +}
>> +
>> +static inline void free_initmem_default(int poison)
>> +{
>
> Why request user to supply the poison argumet. If this is the default
> implmentation then use the default poison value too (POISON_FREE_INITMEM)
>
>> + extern char __init_begin[], __init_end[];
>> +
>> + free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) ,
>> + ((unsigned long)&__init_end) & PAGE_MASK,
>> + poison, "unused kernel");
>> +}
>
>
> Maybe it is just me how is not used to this area of the kernel.
> But a few comments that describe what the purpose is of each
> function would have helped me.
Good suggestion, will add comments for them.
Regards!
Gerry
>
> Sam
>
--
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] 44+ messages in thread
* [RFC PATCH v1 02/33] mm/alpha: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 03/33] mm/ARM: " Jiang Liu
` (30 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 03/33] mm/ARM: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 02/33] mm/alpha: use common help functions to free reserved pages Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 04/33] mm/avr32: " Jiang Liu
` (29 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 04/33] mm/avr32: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (2 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 03/33] mm/ARM: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 16:50 ` Hans-Christian Egtvedt
2013-03-05 14:54 ` [RFC PATCH v1 05/33] mm/blackfin: " Jiang Liu
` (28 subsequent siblings)
32 siblings, 1 reply; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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, Hans-Christian Egtvedt
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
---
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] 44+ messages in thread
* Re: [RFC PATCH v1 04/33] mm/avr32: use common help functions to free reserved pages
2013-03-05 14:54 ` [RFC PATCH v1 04/33] mm/avr32: " Jiang Liu
@ 2013-03-05 16:50 ` Hans-Christian Egtvedt
0 siblings, 0 replies; 44+ messages in thread
From: Hans-Christian Egtvedt @ 2013-03-05 16:50 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, Haavard Skinnemoen
Around Tue 05 Mar 2013 22:54:47 +0800 or thereabout, Jiang Liu wrote:
> Use common help functions to free reserved pages.
>
AFAICT it looks good, thanks for updating.
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
> Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
> ---
> arch/avr32/mm/init.c | 24 ++----------------------
> 1 file changed, 2 insertions(+), 22 deletions(-)
<snipp diff>
--
Hans-Christian Egtvedt
--
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] 44+ messages in thread
* [RFC PATCH v1 05/33] mm/blackfin: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (3 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 04/33] mm/avr32: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 06/33] mm/c6x: " Jiang Liu
` (27 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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 | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index 9cb8553..2adc0ad 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -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] 44+ messages in thread
* [RFC PATCH v1 06/33] mm/c6x: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (4 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 05/33] mm/blackfin: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 07/33] mm/cris: " Jiang Liu
` (26 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 07/33] mm/cris: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (5 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 06/33] mm/c6x: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 08/33] mm/FRV: " Jiang Liu
` (25 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 08/33] mm/FRV: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (6 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 07/33] mm/cris: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 09/33] mm/h8300: " Jiang Liu
` (24 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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 | 32 +++-----------------------------
1 file changed, 3 insertions(+), 29 deletions(-)
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 92e97b0..0a86dcb 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -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] 44+ messages in thread
* [RFC PATCH v1 09/33] mm/h8300: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (7 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 08/33] mm/FRV: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 10/33] mm/IA64: " Jiang Liu
` (23 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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 | 28 ++--------------------------
1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 981e250..b84a2e5 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -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] 44+ messages in thread
* [RFC PATCH v1 10/33] mm/IA64: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (8 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 09/33] mm/h8300: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 11/33] mm/m32r: " Jiang Liu
` (22 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 11/33] mm/m32r: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (9 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 10/33] mm/IA64: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 12/33] mm/m68k: " Jiang Liu
` (21 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 12/33] mm/m68k: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (10 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 11/33] mm/m32r: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 13/33] mm/microblaze: " Jiang Liu
` (20 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 13/33] mm/microblaze: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (11 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 12/33] mm/m68k: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 14/33] mm/MIPS: " Jiang Liu
` (19 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 14/33] mm/MIPS: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (12 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 13/33] mm/microblaze: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 15/33] mm/mn10300: " Jiang Liu
` (18 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 15/33] mm/mn10300: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (13 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 14/33] mm/MIPS: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:54 ` [RFC PATCH v1 16/33] mm/openrisc: " Jiang Liu
` (17 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 16/33] mm/openrisc: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (14 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 15/33] mm/mn10300: " Jiang Liu
@ 2013-03-05 14:54 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 17/33] mm/parisc: " Jiang Liu
` (16 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:54 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] 44+ messages in thread
* [RFC PATCH v1 17/33] mm/parisc: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (15 preceding siblings ...)
2013-03-05 14:54 ` [RFC PATCH v1 16/33] mm/openrisc: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 18/33] mm/ppc: " Jiang Liu
` (15 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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 | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 3ac462d..153510f 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,11 @@ 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_reserved_area(init_begin, init_end,
+ 0, "unused kernel");
/* 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 +1098,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] 44+ messages in thread
* [RFC PATCH v1 18/33] mm/ppc: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (16 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 17/33] mm/parisc: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 19/33] mm/s390: " Jiang Liu
` (14 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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] 44+ messages in thread
* [RFC PATCH v1 19/33] mm/s390: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (17 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 18/33] mm/ppc: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 20/33] mm/score: " Jiang Liu
` (13 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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] 44+ messages in thread
* [RFC PATCH v1 20/33] mm/score: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (18 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 19/33] mm/s390: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 21/33] mm/SH: " Jiang Liu
` (12 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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] 44+ messages in thread
* [RFC PATCH v1 21/33] mm/SH: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (19 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 20/33] mm/score: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-06 2:21 ` Paul Mundt
2013-03-05 14:55 ` [RFC PATCH v1 22/33] mm/SPARC: " Jiang Liu
` (11 subsequent siblings)
32 siblings, 1 reply; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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, Paul Mundt
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: 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] 44+ messages in thread
* Re: [RFC PATCH v1 21/33] mm/SH: use common help functions to free reserved pages
2013-03-05 14:55 ` [RFC PATCH v1 21/33] mm/SH: " Jiang Liu
@ 2013-03-06 2:21 ` Paul Mundt
0 siblings, 0 replies; 44+ messages in thread
From: Paul Mundt @ 2013-03-06 2: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 Tue, Mar 05, 2013 at 10:55:04PM +0800, Jiang Liu wrote:
> Use common help functions to free reserved pages.
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Paul Mundt <lethal@linux-sh.org>
Acked-by: Paul Mundt <lethal@linux-sh.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] 44+ messages in thread
* [RFC PATCH v1 22/33] mm/SPARC: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (20 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 21/33] mm/SH: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 19:49 ` David Miller
2013-03-05 19:58 ` Sam Ravnborg
2013-03-05 14:55 ` [RFC PATCH v1 23/33] mm/um: " Jiang Liu
` (10 subsequent siblings)
32 siblings, 2 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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 S. Miller,
Sam Ravnborg
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: "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 | 40 ++++++----------------------------------
arch/sparc/mm/init_64.c | 25 ++++---------------------
3 files changed, 13 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..2a7b6eb 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -374,45 +374,17 @@ 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_reserved_area((unsigned long)(&__init_begin),
+ (unsigned long)(&__init_end),
+ POISON_FREE_INITMEM,
+ "unused kernel");
}
#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..03bfd10 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,7 @@ 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, 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] 44+ messages in thread
* Re: [RFC PATCH v1 22/33] mm/SPARC: use common help functions to free reserved pages
2013-03-05 14:55 ` [RFC PATCH v1 22/33] mm/SPARC: " Jiang Liu
@ 2013-03-05 19:49 ` David Miller
2013-03-05 19:58 ` Sam Ravnborg
1 sibling, 0 replies; 44+ messages in thread
From: David Miller @ 2013-03-05 19:49 UTC (permalink / raw)
To: liuj97
Cc: akpm, rientjes, jiang.liu, wency, maciej.rutecki, chris2553, rjw,
mgorman, minchan, kamezawa.hiroyu, mhocko, wujianguo, linux-mm,
linux-kernel, sam
From: Jiang Liu <liuj97@gmail.com>
Date: Tue, 5 Mar 2013 22:55:05 +0800
> 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>
--
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] 44+ messages in thread
* Re: [RFC PATCH v1 22/33] mm/SPARC: use common help functions to free reserved pages
2013-03-05 14:55 ` [RFC PATCH v1 22/33] mm/SPARC: " Jiang Liu
2013-03-05 19:49 ` David Miller
@ 2013-03-05 19:58 ` Sam Ravnborg
2013-03-05 22:57 ` Sam Ravnborg
2013-03-06 15:56 ` Jiang Liu
1 sibling, 2 replies; 44+ messages in thread
From: Sam Ravnborg @ 2013-03-05 19:58 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, David S. Miller
On Tue, Mar 05, 2013 at 10:55:05PM +0800, Jiang Liu wrote:
> Use common help functions to free reserved pages.
I like how this simplify things!
Please consider how you can also cover the HIGHMEM case,
so map_high_region(...) is simplified too (in init_32.c).
>
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: "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 | 40 ++++++----------------------------------
> arch/sparc/mm/init_64.c | 25 ++++---------------------
> 3 files changed, 13 insertions(+), 67 deletions(-)
>
> diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
> index 48e0c03..2a7b6eb 100644
> --- a/arch/sparc/mm/init_32.c
> +++ b/arch/sparc/mm/init_32.c
> @@ -374,45 +374,17 @@ 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_reserved_area((unsigned long)(&__init_begin),
> + (unsigned long)(&__init_end),
> + POISON_FREE_INITMEM,
> + "unused kernel");
If you change free_initmem_default(...) to return number of pages freed this
could have been used here.
> }
>
> #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..03bfd10 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,7 @@ 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, 0, "initrd");
Please add poison POISON_FREE_INITMEM here. I know this was not done before.
Sam
--
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] 44+ messages in thread
* Re: [RFC PATCH v1 22/33] mm/SPARC: use common help functions to free reserved pages
2013-03-05 19:58 ` Sam Ravnborg
@ 2013-03-05 22:57 ` Sam Ravnborg
2013-03-06 15:56 ` Jiang Liu
1 sibling, 0 replies; 44+ messages in thread
From: Sam Ravnborg @ 2013-03-05 22:57 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, David S. Miller
On Tue, Mar 05, 2013 at 08:58:46PM +0100, Sam Ravnborg wrote:
> On Tue, Mar 05, 2013 at 10:55:05PM +0800, Jiang Liu wrote:
> > Use common help functions to free reserved pages.
>
> I like how this simplify things!
>
> Please consider how you can also cover the HIGHMEM case,
> so map_high_region(...) is simplified too (in init_32.c).
I now see this is done in a later patch - good!
Sam
--
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] 44+ messages in thread
* Re: [RFC PATCH v1 22/33] mm/SPARC: use common help functions to free reserved pages
2013-03-05 19:58 ` Sam Ravnborg
2013-03-05 22:57 ` Sam Ravnborg
@ 2013-03-06 15:56 ` Jiang Liu
1 sibling, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-06 15:56 UTC (permalink / raw)
To: Sam Ravnborg
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, David S. Miller
Hi Sam,
Thanks for review!
On 03/06/2013 03:58 AM, Sam Ravnborg wrote:
> On Tue, Mar 05, 2013 at 10:55:05PM +0800, Jiang Liu wrote:
>> Use common help functions to free reserved pages.
>
> I like how this simplify things!
>
> Please consider how you can also cover the HIGHMEM case,
> so map_high_region(...) is simplified too (in init_32.c).
>
>>
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>> Cc: "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 | 40 ++++++----------------------------------
>> arch/sparc/mm/init_64.c | 25 ++++---------------------
>> 3 files changed, 13 insertions(+), 67 deletions(-)
>>
>> diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
>> index 48e0c03..2a7b6eb 100644
>> --- a/arch/sparc/mm/init_32.c
>> +++ b/arch/sparc/mm/init_32.c
>> @@ -374,45 +374,17 @@ 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_reserved_area((unsigned long)(&__init_begin),
>> + (unsigned long)(&__init_end),
>> + POISON_FREE_INITMEM,
>> + "unused kernel");
> If you change free_initmem_default(...) to return number of pages freed this
> could have been used here.
Good suggestion, will make that change.
>
>> }
>>
>> #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..03bfd10 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,7 @@ 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, 0, "initrd");
>
> Please add poison POISON_FREE_INITMEM here. I know this was not done before.
Sure, will make it.
>
> Sam
>
--
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] 44+ messages in thread
* [RFC PATCH v1 23/33] mm/um: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (21 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 22/33] mm/SPARC: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 24/33] mm/unicore32: " Jiang Liu
` (9 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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] 44+ messages in thread
* [RFC PATCH v1 24/33] mm/unicore32: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (22 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 23/33] mm/um: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 25/33] mm/x86: " Jiang Liu
` (8 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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 | 26 ++------------------------
1 file changed, 2 insertions(+), 24 deletions(-)
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index de186bd..ed153c5 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)
{
@@ -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] 44+ messages in thread
* [RFC PATCH v1 25/33] mm/x86: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (23 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 24/33] mm/unicore32: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 26/33] mm/xtensa: " Jiang Liu
` (7 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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 +----
1 file changed, 1 insertion(+), 4 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
}
--
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] 44+ messages in thread
* [RFC PATCH v1 26/33] mm/xtensa: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (24 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 25/33] mm/x86: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 27/33] mm,kexec: " Jiang Liu
` (6 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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] 44+ messages in thread
* [RFC PATCH v1 27/33] mm,kexec: use common help functions to free reserved pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (25 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 26/33] mm/xtensa: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 28/33] mm: introduce free_highmem_page() helper to free highmem pages inti buddy system Jiang Liu
` (5 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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] 44+ messages in thread
* [RFC PATCH v1 28/33] mm: introduce free_highmem_page() helper to free highmem pages inti buddy system
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (26 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 27/33] mm,kexec: " Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 29/33] mm: accurately calculate zone->managed_pages for highmem zones Jiang Liu
` (4 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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
Introduce helper function free_highmem_page(), which will be used by
architectures with HIGHMEM enabled to free highmem pages into the buddy
system.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
arch/arm/mm/init.c | 6 ++----
arch/microblaze/mm/init.c | 5 +----
arch/mips/mm/init.c | 5 +----
arch/powerpc/mm/mem.c | 5 +----
arch/sparc/mm/init_32.c | 10 ++--------
arch/um/kernel/mem.c | 15 +++------------
arch/x86/mm/init_32.c | 10 +---------
include/linux/mm.h | 3 +++
mm/page_alloc.c | 8 ++++++++
9 files changed, 22 insertions(+), 45 deletions(-)
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 40a5bc2..400a383 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -519,10 +519,8 @@ static void __init free_unused_memmap(struct meminfo *mi)
#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++;
- }
+ for (; pfn < end; pfn++)
+ free_highmem_page(pfn_to_page(pfn));
}
#endif
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 9be5302..d0fe2a8 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -82,10 +82,7 @@ static unsigned long highmem_setup(void)
/* FIXME not sure about */
if (memblock_is_reserved(pfn << PAGE_SHIFT))
continue;
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalhigh_pages++;
+ free_highmem_page(page);
reservedpages++;
}
totalram_pages += totalhigh_pages;
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 60f7c61..3105494 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -393,10 +393,7 @@ void __init mem_init(void)
SetPageReserved(page);
continue;
}
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalhigh_pages++;
+ free_highmem_page(page);
}
totalram_pages += totalhigh_pages;
num_physpages += totalhigh_pages;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index c756713..79eb16b 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -352,10 +352,7 @@ void __init mem_init(void)
struct page *page = pfn_to_page(pfn);
if (memblock_is_reserved(paddr))
continue;
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalhigh_pages++;
+ free_higmem_page(page);
reservedpages--;
}
totalram_pages += totalhigh_pages;
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index 2a7b6eb..cd4c78c 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -282,14 +282,8 @@ static void map_high_region(unsigned long start_pfn, unsigned long end_pfn)
printk("mapping high region %08lx - %08lx\n", start_pfn, end_pfn);
#endif
- for (tmp = start_pfn; tmp < end_pfn; tmp++) {
- struct page *page = pfn_to_page(tmp);
-
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalhigh_pages++;
- }
+ for (tmp = start_pfn; tmp < end_pfn; tmp++)
+ free_higmem_page(pfn_to_page(tmp));
}
void __init mem_init(void)
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index d5ac802..fea5c9d 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -42,17 +42,12 @@ static unsigned long brk_end;
static void setup_highmem(unsigned long highmem_start,
unsigned long highmem_len)
{
- struct page *page;
unsigned long highmem_pfn;
int i;
highmem_pfn = __pa(highmem_start) >> PAGE_SHIFT;
- for (i = 0; i < highmem_len >> PAGE_SHIFT; i++) {
- page = &mem_map[highmem_pfn + i];
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- }
+ for (i = 0; i < highmem_len >> PAGE_SHIFT; i++)
+ free_highmem_page(&mem_map[highmem_pfn + i]);
}
#endif
@@ -73,7 +68,7 @@ void __init mem_init(void)
totalram_pages = free_all_bootmem();
max_low_pfn = totalram_pages;
#ifdef CONFIG_HIGHMEM
- totalhigh_pages = highmem >> PAGE_SHIFT;
+ setup_highmem(end_iomem, highmem);
totalram_pages += totalhigh_pages;
#endif
num_physpages = totalram_pages;
@@ -81,10 +76,6 @@ void __init mem_init(void)
printk(KERN_INFO "Memory: %luk available\n",
nr_free_pages() << (PAGE_SHIFT-10));
kmalloc_ok = 1;
-
-#ifdef CONFIG_HIGHMEM
- setup_highmem(end_iomem, highmem);
-#endif
}
/*
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 2d19001..3ac7e31 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -427,14 +427,6 @@ static void __init permanent_kmaps_init(pgd_t *pgd_base)
pkmap_page_table = pte;
}
-static void __init add_one_highpage_init(struct page *page)
-{
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalhigh_pages++;
-}
-
void __init add_highpages_with_active_regions(int nid,
unsigned long start_pfn, unsigned long end_pfn)
{
@@ -448,7 +440,7 @@ void __init add_highpages_with_active_regions(int nid,
start_pfn, end_pfn);
for ( ; pfn < e_pfn; pfn++)
if (pfn_valid(pfn))
- add_one_highpage_init(pfn_to_page(pfn));
+ free_highmem_page(pfn_to_page(pfn));
}
}
#else
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 881461c..4d1509b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1296,6 +1296,9 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
extern void free_initmem(void);
/* Help functions to deal with reserved/managed pages. */
+#ifdef CONFIG_HIGHMEM
+extern void free_highmem_page(struct page *page);
+#endif
extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
int poison, char *s);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0fadb09..ad2f619 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5133,6 +5133,14 @@ unsigned long free_reserved_area(unsigned long start, unsigned long end,
return pages;
}
+#ifdef CONFIG_HIGHMEM
+void free_highmem_page(struct page *page)
+{
+ __free_reserved_page(page);
+ totalhigh_pages++;
+}
+#endif
+
/**
* 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] 44+ messages in thread
* [RFC PATCH v1 29/33] mm: accurately calculate zone->managed_pages for highmem zones
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (27 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 28/33] mm: introduce free_highmem_page() helper to free highmem pages inti buddy system Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 30/33] mm: use a dedicated lock to protect totalram_pages and zone->managed_pages Jiang Liu
` (3 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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
Commit "mm: introduce new field "managed_pages" to struct zone" assumes
that all highmem pages will be freed into the buddy system by function
mem_init(). But that's not true, some architectures may reserve some
highmem pages during boot. For example ppc may allocate highmem pages
for giagant HugeTLB pages, and several architectures check PageReserved
flag when freeing highmem pages into the buddy system.
So using the same way to calculate zone->managed_pages for both normal
and highmem zones.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
mm/bootmem.c | 16 ++++------------
mm/nobootmem.c | 14 +++-----------
mm/page_alloc.c | 1 +
3 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 2b0bcb0..46198d8 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -241,20 +241,12 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
return count;
}
-static void reset_node_lowmem_managed_pages(pg_data_t *pgdat)
+static inline void reset_node_managed_pages(pg_data_t *pgdat)
{
struct zone *z;
- /*
- * In free_area_init_core(), highmem zone's managed_pages is set to
- * present_pages, and bootmem allocator doesn't allocate from highmem
- * zones. So there's no need to recalculate managed_pages because all
- * highmem pages will be managed by the buddy system. Here highmem
- * zone also includes highmem movable zone.
- */
for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
- if (!is_highmem(z))
- z->managed_pages = 0;
+ z->managed_pages = 0;
}
/**
@@ -266,7 +258,7 @@ static void reset_node_lowmem_managed_pages(pg_data_t *pgdat)
unsigned long __init free_all_bootmem_node(pg_data_t *pgdat)
{
register_page_bootmem_info_node(pgdat);
- reset_node_lowmem_managed_pages(pgdat);
+ reset_node_managed_pages(pgdat);
return free_all_bootmem_core(pgdat->bdata);
}
@@ -282,7 +274,7 @@ unsigned long __init free_all_bootmem(void)
struct pglist_data *pgdat;
for_each_online_pgdat(pgdat)
- reset_node_lowmem_managed_pages(pgdat);
+ reset_node_managed_pages(pgdat);
list_for_each_entry(bdata, &bdata_list, list)
total_pages += free_all_bootmem_core(bdata);
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 5e07d36..960e80a 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -137,20 +137,12 @@ unsigned long __init free_low_memory_core_early(int nodeid)
return count;
}
-static void reset_node_lowmem_managed_pages(pg_data_t *pgdat)
+static inline void reset_node_managed_pages(pg_data_t *pgdat)
{
struct zone *z;
- /*
- * In free_area_init_core(), highmem zone's managed_pages is set to
- * present_pages, and bootmem allocator doesn't allocate from highmem
- * zones. So there's no need to recalculate managed_pages because all
- * highmem pages will be managed by the buddy system. Here highmem
- * zone also includes highmem movable zone.
- */
for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
- if (!is_highmem(z))
- z->managed_pages = 0;
+ z->managed_pages = 0;
}
/**
@@ -163,7 +155,7 @@ unsigned long __init free_all_bootmem(void)
struct pglist_data *pgdat;
for_each_online_pgdat(pgdat)
- reset_node_lowmem_managed_pages(pgdat);
+ reset_node_managed_pages(pgdat);
/*
* We need to use MAX_NUMNODES instead of NODE_DATA(0)->node_id
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ad2f619..8106aa5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5137,6 +5137,7 @@ unsigned long free_reserved_area(unsigned long start, unsigned long end,
void free_highmem_page(struct page *page)
{
__free_reserved_page(page);
+ page_zone(page)->managed_pages++;
totalhigh_pages++;
}
#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] 44+ messages in thread
* [RFC PATCH v1 30/33] mm: use a dedicated lock to protect totalram_pages and zone->managed_pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (28 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 29/33] mm: accurately calculate zone->managed_pages for highmem zones Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 31/33] mm: avoid using __free_pages_bootmem() at runtime Jiang Liu
` (2 subsequent siblings)
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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,
Michel Lespinasse, Rik van Riel
Currently lock_memory_hotplug()/unlock_memory_hotplug() are used to
protect totalram_pages and zone->managed_pages. Other than the memory
hotplug driver, totalram_pages and zone->managed_pages may be modified
by Xen balloon, virtio_balloon etc at runtime. For those case, memory
hotplug lock is a little too heavy, so introduce a dedicated lock to
protect them.
Now the locking rules for totalram_pages and zone->managed_pages have
been simpilied as:
1) no locking for read accesses because they are unsigned long.
2) no locking for write access at boot time in single-threaded context.
3) serialize write accesses at run time by managed_page_count_lock.
Also adjust zone->managed_pages when dealing with reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: linux-mm@kvack.org (open list:MEMORY MANAGEMENT)
Cc: linux-kernel@vger.kernel.org (open list)
---
include/linux/mm.h | 6 +-----
include/linux/mmzone.h | 14 ++++++++++----
mm/page_alloc.c | 19 +++++++++++++++++++
3 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4d1509b..f9cc7f0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1299,14 +1299,10 @@ extern void free_initmem(void);
#ifdef CONFIG_HIGHMEM
extern void free_highmem_page(struct page *page);
#endif
+extern void adjust_managed_page_count(struct page *page, long count);
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;
-}
-
static inline void __free_reserved_page(struct page *page)
{
ClearPageReserved(page);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index ede2749..bc58fef 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -474,10 +474,16 @@ struct zone {
* frequently read in proximity to zone->lock. It's good to
* give them a chance of being in the same cacheline.
*
- * Write access to present_pages and managed_pages at runtime should
- * be protected by lock_memory_hotplug()/unlock_memory_hotplug().
- * Any reader who can't tolerant drift of present_pages and
- * managed_pages should hold memory hotplug lock to get a stable value.
+ * Write access to present_pages at runtime should be protected by
+ * lock_memory_hotplug()/unlock_memory_hotplug(). Any reader who can't
+ * tolerant drift of present_pages should hold memory hotplug lock to
+ * get a stable value.
+ *
+ * Read access to managed_pages should be safe because it's unsigned
+ * long. Write access to zone->managed_pages and totalram_pages are
+ * protected by managed_page_count_lock at runtime. Basically only
+ * adjust_managed_page_count() should be used instead of directly
+ * touching zone->managed_pages and totalram_pages.
*/
unsigned long spanned_pages;
unsigned long present_pages;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8106aa5..2692931 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -99,6 +99,9 @@ nodemask_t node_states[NR_NODE_STATES] __read_mostly = {
};
EXPORT_SYMBOL(node_states);
+/* Protect totalram_pages and zone->managed_pages */
+static DEFINE_SPINLOCK(managed_page_count_lock);
+
unsigned long totalram_pages __read_mostly;
unsigned long totalreserve_pages __read_mostly;
/*
@@ -5113,6 +5116,22 @@ early_param("movablecore", cmdline_parse_movablecore);
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+void adjust_managed_page_count(struct page *page, long count)
+{
+ bool lock = (system_state != SYSTEM_BOOTING);
+
+ /* No need to acquire the lock during boot */
+ if (lock)
+ spin_lock(&managed_page_count_lock);
+
+ page_zone(page)->managed_pages += count;
+ totalram_pages += count;
+
+ if (lock)
+ spin_unlock(&managed_page_count_lock);
+}
+EXPORT_SYMBOL(adjust_managed_page_count);
+
unsigned long free_reserved_area(unsigned long start, unsigned long end,
int poison, char *s)
{
--
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] 44+ messages in thread
* [RFC PATCH v1 31/33] mm: avoid using __free_pages_bootmem() at runtime
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (29 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 30/33] mm: use a dedicated lock to protect totalram_pages and zone->managed_pages Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 32/33] mm: correctly update zone->mamaged_pages Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 33/33] mm: report available pages as "MemTotal" for each NUMA node Jiang Liu
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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, Yinghai Lu, x86, Tang Chen,
Yasuaki Ishimatsu
Avoid using __free_pages_bootmem() at runtime, so we could easily
manage totalram_pages and zone->managed_pages. With this change applied,
__free_pages_bootmem() is only used by bootmem.c and nobootmem.c at
boot time, so mark it as __init. And other callers of
__free_pages_bootmem() have been switched to free_reserved_page(),
which handles totalram_pages and zone->managed_pages in a common way.
This patch also fix a bug in free_pagetable() for x86_64, which should
increase zone->managed_pages instead of zone->present_pages when freeing
reserved pages.
And free_reserved_page() protects totalram_pages and zone->managed_pages
with managed_pages_count_lock, so remove the redundant ppb_lock lock in
put_page_bootmem(). This makes the locking rules much more clear.
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>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Minchan Kim <minchan@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
---
arch/x86/mm/init_64.c | 18 ++----------------
mm/memory_hotplug.c | 16 ++--------------
mm/page_alloc.c | 9 +--------
3 files changed, 5 insertions(+), 38 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 474e28f..17cfe98 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -711,36 +711,22 @@ EXPORT_SYMBOL_GPL(arch_add_memory);
static void __meminit free_pagetable(struct page *page, int order)
{
- struct zone *zone;
- bool bootmem = false;
unsigned long magic;
unsigned int nr_pages = 1 << order;
/* bootmem page has reserved flag */
if (PageReserved(page)) {
__ClearPageReserved(page);
- bootmem = true;
magic = (unsigned long)page->lru.next;
if (magic == SECTION_INFO || magic == MIX_SECTION_INFO) {
while (nr_pages--)
put_page_bootmem(page++);
} else
- __free_pages_bootmem(page, order);
+ while (nr_pages--)
+ free_reserved_page(page++);
} else
free_pages((unsigned long)page_address(page), order);
-
- /*
- * SECTION_INFO pages and MIX_SECTION_INFO pages
- * are all allocated by bootmem.
- */
- if (bootmem) {
- zone = page_zone(page);
- zone_span_writelock(zone);
- zone->present_pages += nr_pages;
- zone_span_writeunlock(zone);
- totalram_pages += nr_pages;
- }
}
static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index b81a367b..af9e87f 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -101,12 +101,9 @@ void get_page_bootmem(unsigned long info, struct page *page,
atomic_inc(&page->_count);
}
-/* reference to __meminit __free_pages_bootmem is valid
- * so use __ref to tell modpost not to generate a warning */
-void __ref put_page_bootmem(struct page *page)
+void put_page_bootmem(struct page *page)
{
unsigned long type;
- static DEFINE_MUTEX(ppb_lock);
type = (unsigned long) page->lru.next;
BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
@@ -116,17 +113,8 @@ void __ref put_page_bootmem(struct page *page)
ClearPagePrivate(page);
set_page_private(page, 0);
INIT_LIST_HEAD(&page->lru);
-
- /*
- * Please refer to comment for __free_pages_bootmem()
- * for why we serialize here.
- */
- mutex_lock(&ppb_lock);
- __free_pages_bootmem(page, 0);
- mutex_unlock(&ppb_lock);
- totalram_pages++;
+ free_reserved_page(page);
}
-
}
#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2692931..d252443 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -741,14 +741,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
local_irq_restore(flags);
}
-/*
- * Read access to zone->managed_pages is safe because it's unsigned long,
- * but we still need to serialize writers. Currently all callers of
- * __free_pages_bootmem() except put_page_bootmem() should only be used
- * at boot time. So for shorter boot time, we shift the burden to
- * put_page_bootmem() to serialize writers.
- */
-void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
+void __init __free_pages_bootmem(struct page *page, unsigned int order)
{
unsigned int nr_pages = 1 << order;
unsigned int loop;
--
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] 44+ messages in thread
* [RFC PATCH v1 32/33] mm: correctly update zone->mamaged_pages
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (30 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 31/33] mm: avoid using __free_pages_bootmem() at runtime Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
2013-03-05 14:55 ` [RFC PATCH v1 33/33] mm: report available pages as "MemTotal" for each NUMA node Jiang Liu
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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 Metcalf,
Rusty Russell, Michael S. Tsirkin, Konrad Rzeszutek Wilk,
Jeremy Fitzhardinge, Tang Chen, Yasuaki Ishimatsu, virtualization,
xen-devel
Enhance adjust_managed_page_count() to adjust totalhigh_pages for
highmem pages. And change code which directly adjusts totalram_pages
to use adjust_managed_page_count() because it adjusts totalram_pages,
totalhigh_pages and zone->managed_pages altogether in a safe way.
Remove inc_totalhigh_pages() and dec_totalhigh_pages() from xen/balloon
driver bacause adjust_managed_page_count() has already adjusted
totalhigh_pages. This patch also enhances virtio_balloon driver to
adjust totalhigh_pages when reserve/unreserve pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Minchan Kim <minchan@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: xen-devel@lists.xensource.com
Cc: linux-mm@kvack.org
---
arch/tile/mm/init.c | 4 ++--
drivers/virtio/virtio_balloon.c | 8 +++++---
drivers/xen/balloon.c | 19 ++++---------------
mm/hugetlb.c | 2 +-
mm/memory_hotplug.c | 15 +++------------
mm/page_alloc.c | 6 ++++++
6 files changed, 21 insertions(+), 33 deletions(-)
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 2749515..5886aef 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -720,7 +720,7 @@ static void __init init_free_pfn_range(unsigned long start, unsigned long end)
}
init_page_count(page);
__free_pages(page, order);
- totalram_pages += count;
+ adjust_managed_page_count(page, count);
page += count;
pfn += count;
@@ -1033,7 +1033,7 @@ static void free_init_pages(char *what, unsigned long begin, unsigned long end)
pfn_pte(pfn, PAGE_KERNEL));
memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
free_page(addr);
- totalram_pages++;
+ adjust_managed_page_count(page, 1);
}
pr_info("Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
}
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 8dab163..4c6ec53 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -148,7 +148,7 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
}
set_page_pfns(vb->pfns + vb->num_pfns, page);
vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE;
- totalram_pages--;
+ adjust_managed_page_count(page, -1);
}
/* Did we get any? */
@@ -160,11 +160,13 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
static void release_pages_by_pfn(const u32 pfns[], unsigned int num)
{
unsigned int i;
+ struct page *page;
/* Find pfns pointing at start of each page, get pages and free them. */
for (i = 0; i < num; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
- balloon_page_free(balloon_pfn_to_page(pfns[i]));
- totalram_pages++;
+ page = balloon_pfn_to_page(pfns[i]);
+ balloon_page_free(page);
+ adjust_managed_page_count(page, 1);
}
}
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a56776d..a5fdbcc 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -89,14 +89,6 @@ EXPORT_SYMBOL_GPL(balloon_stats);
/* We increase/decrease in batches which fit in a page */
static xen_pfn_t frame_list[PAGE_SIZE / sizeof(unsigned long)];
-#ifdef CONFIG_HIGHMEM
-#define inc_totalhigh_pages() (totalhigh_pages++)
-#define dec_totalhigh_pages() (totalhigh_pages--)
-#else
-#define inc_totalhigh_pages() do {} while (0)
-#define dec_totalhigh_pages() do {} while (0)
-#endif
-
/* List of ballooned pages, threaded through the mem_map array. */
static LIST_HEAD(ballooned_pages);
@@ -132,9 +124,7 @@ static void __balloon_append(struct page *page)
static void balloon_append(struct page *page)
{
__balloon_append(page);
- if (PageHighMem(page))
- dec_totalhigh_pages();
- totalram_pages--;
+ adjust_managed_page_count(page, -1);
}
/* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
@@ -151,13 +141,12 @@ static struct page *balloon_retrieve(bool prefer_highmem)
page = list_entry(ballooned_pages.next, struct page, lru);
list_del(&page->lru);
- if (PageHighMem(page)) {
+ if (PageHighMem(page))
balloon_stats.balloon_high--;
- inc_totalhigh_pages();
- } else
+ else
balloon_stats.balloon_low--;
- totalram_pages++;
+ adjust_managed_page_count(page, 1);
return page;
}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 0a0be33..a381818 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1246,7 +1246,7 @@ static void __init gather_bootmem_prealloc(void)
* side-effects, like CommitLimit going negative.
*/
if (h->order > (MAX_ORDER - 1))
- totalram_pages += 1 << h->order;
+ adjust_managed_page_count(page, 1 << h->order);
}
}
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index af9e87f..f9ce564 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -760,20 +760,13 @@ EXPORT_SYMBOL_GPL(__online_page_set_limits);
void __online_page_increment_counters(struct page *page)
{
- totalram_pages++;
-
-#ifdef CONFIG_HIGHMEM
- if (PageHighMem(page))
- totalhigh_pages++;
-#endif
+ adjust_managed_page_count(page, 1);
}
EXPORT_SYMBOL_GPL(__online_page_increment_counters);
void __online_page_free(struct page *page)
{
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
+ __free_reserved_page(page);
}
EXPORT_SYMBOL_GPL(__online_page_free);
@@ -970,7 +963,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
return ret;
}
- zone->managed_pages += onlined_pages;
zone->present_pages += onlined_pages;
zone->zone_pgdat->node_present_pages += onlined_pages;
if (onlined_pages) {
@@ -1554,10 +1546,9 @@ repeat:
/* reset pagetype flags and makes migrate type to be MOVABLE */
undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
/* removal success */
- zone->managed_pages -= offlined_pages;
+ adjust_managed_page_count(pfn_to_page(start_pfn), -offlined_pages);
zone->present_pages -= offlined_pages;
zone->zone_pgdat->node_present_pages -= offlined_pages;
- totalram_pages -= offlined_pages;
init_per_zone_wmark_min();
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d252443..041eb92 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -780,7 +780,9 @@ void __init init_cma_reserved_pageblock(struct page *page)
#ifdef CONFIG_HIGHMEM
if (PageHighMem(page))
totalhigh_pages += pageblock_nr_pages;
+ else
#endif
+ page_zone(page)->managed_pages += pageblock_nr_pages;
}
#endif
@@ -5119,6 +5121,10 @@ void adjust_managed_page_count(struct page *page, long count)
page_zone(page)->managed_pages += count;
totalram_pages += count;
+#ifdef CONFIG_HIGHMEM
+ if (PageHighMem(page))
+ totalhigh_pages += count;
+#endif
if (lock)
spin_unlock(&managed_page_count_lock);
--
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] 44+ messages in thread
* [RFC PATCH v1 33/33] mm: report available pages as "MemTotal" for each NUMA node
2013-03-05 14:54 [RFC PATCH v1 00/33] accurately calculate pages managed by buddy system Jiang Liu
` (31 preceding siblings ...)
2013-03-05 14:55 ` [RFC PATCH v1 32/33] mm: correctly update zone->mamaged_pages Jiang Liu
@ 2013-03-05 14:55 ` Jiang Liu
32 siblings, 0 replies; 44+ messages in thread
From: Jiang Liu @ 2013-03-05 14:55 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
As reported by https://bugzilla.kernel.org/show_bug.cgi?id=53501,
"MemTotal" from /proc/meminfo means memory pages managed by the buddy
system (managed_pages), but "MemTotal" from /sys/.../node/nodex/meminfo
means phsical pages present (present_pages) within the NUMA node.
There's a difference between managed_pages and present_pages due to
bootmem allocator and reserved pages.
And Documentation/filesystems/proc.txt says
MemTotal: Total usable ram (i.e. physical ram minus a few reserved
bits and the kernel binary code)
So change /sys/.../node/nodex/meminfo to report available pages within
the node as "MemTotal".
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Reported-by: sworddragon2@aol.com
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Minchan Kim <minchan@kernel.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
mm/page_alloc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 041eb92..048c5c6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2878,9 +2878,13 @@ EXPORT_SYMBOL(si_meminfo);
#ifdef CONFIG_NUMA
void si_meminfo_node(struct sysinfo *val, int nid)
{
+ int zone_type; /* needs to be signed */
+ unsigned long managed_pages = 0;
pg_data_t *pgdat = NODE_DATA(nid);
- val->totalram = pgdat->node_present_pages;
+ for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++)
+ managed_pages += pgdat->node_zones[zone_type].managed_pages;
+ val->totalram = managed_pages;
val->freeram = node_page_state(nid, NR_FREE_PAGES);
#ifdef CONFIG_HIGHMEM
val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].managed_pages;
--
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] 44+ messages in thread