From: Tejun Heo <tj@kernel.org>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH] memblock: Make sure reserved.regions is freed really
Date: Mon, 18 Jun 2012 16:09:39 -0700 [thread overview]
Message-ID: <20120618230939.GI32733@google.com> (raw)
In-Reply-To: <CAE9FiQUYsPFPnQvTsy9u3inM3hP5uWYtCRJMvQ=MvR7fCJTqzg@mail.gmail.com>
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
next prev parent reply other threads:[~2012-06-18 23:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-16 3:12 [PATCH] memblock: Make sure reserved.regions is freed really Yinghai Lu
2012-06-18 22:05 ` Tejun Heo
2012-06-18 22:58 ` Yinghai Lu
2012-06-18 23:09 ` Tejun Heo [this message]
2012-06-18 23:46 ` Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120618230939.GI32733@google.com \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox