[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120618230939.GI32733@google.com>
Date: Mon, 18 Jun 2012 16:09:39 -0700
From: Tejun Heo <tj@...nel.org>
To: Yinghai Lu <yinghai@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org,
Benjamin Herrenschmidt <benh@...nel.crashing.org>
Subject: Re: [PATCH] memblock: Make sure reserved.regions is freed really
Hey, Yinghai.
On Mon, Jun 18, 2012 at 03:58:52PM -0700, Yinghai Lu wrote:
> > Hmmm... nice catch but I think it's a bit complex and ugly. In this
> > case, we *know* that the region isn't gonna be split. Maybe a better
> > option is to add something like the following?
>
> how do you know __pa(memblock.reserved.regions) would not be merged
> with other entries
> in reserved.regions?
>
> >
> > void memblock_remove_region_by_ptr(struct memblock_type *type,
> > struct memblock_region *r)
> > {
> > WARN_ON(/* make sure @r is inside @type->regions */);
> > memblock_remove_region(type, r - type->regions);
> > }
>
> you want to change
Heh, you're right. My suggestion was completely bonkers. Sorry about
that. Hmm.... how about separating out removal pre-expansion and
doing it before calling into free? ie. something like
static int memblock_prepare_for_isolation(struct memblock_type *type)
{
/* we'll create at most two more regions */
while (type->cnt + 2 > type->max)
if (memblock_double_array(type) < 0)
return -ENOMEM;
return 0;
}
int __init_memblock memblock_free_reserved_regions(void)
{
int ret;
if (memblock.reserved.regions == memblock_reserved_init_regions)
return 0;
ret = memblock_prepare_for_isolation(&memblock.reserved);
if (ret)
return ret;
ret = memblock_free(__pa(memblock.reserved.regions),
sizeof(struct memblock_region) * memblock.reserved.max);
WARN_ON(ret || memblock.reserved.regions has changed);
return ret;
}
Thanks.
--
tejun
--
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