[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4C5081E4.4090205@kernel.org>
Date: Wed, 28 Jul 2010 12:15:48 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: Benjamin Herrenschmidt <benh@...nel.crashing.org>
CC: Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andrew Morton <akpm@...ux-foundation.org>,
David Miller <davem@...emloft.net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
Jan Beulich <jbeulich@...ell.com>
Subject: Re: [PATCH 05/16] x86, memblock: Add get_free_all_memory_range()
On 07/27/2010 10:02 PM, Benjamin Herrenschmidt wrote:
> On Thu, 2010-07-22 at 11:43 -0700, Yinghai Lu wrote:
>>
>> + /* Take out region array itself at first*/
>> + if (memblock.reserved.regions != memblock_reserved_init_regions)
>> + memblock_free(__pa(memblock.reserved.regions), sizeof(struct memblock_region) * memblock.reserved.max);
>> +
>
> More of that horror. Don't.
>
> Another option from what i proposed earlier is to actually have a function
> inside mm/memblock to free it (memblock_free_arrays()) that does nothing
> if memblock is to survive init.
>
> I hate exporting variables or data structures like that. Functions are
> semantically a lot cleaner.
Please check if you are ok with this one. if so please put it in your branch.
then I could rebase the second half patchset and ask hpa to put all in tip.
Thanks
Yinghai
[PATCH] memblock: Add memblock_free/reserve_reserved_resgions()
So we can avoid export memblock_reserved_init_regions()
Suggested by Ben.
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
include/linux/memblock.h | 2 ++
mm/memblock.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+)
Index: linux-2.6/include/linux/memblock.h
===================================================================
--- linux-2.6.orig/include/linux/memblock.h
+++ linux-2.6/include/linux/memblock.h
@@ -48,6 +48,8 @@ extern int memblock_can_resize;
if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
u64 memblock_find_in_range(u64 start, u64 end, u64 size, u64 align);
+int memblock_free_reserved_regions(void);
+int memblock_reserve_reserved_regions(void);
extern void __init memblock_init(void);
extern void __init memblock_analyze(void);
Index: linux-2.6/mm/memblock.c
===================================================================
--- linux-2.6.orig/mm/memblock.c
+++ linux-2.6/mm/memblock.c
@@ -170,6 +170,30 @@ u64 __init_memblock memblock_find_in_ran
return memblock_find_base(size, align, start, end);
}
+/*
+ * Free memblock.reserved.regions
+ */
+int memblock_free_reserved_regions(void)
+{
+ if (memblock.reserved.regions == memblock_reserved_init_regions)
+ return 0;
+
+ return memblock_free(__pa(memblock.reserved.regions),
+ sizeof(struct memblock_region) * memblock.reserved.max);
+}
+
+/*
+ * Reserve memblock.reserved.regions
+ */
+int memblock_reserve_reserved_regions(void)
+{
+ if (memblock.reserved.regions == memblock_reserved_init_regions)
+ return 0;
+
+ return memblock_reserve(__pa(memblock.reserved.regions),
+ sizeof(struct memblock_region) * memblock.reserved.max);
+}
+
static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
{
unsigned long i;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists