* [PATCH] m68k: merge arch free memory functions into a single function
@ 2012-11-30 4:27 gerg
2012-12-01 3:49 ` Finn Thain
0 siblings, 1 reply; 3+ messages in thread
From: gerg @ 2012-11-30 4:27 UTC (permalink / raw)
To: linux-m68k, uclinux-dev; +Cc: Greg Ungerer
From: Greg Ungerer <gerg@uclinux.org>
We have separate architecture functions for freeing the initrd memory, and
for freeing the init sections. But they are essentially the same code, they
are doing exactly the same thing.
Create a common local arch free memory function and make the current users
call it to do the real work.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
arch/m68k/mm/init.c | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index f0e05bc..a95f6c4 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -105,21 +105,34 @@ void __init paging_init(void)
#endif /* CONFIG_MMU */
-void free_initmem(void)
+static void free_mem(const char *name, unsigned long start, unsigned long end)
{
-#ifndef CONFIG_MMU_SUN3
unsigned long addr;
+ int pages = 0;
- addr = (unsigned long) __init_begin;
- for (; addr < ((unsigned long) __init_end); addr += PAGE_SIZE) {
+ 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++;
+ 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);
+ pr_notice("Freeing %s memory: %dk freed (0x%lx-0x%lx)\n", name,
+ pages << (PAGE_SHIFT - 10), start, end);
+}
+
+#ifdef CONFIG_BLK_DEV_INITRD
+void free_initrd_mem(unsigned long start, unsigned long end)
+{
+ free_mem("initrd", start, end);
+}
+#endif
+
+void free_initmem(void)
+{
+#ifndef CONFIG_MMU_SUN3
+ free_mem("unused kernel", (unsigned long) __init_begin,
+ (unsigned long) __init_end);
#endif /* CONFIG_MMU_SUN3 */
}
@@ -208,18 +221,3 @@ void __init mem_init(void)
print_memmap();
}
-#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));
-}
-#endif
--
1.7.0.4
_______________________________________________
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 related [flat|nested] 3+ messages in thread
* Re: [PATCH] m68k: merge arch free memory functions into a single function
2012-11-30 4:27 [PATCH] m68k: merge arch free memory functions into a single function gerg
@ 2012-12-01 3:49 ` Finn Thain
2012-12-03 6:29 ` Greg Ungerer
0 siblings, 1 reply; 3+ messages in thread
From: Finn Thain @ 2012-12-01 3:49 UTC (permalink / raw)
To: gerg; +Cc: linux-m68k, uclinux-dev, Greg Ungerer
On Fri, 30 Nov 2012, gerg@snapgear.com wrote:
> - 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);
> + pr_notice("Freeing %s memory: %dk freed (0x%lx-0x%lx)\n", name,
> + pages << (PAGE_SHIFT - 10), start, end);
Perhaps "Freed %d KiB %s memory: 0x%lx - 0x%lx\n" is better (a tad shorter
and has the correct unit).
Finn
_______________________________________________
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
* Re: [PATCH] m68k: merge arch free memory functions into a single function
2012-12-01 3:49 ` Finn Thain
@ 2012-12-03 6:29 ` Greg Ungerer
0 siblings, 0 replies; 3+ messages in thread
From: Greg Ungerer @ 2012-12-03 6:29 UTC (permalink / raw)
To: Finn Thain; +Cc: linux-m68k, uclinux-dev, Greg Ungerer
Hi Finn,
On 01/12/12 13:49, Finn Thain wrote:
> On Fri, 30 Nov 2012, gerg@snapgear.com wrote:
>
>> - 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);
>> + pr_notice("Freeing %s memory: %dk freed (0x%lx-0x%lx)\n", name,
>> + pages << (PAGE_SHIFT - 10), start, end);
>
> Perhaps "Freed %d KiB %s memory: 0x%lx - 0x%lx\n" is better (a tad shorter
> and has the correct unit).
Sure. New patch coming up.
Thanks
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-03 6:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-30 4:27 [PATCH] m68k: merge arch free memory functions into a single function gerg
2012-12-01 3:49 ` Finn Thain
2012-12-03 6:29 ` Greg Ungerer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox