All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shan Wei <shanwei88@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Samuel Liao <samuelliao@tencent.com>,
	Lin Feng <linfeng@cn.fujitsu.com>,
	hpa@linux.intel.com, yinghai@kernel.org,
	Kernel-Maillist <linux-kernel@vger.kernel.org>
Cc: davidshan <davidshan@tencent.com>
Subject: [PATCH buf-fix] kernel, range: fix broken mtrr_cleanup
Date: Sun, 09 Jun 2013 17:42:17 +0800	[thread overview]
Message-ID: <51B44DF9.5040705@gmail.com> (raw)

From: Samuel Liao <samuelliao@tencent.com>


commit fbe06b7bae7c9cf6ab05168fce5ee93b2f4bae7c broken the mtrr_cleanup
due to return incorrect merged range. this patch remove the empty range
by swapping with the last.

Error messages:
Jun  9 14:06:18 kernel: [    0.000000] *BAD*gran_size: 64K   chunk_size: 64K         num_reg: 4      lose cover RAM: -0G
Jun  9 14:06:18 kernel: [    0.000000] *BAD*gran_size: 64K   chunk_size: 128K        num_reg: 4      lose cover RAM: -0G
Jun  9 14:06:18 kernel: [    0.000000] *BAD*gran_size: 64K   chunk_size: 256K        num_reg: 4      lose cover RAM: -0G
Jun  9 14:06:18 kernel: [    0.000000] *BAD*gran_size: 64K   chunk_size: 512K        num_reg: 4      lose cover RAM: -0G


Signed-off-by: Samuel Liao <samuelliao@tencent.com>
---
 kernel/range.c | 15 ++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/kernel/range.c b/kernel/range.c
index eb911db..b723697 100644
--- a/kernel/range.c
+++ b/kernel/range.c
@@ -48,11 +48,18 @@ int add_range_with_merge(struct range *range, int az, int nr_range,
 		final_start = min(range[i].start, start);
 		final_end = max(range[i].end, end);
 
+		if (final_start == range[i].start && final_end == range[i].end)
+			return nr_range;
+
 		/* clear it and add it back for further merge */
-		range[i].start = 0;
-		range[i].end =  0;
-		return add_range_with_merge(range, az, nr_range,
-			final_start, final_end);
+		nr_range -= 1;
+		if (i != nr_range) {
+			range[i].start = range[nr_range].start;
+			range[i].end = range[nr_range].end;
+		}
+		range[nr_range].start = 0;
+		range[nr_range].end =  0;
+		i = -1;
 	}
 
 	/* Need to add it: */
-- 
1.8.2.1


             reply	other threads:[~2013-06-09  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09  9:42 Shan Wei [this message]
2013-06-09 21:34 ` [PATCH buf-fix] kernel, range: fix broken mtrr_cleanup Yinghai Lu
2013-06-13  2:18   ` [PATCH buf-fix] kernel, range: fix broken mtrr_cleanup(Internet mail) samuelliao(廖生苗)

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=51B44DF9.5040705@gmail.com \
    --to=shanwei88@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davidshan@tencent.com \
    --cc=hpa@linux.intel.com \
    --cc=linfeng@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuelliao@tencent.com \
    --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 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.