* [PATCH] m68k: move to a single instance of free_initmem()
@ 2012-10-23 3:40 gerg
2012-11-11 10:43 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: gerg @ 2012-10-23 3:40 UTC (permalink / raw)
To: linux-m68k, uclinux-dev; +Cc: Greg Ungerer
From: Greg Ungerer <gerg@uclinux.org>
Currently each sub-architecture has its own implementation if init_freemem().
There is two different cases that the various implementations deal with.
They either free the init memory, or they don't. We only need a single instance
to cover all cases.
The non-MMU version did some page alignment twidling, but this is not
neccessary. The current linker script enforces page alignment. It also
checked for CONFIG_RAMKERNEL, but this also is not necessary, the linker
script always keeps the init sections in RAM.
The MMU ColdFire version of free_initmem() was empty. There is no reason it
can't carry out the freeing of the init memory. So it is now changed and
tested to do this.
For the other MMU cases the code is the same. For the general Motorola MMU
case we free the init memory. For the SUN3 case we do nothing (though I
think it could safely free the init memory as well).
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
arch/m68k/mm/init.c | 22 ++++++++--------------
arch/m68k/mm/mcfmmu.c | 4 ----
arch/m68k/mm/motorola.c | 14 --------------
arch/m68k/mm/sun3mmu.c | 4 ----
4 files changed, 8 insertions(+), 36 deletions(-)
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index d0286db..4d7af92 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -103,32 +103,26 @@ void __init paging_init(void)
free_area_init(zones_size);
}
+#endif /* CONFIG_MMU */
+
void free_initmem(void)
{
-#ifdef CONFIG_RAMKERNEL
+#ifndef CONFIG_MMU_SUN3
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) {
+ 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 - PAGE_ALIGN((unsigned long) __init_begin)) >> 10,
- (int)(PAGE_ALIGN((unsigned long) __init_begin)),
- (int)(addr - PAGE_SIZE));
-#endif
+ (addr - (unsigned long) __init_begin) >> 10,
+ (unsigned int) __init_begin, (unsigned int) __init_end);
+#endif /* CONFIG_MMU_SUN3 */
}
-#endif /* CONFIG_MMU */
-
#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
#define VECTORS &vectors[0]
#else
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index 875b800..f58fafe 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -29,10 +29,6 @@ atomic_t nr_free_contexts;
struct mm_struct *context_mm[LAST_CONTEXT+1];
extern unsigned long num_pages;
-void free_initmem(void)
-{
-}
-
/*
* ColdFire paging_init derived from sun3.
*/
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 0dafa69..251c543 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -304,17 +304,3 @@ void __init paging_init(void)
}
}
-void free_initmem(void)
-{
- unsigned long addr;
-
- addr = (unsigned long)__init_begin;
- for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
- virt_to_page(addr)->flags &= ~(1 << PG_reserved);
- init_page_count(virt_to_page(addr));
- free_page(addr);
- totalram_pages++;
- }
-}
-
-
diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
index e080406..269f811 100644
--- a/arch/m68k/mm/sun3mmu.c
+++ b/arch/m68k/mm/sun3mmu.c
@@ -30,10 +30,6 @@ const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
extern unsigned long num_pages;
-void free_initmem(void)
-{
-}
-
/* For the sun3 we try to follow the i386 paging_init() more closely */
/* start_mem and end_mem have PAGE_OFFSET added already */
/* now sets up tables using sun3 PTEs rather than i386 as before. --m */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] m68k: move to a single instance of free_initmem()
2012-10-23 3:40 [PATCH] m68k: move to a single instance of free_initmem() gerg
@ 2012-11-11 10:43 ` Geert Uytterhoeven
2012-11-30 4:24 ` Greg Ungerer
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2012-11-11 10:43 UTC (permalink / raw)
To: gerg; +Cc: linux-m68k, uclinux-dev, Greg Ungerer
On Tue, Oct 23, 2012 at 5:40 AM, <gerg@snapgear.com> wrote:
> From: Greg Ungerer <gerg@uclinux.org>
>
> Currently each sub-architecture has its own implementation if init_freemem().
> There is two different cases that the various implementations deal with.
> They either free the init memory, or they don't. We only need a single instance
> to cover all cases.
>
> The non-MMU version did some page alignment twidling, but this is not
> neccessary. The current linker script enforces page alignment. It also
> checked for CONFIG_RAMKERNEL, but this also is not necessary, the linker
> script always keeps the init sections in RAM.
>
> The MMU ColdFire version of free_initmem() was empty. There is no reason it
> can't carry out the freeing of the init memory. So it is now changed and
> tested to do this.
>
> For the other MMU cases the code is the same. For the general Motorola MMU
> case we free the init memory. For the SUN3 case we do nothing (though I
> think it could safely free the init memory as well).
>
> Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> void free_initmem(void)
> {
> -#ifdef CONFIG_RAMKERNEL
> +#ifndef CONFIG_MMU_SUN3
> 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) {
> + 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 - PAGE_ALIGN((unsigned long) __init_begin)) >> 10,
> - (int)(PAGE_ALIGN((unsigned long) __init_begin)),
> - (int)(addr - PAGE_SIZE));
> -#endif
> + (addr - (unsigned long) __init_begin) >> 10,
> + (unsigned int) __init_begin, (unsigned int) __init_end);
Which is now BTW almost identical to free_initrd_mem(), so the common
parts can be extracted in a helper function.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] m68k: move to a single instance of free_initmem()
2012-11-11 10:43 ` Geert Uytterhoeven
@ 2012-11-30 4:24 ` Greg Ungerer
0 siblings, 0 replies; 3+ messages in thread
From: Greg Ungerer @ 2012-11-30 4:24 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-m68k, uclinux-dev, Greg Ungerer
Hi Geert,
On 11/11/12 20:43, Geert Uytterhoeven wrote:
> On Tue, Oct 23, 2012 at 5:40 AM, <gerg@snapgear.com> wrote:
[snip]
>> void free_initmem(void)
>> {
>> -#ifdef CONFIG_RAMKERNEL
>> +#ifndef CONFIG_MMU_SUN3
>> 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) {
>> + 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 - PAGE_ALIGN((unsigned long) __init_begin)) >> 10,
>> - (int)(PAGE_ALIGN((unsigned long) __init_begin)),
>> - (int)(addr - PAGE_SIZE));
>> -#endif
>> + (addr - (unsigned long) __init_begin) >> 10,
>> + (unsigned int) __init_begin, (unsigned int) __init_end);
>
> Which is now BTW almost identical to free_initrd_mem(), so the common
> parts can be extracted in a helper function.
Indeed it can. Well spotted :-)
Patch coming up.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: gerg@snapgear.com
SnapGear Group, McAfee PHONE: +61 7 3435 2888
8 Gardner Close FAX: +61 7 3217 5323
Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-30 4:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-23 3:40 [PATCH] m68k: move to a single instance of free_initmem() gerg
2012-11-11 10:43 ` Geert Uytterhoeven
2012-11-30 4:24 ` Greg Ungerer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox