public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Cc: jbeulich@novell.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86: make e820_update_range to handle small range update
Date: Thu, 12 Mar 2009 22:36:01 -0700	[thread overview]
Message-ID: <49B9F0C1.10402@kernel.org> (raw)
In-Reply-To: <tip-773e673de27297d07d852e7e9bfd1a695cae1da2@git.kernel.org>


Impact: enhance to handle more case.

try to handle new range could be covered by one entry.

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

---
 arch/x86/kernel/e820.c |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

Index: linux-2.6/arch/x86/kernel/e820.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/e820.c
+++ linux-2.6/arch/x86/kernel/e820.c
@@ -427,6 +427,7 @@ static u64 __init __e820_update_range(st
 					u64 size, unsigned old_type,
 					unsigned new_type)
 {
+	u64 end;
 	unsigned int i;
 	u64 real_updated_size = 0;
 
@@ -435,21 +436,35 @@ static u64 __init __e820_update_range(st
 	if (size > (ULLONG_MAX - start))
 		size = ULLONG_MAX - start;
 
+	end = start + size;
 	for (i = 0; i < e820x->nr_map; i++) {
 		struct e820entry *ei = &e820x->map[i];
 		u64 final_start, final_end;
+		u64 ei_end;
+
 		if (ei->type != old_type)
 			continue;
-		/* totally covered? */
-		if (ei->addr >= start &&
-		    (ei->addr + ei->size) <= (start + size)) {
+
+		ei_end = ei->addr + ei->size;
+		/* totally covered by new range? */
+		if (ei->addr >= start && ei_end <= end) {
 			ei->type = new_type;
 			real_updated_size += ei->size;
 			continue;
 		}
+
+		/* new range is totally covered? */
+		if (ei->addr < start && ei_end > end) {
+			__e820_add_region(e820x, start, size, new_type);
+			__e820_add_region(e820x, end, ei_end - end, ei->type);
+			ei->size = start - ei->addr;
+			real_updated_size += size;
+			continue;
+		}
+
 		/* partially covered */
 		final_start = max(start, ei->addr);
-		final_end = min(start + size, ei->addr + ei->size);
+		final_end = min(end, ei_end);
 		if (final_start >= final_end)
 			continue;
 

  reply	other threads:[~2009-03-13  5:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12 12:57 [PATCH] x86: clean up output resulting from update_mptable option Jan Beulich
2009-03-13  2:34 ` [tip:x86/mm] " Jan Beulich
2009-03-13  4:35   ` [PATCH] x86: fix e820_update_range() Yinghai Lu
2009-03-13  4:39     ` [tip:x86/mm] " Yinghai Lu
2009-03-13  5:36       ` Yinghai Lu [this message]
2009-03-14 11:39         ` [tip:x86/mm] x86: make e820_update_range() handle small range update Yinghai Lu
2009-03-14 12:17           ` Ingo Molnar
2009-03-14 18:21             ` Yinghai Lu
2009-03-14 18:40               ` Ingo Molnar
2009-03-14 21:32                 ` Yinghai Lu
2009-03-15  6:04                   ` Ingo Molnar
2009-03-15  6:20                     ` Yinghai Lu
2009-03-15  6:25                       ` Ingo Molnar
2009-03-15  6:12                   ` [tip:x86/mm] x86: fix 64k corruption-check Yinghai Lu
2009-03-13  7:57     ` [PATCH] x86: fix e820_update_range() Jan Beulich
2009-03-13 11:13       ` Ingo Molnar
2009-03-13 18:22         ` 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=49B9F0C1.10402@kernel.org \
    --to=yinghai@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox