2013-03-10 08:08:36

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 00/10] simplify initialization of highmem pages

The original goal of this patchset is to fix the bug reported by
https://bugzilla.kernel.org/show_bug.cgi?id=53501
Now it has also been expanded to reduce common code used by memory
initializion.

This is the second part, which applies to the previous part at:
http://marc.info/?l=linux-mm&m=136289696323825&w=2

It introduces a helper function free_highmem_page() to free highmem
pages into the buddy system when initializing mm subsystem.
Introduction of free_highmem_page() is one step forward to clean up
accesses and modificaitons of totalhigh_pages, totalram_pages and
zone->managed_pages etc. I hope we could remove all references to
totalhigh_pages from the arch/ subdirectory.

We have only tested these patchset on x86 platforms, and have done basic
compliation tests using cross-compilers from ftp.kernel.org. That means
some code may not pass compilation on some architectures. So any help
to test this patchset are welcomed!

There are several other parts still under development:
Part3: refine code to manage totalram_pages, totalhigh_pages and
zone->managed_pages
Part4: introduce helper functions to simplify mem_init() and remove the
global variable num_physpages.

Jiang Liu (10):
mm: introduce free_highmem_page() helper to free highmem pages into
buddy system
mm/ARM: use free_highmem_page() to free highmem pages into buddy
system
mm/FRV: use free_highmem_page() to free highmem pages into buddy
system
mm/metag: use free_highmem_page() to free highmem pages into buddy
system
mm/microblaze: use free_highmem_page() to free highmem pages into
buddy system
mm/MIPS: use free_highmem_page() to free highmem pages into buddy
system
mm/PPC: use free_highmem_page() to free highmem pages into buddy
system
mm/SPARC: use free_highmem_page() to free highmem pages into buddy
system
mm/um: use free_highmem_page() to free highmem pages into buddy
system
mm/x86: use free_highmem_page() to free highmem pages into buddy
system

arch/arm/mm/init.c | 7 ++-----
arch/frv/mm/init.c | 6 ++----
arch/metag/mm/init.c | 10 ++--------
arch/microblaze/mm/init.c | 6 +-----
arch/mips/mm/init.c | 6 +-----
arch/powerpc/mm/mem.c | 6 +-----
arch/sparc/mm/init_32.c | 12 ++----------
arch/um/kernel/mem.c | 16 +++-------------
arch/x86/mm/highmem_32.c | 1 -
arch/x86/mm/init_32.c | 10 +---------
include/linux/mm.h | 7 +++++++
mm/page_alloc.c | 9 +++++++++
12 files changed, 31 insertions(+), 65 deletions(-)

--
1.7.9.5


2013-03-10 08:09:17

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 03/10] mm/FRV: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Also fix a bug that totalhigh_pages should be increased when freeing
a highmem page into the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: David Howells <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: [email protected]
---
arch/frv/mm/init.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 21b9290..dee354f 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -131,10 +131,8 @@ void __init mem_init(void)
datapages++;

#ifdef CONFIG_HIGHMEM
- for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--) {
- __free_reserved_page(&mem_map[pfn]);
- totalram_pages++;
- }
+ for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--)
+ free_highmem_page(&mem_map[pfn]);
#endif

codek = ((unsigned long) &_etext - (unsigned long) &_stext) >> 10;
--
1.7.9.5

2013-03-10 08:09:26

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 06/10] mm/MIPS: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: David Daney <[email protected]>
Cc: Cong Wang <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/mips/mm/init.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 60f7c61..3d0346d 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -393,12 +393,8 @@ 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;
#endif

--
1.7.9.5

2013-03-10 08:09:35

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 07/10] mm/PPC: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

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

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index c756713..68f51d0 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -352,13 +352,9 @@ 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;
printk(KERN_DEBUG "High memory: %luk\n",
totalhigh_pages << (PAGE_SHIFT-10));
}
--
1.7.9.5

2013-03-10 08:09:46

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 08/10] mm/SPARC: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/sparc/mm/init_32.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index 13d6fee..6a7eb68 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)
@@ -347,8 +341,6 @@ void __init mem_init(void)
map_high_region(start_pfn, end_pfn);
}

- totalram_pages += totalhigh_pages;
-
codepages = (((unsigned long) &_etext) - ((unsigned long)&_start));
codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
datapages = (((unsigned long) &_edata) - ((unsigned long)&_etext));
--
1.7.9.5

2013-03-10 08:09:53

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 09/10] mm/um: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/um/kernel/mem.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index d5ac802..9df292b 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,18 +68,13 @@ void __init mem_init(void)
totalram_pages = free_all_bootmem();
max_low_pfn = totalram_pages;
#ifdef CONFIG_HIGHMEM
- totalhigh_pages = highmem >> PAGE_SHIFT;
- totalram_pages += totalhigh_pages;
+ setup_highmem(end_iomem, highmem);
#endif
num_physpages = totalram_pages;
max_pfn = totalram_pages;
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
}

/*
--
1.7.9.5

2013-03-10 08:10:06

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 10/10] mm/x86: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
Cc: Cong Wang <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Attilio Rao <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/x86/mm/highmem_32.c | 1 -
arch/x86/mm/init_32.c | 10 +---------
2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
index 6f31ee5..252b8f5 100644
--- a/arch/x86/mm/highmem_32.c
+++ b/arch/x86/mm/highmem_32.c
@@ -137,5 +137,4 @@ void __init set_highmem_pages_init(void)
add_highpages_with_active_regions(nid, zone_start_pfn,
zone_end_pfn);
}
- totalram_pages += totalhigh_pages;
}
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
--
1.7.9.5

2013-03-10 08:09:13

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 02/10] mm/ARM: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Russell King <[email protected]>
Cc: Linus Walleij <[email protected]>
cc: Marek Szyprowski <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mm/init.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 40a5bc2..687a114 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

@@ -571,7 +569,6 @@ static void __init free_highpages(void)
if (start < end)
free_area_high(start, end);
}
- totalram_pages += totalhigh_pages;
#endif
}

--
1.7.9.5

2013-03-10 08:12:58

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 05/10] mm/microblaze: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

Signed-off-by: Jiang Liu <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/microblaze/mm/init.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 9be5302..4ec137d 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -82,13 +82,9 @@ 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;
pr_info("High memory: %luk\n",
totalhigh_pages << (PAGE_SHIFT-10));

--
1.7.9.5

2013-03-10 08:09:08

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 01/10] mm: introduce free_highmem_page() helper to free highmem pages into buddy system

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 <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Michal Nazarewicz <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Russell King <[email protected]>
Cc: David Howells <[email protected]>
Cc: James Hogan <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: David Daney <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
---
include/linux/mm.h | 7 +++++++
mm/page_alloc.c | 9 +++++++++
2 files changed, 16 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index d75c14b..f2fb750 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1303,6 +1303,13 @@ extern void free_initmem(void);
*/
extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
int poison, char *s);
+#ifdef CONFIG_HIGHMEM
+/*
+ * Free a highmem page into the buddy system, adjusting totalhigh_pages
+ * and totalram_pages.
+ */
+extern void free_highmem_page(struct page *page);
+#endif

static inline void adjust_managed_page_count(struct page *page, long count)
{
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0fadb09..37bc8ab 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5133,6 +5133,15 @@ 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);
+ totalram_pages++;
+ 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

2013-03-10 08:13:44

by Jiang Liu

[permalink] [raw]
Subject: [PATCH v2, part2 04/10] mm/metag: use free_highmem_page() to free highmem pages into buddy system

Use helper function free_highmem_page() to free highmem pages into
the buddy system.

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

diff --git a/arch/metag/mm/init.c b/arch/metag/mm/init.c
index c6784fb..d05b845 100644
--- a/arch/metag/mm/init.c
+++ b/arch/metag/mm/init.c
@@ -380,14 +380,8 @@ void __init mem_init(void)

#ifdef CONFIG_HIGHMEM
unsigned long tmp;
- for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = pfn_to_page(tmp);
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalhigh_pages++;
- }
- totalram_pages += totalhigh_pages;
+ for (tmp = highstart_pfn; tmp < highend_pfn; tmp++)
+ free_highmem_page(pfn_to_page(tmp));
num_physpages += totalhigh_pages;
#endif /* CONFIG_HIGHMEM */

--
1.7.9.5

2013-03-10 10:32:39

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH v2, part2 10/10] mm/x86: use free_highmem_page() to free highmem pages into buddy system

On Sun, Mar 10, 2013 at 10:01 AM, Jiang Liu <[email protected]> wrote:
> Use helper function free_highmem_page() to free highmem pages into
> the buddy system.
>
> Signed-off-by: Jiang Liu <[email protected]>
> ---
> arch/x86/mm/highmem_32.c | 1 -
> arch/x86/mm/init_32.c | 10 +---------
> 2 files changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
> index 6f31ee5..252b8f5 100644
> --- a/arch/x86/mm/highmem_32.c
> +++ b/arch/x86/mm/highmem_32.c
> @@ -137,5 +137,4 @@ void __init set_highmem_pages_init(void)
> add_highpages_with_active_regions(nid, zone_start_pfn,
> zone_end_pfn);
> }
> - totalram_pages += totalhigh_pages;

Hmm? I haven't looked at what totalram_pages is used for but could you
explain why this change is safe?

> }
> 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
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2013-03-10 10:40:52

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH v2, part2 10/10] mm/x86: use free_highmem_page() to free highmem pages into buddy system

On Sun, Mar 10, 2013 at 12:32 PM, Pekka Enberg <[email protected]> wrote:
> On Sun, Mar 10, 2013 at 10:01 AM, Jiang Liu <[email protected]> wrote:
>> Use helper function free_highmem_page() to free highmem pages into
>> the buddy system.
>>
>> Signed-off-by: Jiang Liu <[email protected]>
>> ---
>> arch/x86/mm/highmem_32.c | 1 -
>> arch/x86/mm/init_32.c | 10 +---------
>> 2 files changed, 1 insertion(+), 10 deletions(-)
>>
>> diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
>> index 6f31ee5..252b8f5 100644
>> --- a/arch/x86/mm/highmem_32.c
>> +++ b/arch/x86/mm/highmem_32.c
>> @@ -137,5 +137,4 @@ void __init set_highmem_pages_init(void)
>> add_highpages_with_active_regions(nid, zone_start_pfn,
>> zone_end_pfn);
>> }
>> - totalram_pages += totalhigh_pages;
>
> Hmm? I haven't looked at what totalram_pages is used for but could you
> explain why this change is safe?

Never mind, I should have read the patchset more carefully:

Reviewed-by: Pekka Enberg <[email protected]>

2013-03-10 10:44:21

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH v2, part2 01/10] mm: introduce free_highmem_page() helper to free highmem pages into buddy system

On Sun, Mar 10, 2013 at 10:01 AM, Jiang Liu <[email protected]> wrote:
> 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 <[email protected]>

Reviewed-by: Pekka Enberg <[email protected]>

2013-03-12 21:42:19

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v2, part2 08/10] mm/SPARC: use free_highmem_page() to free highmem pages into buddy system

On Sun, 10 Mar 2013 16:01:08 +0800 Jiang Liu <[email protected]> wrote:

> Use helper function free_highmem_page() to free highmem pages into
> the buddy system.
>
> ...
>
> --- 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));
> }

This code isn't inside #ifdef CONFIG_HIGHMEM, but afaict that's OK
because CONFIG_HIGHMEM=n isn't possible on sparc32.

This patch and one other mistyped "free_highmem_page". I got lazy and
edited those patches in-place.

2013-03-13 06:34:55

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH v2, part2 08/10] mm/SPARC: use free_highmem_page() to free highmem pages into buddy system

On Tue, Mar 12, 2013 at 02:42:15PM -0700, Andrew Morton wrote:
> On Sun, 10 Mar 2013 16:01:08 +0800 Jiang Liu <[email protected]> wrote:
>
> > Use helper function free_highmem_page() to free highmem pages into
> > the buddy system.
> >
> > ...
> >
> > --- 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));
> > }
>
> This code isn't inside #ifdef CONFIG_HIGHMEM, but afaict that's OK
> because CONFIG_HIGHMEM=n isn't possible on sparc32.
Correct - from arch/sparc/Kconfig

config HIGHMEM
bool
default y if SPARC32


> This patch and one other mistyped "free_highmem_page". I got lazy and
> edited those patches in-place.
Good spot!

You can add my:
Acked-by: Sam Ravnborg <[email protected]>

Sam

2013-03-13 16:47:31

by Jiang Liu

[permalink] [raw]
Subject: Re: [PATCH v2, part2 08/10] mm/SPARC: use free_highmem_page() to free highmem pages into buddy system

On 03/13/2013 05:42 AM, Andrew Morton wrote:
> On Sun, 10 Mar 2013 16:01:08 +0800 Jiang Liu <[email protected]> wrote:
>
>> Use helper function free_highmem_page() to free highmem pages into
>> the buddy system.
>>
>> ...
>>
>> --- 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));
>> }
>
> This code isn't inside #ifdef CONFIG_HIGHMEM, but afaict that's OK
> because CONFIG_HIGHMEM=n isn't possible on sparc32.
>
> This patch and one other mistyped "free_highmem_page". I got lazy and
> edited those patches in-place.
>
Hi Andrew,
Great thanks for fixing them!
Gerry