All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Russell King <linux@arm.linux.org.uk>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH/v2] mm/memblock: Properly handle overlaps and fix error path
Date: Wed, 09 Mar 2011 12:41:04 -0800	[thread overview]
Message-ID: <4D77E5E0.6010706@kernel.org> (raw)
In-Reply-To: <1299466980.8833.973.camel@pasglop>

On 03/06/2011 07:03 PM, Benjamin Herrenschmidt wrote:
> Currently memblock_reserve() or memblock_free() don't handle overlaps
> of any kind. There is some special casing for coalescing exactly
> adjacent regions but that's about it.
> 
> This is annoying because typically memblock_reserve() is used to
> mark regions passed by the firmware as reserved and we all know
> how much we can trust our firmwares...
> 
> Also, with the current code, if we do something it doesn't handle
> right such as trying to memblock_reserve() a large range spanning
> multiple existing smaller reserved regions for example, or doing
> overlapping reservations, it can silently corrupt the internal
> region array, causing odd errors much later on, such as allocations
> returning reserved regions etc...
> 
> This patch rewrites the underlying functions that add or remove a
> region to the arrays. The new code is a lot more robust as it fully
> handles overlapping regions. It's also, imho, simpler than the previous
> implementation.
> 
> In addition, while doing so, I found a bug where if we fail to double
> the array while adding a region, we would remove the last region of
> the array rather than the region we just allocated. This fixes it too.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 
> Hopefully not damaged with a spurious bit of email header this
> time around... sorry about that.

works on my setups...

[    0.000000] Subtract (26 early reservations)
[    0.000000]   [000009a000-000009efff]
[    0.000000]   [000009f400-00000fffff]
[    0.000000]   [0001000000-0003495048]
...
before:
[    0.000000] Subtract (27 early reservations)
[    0.000000]   [000009a000-000009efff]
[    0.000000]   [000009f400-00000fffff]
[    0.000000]   [00000f85b0-00000f86b3]
[    0.000000]   [0001000000-0003495048]

Acked-by: Yinghai Lu <yinghai@kernel.org>

WARNING: multiple messages have this Message-ID (diff)
From: Yinghai Lu <yinghai@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Russell King <linux@arm.linux.org.uk>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH/v2] mm/memblock: Properly handle overlaps and fix error path
Date: Wed, 09 Mar 2011 12:41:04 -0800	[thread overview]
Message-ID: <4D77E5E0.6010706@kernel.org> (raw)
In-Reply-To: <1299466980.8833.973.camel@pasglop>

On 03/06/2011 07:03 PM, Benjamin Herrenschmidt wrote:
> Currently memblock_reserve() or memblock_free() don't handle overlaps
> of any kind. There is some special casing for coalescing exactly
> adjacent regions but that's about it.
> 
> This is annoying because typically memblock_reserve() is used to
> mark regions passed by the firmware as reserved and we all know
> how much we can trust our firmwares...
> 
> Also, with the current code, if we do something it doesn't handle
> right such as trying to memblock_reserve() a large range spanning
> multiple existing smaller reserved regions for example, or doing
> overlapping reservations, it can silently corrupt the internal
> region array, causing odd errors much later on, such as allocations
> returning reserved regions etc...
> 
> This patch rewrites the underlying functions that add or remove a
> region to the arrays. The new code is a lot more robust as it fully
> handles overlapping regions. It's also, imho, simpler than the previous
> implementation.
> 
> In addition, while doing so, I found a bug where if we fail to double
> the array while adding a region, we would remove the last region of
> the array rather than the region we just allocated. This fixes it too.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 
> Hopefully not damaged with a spurious bit of email header this
> time around... sorry about that.

works on my setups...

[    0.000000] Subtract (26 early reservations)
[    0.000000]   [000009a000-000009efff]
[    0.000000]   [000009f400-00000fffff]
[    0.000000]   [0001000000-0003495048]
...
before:
[    0.000000] Subtract (27 early reservations)
[    0.000000]   [000009a000-000009efff]
[    0.000000]   [000009f400-00000fffff]
[    0.000000]   [00000f85b0-00000f86b3]
[    0.000000]   [0001000000-0003495048]

Acked-by: Yinghai Lu <yinghai@kernel.org>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-03-09 20:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-07  3:03 [PATCH/v2] mm/memblock: Properly handle overlaps and fix error path Benjamin Herrenschmidt
2011-03-07  3:03 ` Benjamin Herrenschmidt
2011-03-09 20:41 ` Yinghai Lu [this message]
2011-03-09 20:41   ` Yinghai Lu
2011-03-09 21:20   ` Benjamin Herrenschmidt
2011-03-09 21:20     ` Benjamin Herrenschmidt
2011-03-10  6:46     ` Ingo Molnar
2011-03-10  6:46       ` Ingo Molnar
2011-03-10  6:53       ` Benjamin Herrenschmidt
2011-03-10  6:53         ` Benjamin Herrenschmidt

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=4D77E5E0.6010706@kernel.org \
    --to=yinghai@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.