2013-04-13 15:40:21

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 00/19] kill free_all_bootmem() and clean up VALID_PAGE()

Commit 600cc5b7f6 "mm: Kill NO_BOOTMEM version free_all_bootmem_node()"
has kill free_all_bootmem_node() for NO_BOOTMEM.

Currently the usage pattern for free_all_bootmem_node() is like:
for_each_online_pgdat(pgdat)
free_all_bootmem_node(pgdat);

It's equivalent to free_all_bootmem(), so this patchset goes one
step further to kill free_all_bootmem_node() for BOOTMEM too.

This patchset also tries to clean up code and comments related to
VALID_PAGE() because it has been removed from kernel long time ago.

Patch 1-11:
Kill free_all_bootmem_node()
Patch 12-16:
Clean up code and comments related to VALID_PAGE()
Patch 17:
Fix a minor build warning for m68k
Patch 18:
merge Alpha's mem_init() for UMA and NUMA.
Patch 19:
call register_page_bootmem_info_node() from mm core

This patch is based on patchset at
http://marc.info/?l=linux-mm&m=136525931917910&w=2

Jiang Liu (19):
mm: introduce accessor function set_max_mapnr()
mm/AVR32: prepare for killing free_all_bootmem_node()
mm/IA64: prepare for killing free_all_bootmem_node()
mm/m32r: prepare for killing free_all_bootmem_node()
mm/m68k: prepare for killing free_all_bootmem_node()
mm/metag: prepare for killing free_all_bootmem_node()
mm/MIPS: prepare for killing free_all_bootmem_node()
mm/PARISC: prepare for killing free_all_bootmem_node()
mm/PPC: prepare for killing free_all_bootmem_node()
mm/SH: prepare for killing free_all_bootmem_node()
mm: kill free_all_bootmem_node()
mm/ALPHA: clean up unused VALID_PAGE()
mm/CRIS: clean up unused VALID_PAGE()
mm/microblaze: clean up unused VALID_PAGE()
mm/ARM: fix stale comment about VALID_PAGE()
mm/unicore32: fix stale comment about VALID_PAGE()
mm/m68k: fix build warning of unused variable
mm/alpha: unify mem_init() for both UMA and NUMA architectures
mm: call register_page_bootmem_info_node() from mm core

arch/alpha/include/asm/mmzone.h | 2 --
arch/alpha/mm/init.c | 7 ++-----
arch/alpha/mm/numa.c | 10 ----------
arch/arm/include/asm/memory.h | 6 ------
arch/avr32/mm/init.c | 21 +++++----------------
arch/cris/include/asm/page.h | 1 -
arch/ia64/mm/init.c | 9 ++-------
arch/m32r/mm/init.c | 17 ++++-------------
arch/m68k/mm/init.c | 15 ++++++++-------
arch/metag/mm/init.c | 14 ++------------
arch/microblaze/include/asm/page.h | 1 -
arch/mips/sgi-ip27/ip27-memory.c | 12 +-----------
arch/parisc/mm/init.c | 12 +-----------
arch/powerpc/mm/mem.c | 16 +---------------
arch/sh/mm/init.c | 16 ++++------------
arch/sparc/mm/init_64.c | 12 ------------
arch/unicore32/include/asm/memory.h | 6 ------
arch/x86/mm/init_64.c | 12 ------------
include/linux/bootmem.h | 1 -
include/linux/mm.h | 9 ++++++++-
mm/bootmem.c | 24 ++++++------------------
mm/nobootmem.c | 6 ++++++
22 files changed, 50 insertions(+), 179 deletions(-)

--
1.7.9.5


2013-04-13 15:40:41

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 02/19] mm/AVR32: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem() instead.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Haavard Skinnemoen <[email protected]>
Cc: Hans-Christian Egtvedt <[email protected]>
Cc: [email protected]
---
arch/avr32/mm/init.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index c1706a0..b25aba3 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -103,23 +103,12 @@ void __init mem_init(void)
pg_data_t *pgdat;

high_memory = NULL;
+ for_each_online_pgdat(pgdat)
+ high_memory = max_t(void *, high_memory,
+ (void *)__va(pgdat_end_pfn(pgdat) << PAGE_SHIFT));

- /* this will put all low memory onto the freelists */
- for_each_online_pgdat(pgdat) {
- void *node_high_memory;
-
- if (pgdat->node_spanned_pages != 0)
- free_all_bootmem_node(pgdat);
-
- node_high_memory = (void *)((pgdat->node_start_pfn
- + pgdat->node_spanned_pages)
- << PAGE_SHIFT);
- if (node_high_memory > high_memory)
- high_memory = node_high_memory;
- }
-
- max_mapnr = MAP_NR(high_memory);
-
+ set_max_mapnr(MAP_NR(high_memory));
+ free_all_bootmem();
mem_init_print_info(NULL);
}

--
1.7.9.5

2013-04-13 15:40:51

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 03/19] mm/IA64: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: Tang Chen <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/ia64/mm/init.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index d4382dc..26eeb74 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -584,7 +584,6 @@ __setup("nolwsys", nolwsys_setup);
void __init
mem_init (void)
{
- pg_data_t *pgdat;
int i;

BUG_ON(PTRS_PER_PGD * sizeof(pgd_t) != PAGE_SIZE);
@@ -602,15 +601,11 @@ mem_init (void)

#ifdef CONFIG_FLATMEM
BUG_ON(!mem_map);
- max_mapnr = max_low_pfn;
#endif

+ set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
-
- for_each_online_pgdat(pgdat)
- if (pgdat->bdata->node_bootmem_map)
- free_all_bootmem_node(pgdat);
-
+ free_all_bootmem();
mem_init_print_info(NULL);

/*
--
1.7.9.5

2013-04-13 15:41:00

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 04/19] mm/m32r: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/m32r/mm/init.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index 9c94839..3113c85 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -111,28 +111,19 @@ void __init paging_init(void)
*======================================================================*/
void __init mem_init(void)
{
- int nid;
#ifndef CONFIG_MMU
extern unsigned long memory_end;
-#endif

-#ifndef CONFIG_DISCONTIGMEM
- max_mapnr = get_num_physpages();
-#endif /* CONFIG_DISCONTIGMEM */
-
-#ifdef CONFIG_MMU
- high_memory = (void *)__va(PFN_PHYS(MAX_LOW_PFN(0)));
-#else
high_memory = (void *)(memory_end & PAGE_MASK);
+#else
+ high_memory = (void *)__va(PFN_PHYS(MAX_LOW_PFN(0)));
#endif /* CONFIG_MMU */

/* clear the zero-page */
memset(empty_zero_page, 0, PAGE_SIZE);

- /* this will put all low memory onto the freelists */
- for_each_online_node(nid)
- free_all_bootmem_node(NODE_DATA(nid));
-
+ set_max_mapnr(get_num_physpages());
+ free_all_bootmem();
mem_init_print_info(NULL);
}

--
1.7.9.5

2013-04-13 15:41:15

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 05/19] mm/m68k: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Greg Ungerer <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/m68k/mm/init.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 0723141..20d0ae2 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -148,12 +148,10 @@ void __init print_memmap(void)

void __init mem_init(void)
{
- pg_data_t *pgdat;
int i;

/* this will put all memory onto the freelists */
- for_each_online_pgdat(pgdat)
- free_all_bootmem_node(pgdat);
+ free_all_bootmem();

#if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
/* insert pointer tables allocated so far into the tablelist */
--
1.7.9.5

2013-04-13 15:41:20

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 06/19] mm/metag: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: James Hogan <[email protected]>
Cc: [email protected]
---
arch/metag/mm/init.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/arch/metag/mm/init.c b/arch/metag/mm/init.c
index e00586f..096d022 100644
--- a/arch/metag/mm/init.c
+++ b/arch/metag/mm/init.c
@@ -376,31 +376,21 @@ void __init paging_init(unsigned long mem_end)

void __init mem_init(void)
{
- int nid;
-
#ifdef CONFIG_HIGHMEM
unsigned long tmp;

/*
* Explicitly reset zone->managed_pages because highmem pages are
- * freed before calling free_all_bootmem_node();
+ * freed before calling free_all_bootmem();
*/
reset_all_zones_managed_pages();
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++)
free_highmem_page(pfn_to_page(tmp));
#endif /* CONFIG_HIGHMEM */

- for_each_online_node(nid) {
- pg_data_t *pgdat = NODE_DATA(nid);
-
- if (pgdat->node_spanned_pages)
- free_all_bootmem_node(pgdat);
- }
-
+ free_all_bootmem();
mem_init_print_info(NULL);
show_mem(0);
-
- return;
}

void free_initmem(void)
--
1.7.9.5

2013-04-13 15:41:30

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 07/19] mm/MIPS: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/mips/sgi-ip27/ip27-memory.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index d074680..0ebea6f 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -477,18 +477,8 @@ void __init paging_init(void)

void __init mem_init(void)
{
- unsigned node;
-
high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
-
- for_each_online_node(node) {
- /*
- * This will free up the bootmem, ie, slot 0 memory.
- */
- free_all_bootmem_node(NODE_DATA(node));
- }
-
+ free_all_bootmem();
setup_zero_pages(); /* This comes from node 0 */
-
mem_init_print_info(NULL);
}
--
1.7.9.5

2013-04-13 15:41:41

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 08/19] mm/PARISC: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/parisc/mm/init.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index f80c175..ab76b84 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -585,18 +585,8 @@ void __init mem_init(void)
> BITS_PER_LONG);

high_memory = __va((max_pfn << PAGE_SHIFT));
-
-#ifndef CONFIG_DISCONTIGMEM
- max_mapnr = page_to_pfn(virt_to_page(high_memory - 1)) + 1;
+ set_max_mapnr(page_to_pfn(virt_to_page(high_memory - 1)) + 1);
free_all_bootmem();
-#else
- {
- int i;
-
- for (i = 0; i < npmem_ranges; i++)
- free_all_bootmem_node(NODE_DATA(i));
- }
-#endif

#ifdef CONFIG_PA11
if (hppa_dma_ops == &pcxl_dma_ops) {
--
1.7.9.5

2013-04-13 15:41:52

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 09/19] mm/PPC: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: "Suzuki K. Poulose" <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/powerpc/mm/mem.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 07663de..22e46db 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -305,22 +305,8 @@ void __init mem_init(void)
#endif

high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
-
-#ifdef CONFIG_NEED_MULTIPLE_NODES
- {
- pg_data_t *pgdat;
-
- for_each_online_pgdat(pgdat)
- if (pgdat->node_spanned_pages != 0) {
- printk("freeing bootmem node %d\n",
- pgdat->node_id);
- free_all_bootmem_node(pgdat);
- }
- }
-#else
- max_mapnr = max_pfn;
+ set_max_mapnr(max_pfn);
free_all_bootmem();
-#endif

#ifdef CONFIG_HIGHMEM
{
--
1.7.9.5

2013-04-13 15:42:13

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 11/19] mm: kill free_all_bootmem_node()

Now nobody makes use of free_all_bootmem_node(), kill it.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
include/linux/bootmem.h | 1 -
mm/bootmem.c | 18 ------------------
2 files changed, 19 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index b585f57..a8866c5 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -45,7 +45,6 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);

extern unsigned long free_low_memory_core_early(int nodeid);
-extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
extern unsigned long free_all_bootmem(void);
extern void reset_all_zones_managed_pages(void);

diff --git a/mm/bootmem.c b/mm/bootmem.c
index a19404b..fab8f63 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -265,24 +265,6 @@ void __init reset_all_zones_managed_pages(void)
}

/**
- * free_all_bootmem_node - release a node's free pages to the buddy allocator
- * @pgdat: node to be released
- *
- * Returns the number of pages actually released.
- */
-unsigned long __init free_all_bootmem_node(pg_data_t *pgdat)
-{
- unsigned long pages;
-
- register_page_bootmem_info_node(pgdat);
- reset_node_managed_pages(pgdat);
- pages = free_all_bootmem_core(pgdat->bdata);
- totalram_pages += pages;
-
- return pages;
-}
-
-/**
* free_all_bootmem - release free pages to the buddy allocator
*
* Returns the number of pages actually released.
--
1.7.9.5

2013-04-13 15:42:21

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 12/19] mm/ALPHA: clean up unused VALID_PAGE()

VALID_PAGE() has been removed from kernel long time ago, so clean up it.

Signed-off-by: Jiang Liu <[email protected]>
---
arch/alpha/include/asm/mmzone.h | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/alpha/include/asm/mmzone.h b/arch/alpha/include/asm/mmzone.h
index c5b5d6b..14ce27b 100644
--- a/arch/alpha/include/asm/mmzone.h
+++ b/arch/alpha/include/asm/mmzone.h
@@ -71,8 +71,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)

#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)

-#define VALID_PAGE(page) (((page) - mem_map) < max_mapnr)
-
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> 32))
#define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> 32))
#define pte_pfn(pte) (pte_val(pte) >> 32)
--
1.7.9.5

2013-04-13 15:42:30

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 13/19] mm/CRIS: clean up unused VALID_PAGE()

VALID_PAGE() has been removed from kernel long time ago, so clean up it.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: Jesper Nilsson <[email protected]>
Cc: Jiang Liu <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/cris/include/asm/page.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/cris/include/asm/page.h b/arch/cris/include/asm/page.h
index be45ee3..dfc53f9 100644
--- a/arch/cris/include/asm/page.h
+++ b/arch/cris/include/asm/page.h
@@ -51,7 +51,6 @@ typedef struct page *pgtable_t;
*/

#define virt_to_page(kaddr) (mem_map + (((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT))
-#define VALID_PAGE(page) (((page) - mem_map) < max_mapnr)
#define virt_addr_valid(kaddr) pfn_valid((unsigned)(kaddr) >> PAGE_SHIFT)

/* convert a page (based on mem_map and forward) to a physical address
--
1.7.9.5

2013-04-13 15:42:03

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 10/19] mm/SH: prepare for killing free_all_bootmem_node()

Prepare for killing free_all_bootmem_node() by using
free_all_bootmem().

Signed-off-by: Jiang Liu <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Wen Congyang <[email protected]>
Cc: Tang Chen <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/sh/mm/init.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 3826596..485c858 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -412,19 +412,11 @@ void __init mem_init(void)
iommu_init();

high_memory = NULL;
+ for_each_online_pgdat(pgdat)
+ high_memory = max_t(void *, high_memory,
+ (void *)__va(pgdat_end_pfn(pgdat) << PAGE_SHIFT));

- for_each_online_pgdat(pgdat) {
- void *node_high_memory;
-
- if (pgdat->node_spanned_pages)
- free_all_bootmem_node(pgdat);
-
- node_high_memory = (void *)__va((pgdat->node_start_pfn +
- pgdat->node_spanned_pages) <<
- PAGE_SHIFT);
- if (node_high_memory > high_memory)
- high_memory = node_high_memory;
- }
+ free_all_bootmem();

/* Set this up early, so we can take care of the zero page */
cpu_cache_init();
--
1.7.9.5

2013-04-13 15:43:17

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 14/19] mm/microblaze: clean up unused VALID_PAGE()

VALID_PAGE() has been removed from kernel long time ago, so clean up it.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/microblaze/include/asm/page.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index 85a5ae8..fd85087 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -168,7 +168,6 @@ extern int page_is_ram(unsigned long pfn);
# else /* CONFIG_MMU */
# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
# define pfn_valid(pfn) ((pfn) < (max_mapnr + ARCH_PFN_OFFSET))
-# define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
# endif /* CONFIG_MMU */

# endif /* __ASSEMBLY__ */
--
1.7.9.5

2013-04-13 15:43:51

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 15/19] mm/ARM: fix stale comment about VALID_PAGE()

VALID_PAGE() has been removed from kernel long time ago,
so fix the comment.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Nicolas Pitre <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Giancarlo Asnaghi <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/include/asm/memory.h | 6 ------
1 file changed, 6 deletions(-)

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 57870ab..0cd2a3d 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -260,12 +260,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
/*
* Conversion between a struct page and a physical address.
*
- * Note: when converting an unknown physical address to a
- * struct page, the resulting pointer must be validated
- * using VALID_PAGE(). It must return an invalid struct page
- * for any physical address not corresponding to a system
- * RAM address.
- *
* page_to_pfn(page) convert a struct page * to a PFN number
* pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
*
--
1.7.9.5

2013-04-13 15:43:59

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 16/19] mm/unicore32: fix stale comment about VALID_PAGE()

VALID_PAGE() has been removed from kernel long time ago,
so fix the comment.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Guan Xuetao <[email protected]>
Cc: [email protected]
---
arch/unicore32/include/asm/memory.h | 6 ------
1 file changed, 6 deletions(-)

diff --git a/arch/unicore32/include/asm/memory.h b/arch/unicore32/include/asm/memory.h
index 5eddb99..debafc4 100644
--- a/arch/unicore32/include/asm/memory.h
+++ b/arch/unicore32/include/asm/memory.h
@@ -98,12 +98,6 @@
/*
* Conversion between a struct page and a physical address.
*
- * Note: when converting an unknown physical address to a
- * struct page, the resulting pointer must be validated
- * using VALID_PAGE(). It must return an invalid struct page
- * for any physical address not corresponding to a system
- * RAM address.
- *
* page_to_pfn(page) convert a struct page * to a PFN number
* pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
*
--
1.7.9.5

2013-04-13 15:44:11

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 17/19] mm/m68k: fix build warning of unused variable

Fix build warning of unused variable:
arch/m68k/mm/init.c: In function 'mem_init':
arch/m68k/mm/init.c:151:6: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Jiang Liu <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Greg Ungerer <[email protected]>
Cc: Thadeu Lima de Souza Cascardo <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/m68k/mm/init.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 20d0ae2..e4cb0af 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -146,14 +146,11 @@ void __init print_memmap(void)
MLK_ROUNDUP(__bss_start, __bss_stop));
}

-void __init mem_init(void)
+static inline void init_pointer_tables(void)
{
+#if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
int i;

- /* this will put all memory onto the freelists */
- free_all_bootmem();
-
-#if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
/* insert pointer tables allocated so far into the tablelist */
init_pointer_table((unsigned long)kernel_pg_dir);
for (i = 0; i < PTRS_PER_PGD; i++) {
@@ -165,7 +162,13 @@ void __init mem_init(void)
if (zero_pgtable)
init_pointer_table((unsigned long)zero_pgtable);
#endif
+}

+void __init mem_init(void)
+{
+ /* this will put all memory onto the freelists */
+ free_all_bootmem();
+ init_pointer_tables();
mem_init_print_info(NULL);
print_memmap();
}
--
1.7.9.5

2013-04-13 15:44:20

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 18/19] mm/alpha: unify mem_init() for both UMA and NUMA architectures

Now mem_init() for both Alpha UMA and Alpha NUMA are the same,
so unify it to reduce duplicated code.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/alpha/mm/init.c | 7 ++-----
arch/alpha/mm/numa.c | 10 ----------
2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 04c933c..39de408 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -276,17 +276,14 @@ srm_paging_stop (void)
}
#endif

-#ifndef CONFIG_DISCONTIGMEM
void __init
mem_init(void)
{
- max_mapnr = max_low_pfn;
- free_all_bootmem();
+ set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
-
+ free_all_bootmem();
mem_init_print_info(NULL);
}
-#endif /* CONFIG_DISCONTIGMEM */

void
free_initmem(void)
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index 0894b3a8..d543d71 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -319,13 +319,3 @@ void __init paging_init(void)
/* Initialize the kernel's ZERO_PGE. */
memset((void *)ZERO_PGE, 0, PAGE_SIZE);
}
-
-void __init mem_init(void)
-{
- high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
- free_all_bootmem();
- mem_init_print_info(NULL);
-#if 0
- mem_stress();
-#endif
-}
--
1.7.9.5

2013-04-13 15:44:35

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 19/19] mm: call register_page_bootmem_info_node() from mm core

Function register_page_bootmem_info_node() is suitably defined for
both HOTPLUG and non-HOTPLUG configurations, so we could call it
from mm core instead of arch specific code. This could simplify
arch implementations.

Signed-off-by: Jiang Liu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
Cc: Yasuaki Ishimatsu <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Wen Congyang <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/sparc/mm/init_64.c | 12 ------------
arch/x86/mm/init_64.c | 12 ------------
mm/bootmem.c | 6 ++++++
mm/nobootmem.c | 6 ++++++
4 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index b1e35b7..5530c09 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2027,16 +2027,6 @@ static void __init patch_tlb_miss_handler_bitmap(void)
flushi(&valid_addr_bitmap_insn[0]);
}

-static void __init register_page_bootmem_info(void)
-{
-#ifdef CONFIG_NEED_MULTIPLE_NODES
- int i;
-
- for_each_online_node(i)
- if (NODE_DATA(i)->node_spanned_pages)
- register_page_bootmem_info_node(NODE_DATA(i));
-#endif
-}
void __init mem_init(void)
{
unsigned long addr, last;
@@ -2052,8 +2042,6 @@ void __init mem_init(void)
patch_tlb_miss_handler_bitmap();

high_memory = __va(last_valid_pfn << PAGE_SHIFT);
-
- register_page_bootmem_info();
free_all_bootmem();

/*
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 650264b..72b5141 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1031,24 +1031,12 @@ int __ref arch_remove_memory(u64 start, u64 size)

static struct kcore_list kcore_vsyscall;

-static void __init register_page_bootmem_info(void)
-{
-#ifdef CONFIG_NUMA
- int i;
-
- for_each_online_node(i)
- register_page_bootmem_info_node(NODE_DATA(i));
-#endif
-}
-
void __init mem_init(void)
{
pci_iommu_alloc();

/* clear_bss() already clear the empty_zero_page */

- register_page_bootmem_info();
-
/* this will put all memory onto the freelists */
free_all_bootmem();
after_bootmem = 1;
diff --git a/mm/bootmem.c b/mm/bootmem.c
index fab8f63..3cf36ac 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -273,6 +273,12 @@ unsigned long __init free_all_bootmem(void)
{
unsigned long total_pages = 0;
bootmem_data_t *bdata;
+#ifdef CONFIG_NEED_MULTIPLE_NODES
+ pg_data_t *pgdat;
+
+ for_each_online_pgdat(pgdat)
+ register_page_bootmem_info_node(pgdat);
+#endif

reset_all_zones_managed_pages();

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 6b63cd6..ccc6630 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -166,6 +166,12 @@ void __init reset_all_zones_managed_pages(void)
unsigned long __init free_all_bootmem(void)
{
unsigned long pages;
+#ifdef CONFIG_NEED_MULTIPLE_NODES
+ pg_data_t *pgdat;
+
+ for_each_online_pgdat(pgdat)
+ register_page_bootmem_info_node(pgdat);
+#endif

reset_all_zones_managed_pages();

--
1.7.9.5

2013-04-13 15:40:39

by Jiang Liu

[permalink] [raw]
Subject: [RFC PATCH v1 01/19] mm: introduce accessor function set_max_mapnr()

Introduce accessor function set_max_mapnr() to set global variable
max_mapnr.

Also unify condition compilation for max_mapnr with
CONFIG_NEED_MULTIPLE_NODES instead of CONFIG_DISCONTIGMEM.

Signed-off-by: Jiang Liu <[email protected]>
---
include/linux/mm.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index f9f9f3c..497ebaf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -25,8 +25,15 @@ struct file_ra_state;
struct user_struct;
struct writeback_control;

-#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */
+#ifndef CONFIG_NEED_MULTIPLE_NODES /* Don't use mapnrs, do it properly */
extern unsigned long max_mapnr;
+
+static inline void set_max_mapnr(unsigned long limit)
+{
+ max_mapnr = limit;
+}
+#else
+static inline void set_max_mapnr(unsigned long limit) { }
#endif

extern unsigned long totalram_pages;
--
1.7.9.5

2013-04-15 04:56:37

by Paul Mackerras

[permalink] [raw]
Subject: Re: [RFC PATCH v1 00/19] kill free_all_bootmem() and clean up VALID_PAGE()

On Sat, Apr 13, 2013 at 11:36:20PM +0800, Jiang Liu wrote:
> Commit 600cc5b7f6 "mm: Kill NO_BOOTMEM version free_all_bootmem_node()"
> has kill free_all_bootmem_node() for NO_BOOTMEM.
>
> Currently the usage pattern for free_all_bootmem_node() is like:
> for_each_online_pgdat(pgdat)
> free_all_bootmem_node(pgdat);
>
> It's equivalent to free_all_bootmem(), so this patchset goes one
> step further to kill free_all_bootmem_node() for BOOTMEM too.
>
> This patchset also tries to clean up code and comments related to
> VALID_PAGE() because it has been removed from kernel long time ago.
>
> Patch 1-11:
> Kill free_all_bootmem_node()
> Patch 12-16:
> Clean up code and comments related to VALID_PAGE()
> Patch 17:
> Fix a minor build warning for m68k
> Patch 18:
> merge Alpha's mem_init() for UMA and NUMA.
> Patch 19:
> call register_page_bootmem_info_node() from mm core

How does this not break bisection? Will a kernel still boot with
patches 1-11 applied but not patch 19? As far as I can see such a
kernel would have no memory available to it after mem_init() time
and would therefore crash early in boot.

Paul.

2013-04-15 13:14:47

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [RFC PATCH v1 13/19] mm/CRIS: clean up unused VALID_PAGE()

On Sat, Apr 13, 2013 at 05:36:33PM +0200, Jiang Liu wrote:
> VALID_PAGE() has been removed from kernel long time ago, so clean up it.
>
> Signed-off-by: Jiang Liu <[email protected]>
> Cc: Mikael Starvik <[email protected]>
> Cc: Jiang Liu <[email protected]>
> Cc: [email protected]
> Cc: [email protected]

Acked-by: Jesper Nilsson <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-04-15 18:50:07

by Xuetao Guan

[permalink] [raw]
Subject: Re: [RFC PATCH v1 16/19] mm/unicore32: fix stale comment about VALID_PAGE()

> VALID_PAGE() has been removed from kernel long time ago,
> so fix the comment.
>
> Signed-off-by: Jiang Liu <[email protected]>
> Cc: Guan Xuetao <[email protected]>
> Cc: [email protected]

Thanks,

Acked-by: Guan Xuetao <[email protected]>

> ---
> arch/unicore32/include/asm/memory.h | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/arch/unicore32/include/asm/memory.h
> b/arch/unicore32/include/asm/memory.h
> index 5eddb99..debafc4 100644
> --- a/arch/unicore32/include/asm/memory.h
> +++ b/arch/unicore32/include/asm/memory.h
> @@ -98,12 +98,6 @@
> /*
> * Conversion between a struct page and a physical address.
> *
> - * Note: when converting an unknown physical address to a
> - * struct page, the resulting pointer must be validated
> - * using VALID_PAGE(). It must return an invalid struct page
> - * for any physical address not corresponding to a system
> - * RAM address.
> - *
> * page_to_pfn(page) convert a struct page * to a PFN number
> * pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
> *
> --
> 1.7.9.5
>

2013-04-16 15:04:29

by Jiang Liu

[permalink] [raw]
Subject: Re: [RFC PATCH v1 00/19] kill free_all_bootmem() and clean up VALID_PAGE()

On 04/15/2013 12:56 PM, Paul Mackerras wrote:
> On Sat, Apr 13, 2013 at 11:36:20PM +0800, Jiang Liu wrote:
>> Commit 600cc5b7f6 "mm: Kill NO_BOOTMEM version free_all_bootmem_node()"
>> has kill free_all_bootmem_node() for NO_BOOTMEM.
>>
>> Currently the usage pattern for free_all_bootmem_node() is like:
>> for_each_online_pgdat(pgdat)
>> free_all_bootmem_node(pgdat);
>>
>> It's equivalent to free_all_bootmem(), so this patchset goes one
>> step further to kill free_all_bootmem_node() for BOOTMEM too.
>>
>> This patchset also tries to clean up code and comments related to
>> VALID_PAGE() because it has been removed from kernel long time ago.
>>
>> Patch 1-11:
>> Kill free_all_bootmem_node()
>> Patch 12-16:
>> Clean up code and comments related to VALID_PAGE()
>> Patch 17:
>> Fix a minor build warning for m68k
>> Patch 18:
>> merge Alpha's mem_init() for UMA and NUMA.
>> Patch 19:
>> call register_page_bootmem_info_node() from mm core
>
> How does this not break bisection? Will a kernel still boot with
> patches 1-11 applied but not patch 19? As far as I can see such a
> kernel would have no memory available to it after mem_init() time
> and would therefore crash early in boot.
Hi Paul,
Thanks for review!
Patch 1-11 replace free_all_bootmem_node() with free_all_bootmem(),
so all normal pages will be freed into the buddy system as before. And
patch 1-11 are independent with patch 19.
Gerry
>
> Paul.
>