mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
	"Jack Steiner" <steiner@sgi.com>, "Mike Travis" <travis@sgi.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org, "Huang,
	Ying" <ying.huang@intel.com>, "Andi Kleen" <andi@firstfloor.org>,
	"Ingo Molnar" <mingo@elte.hu>, Paul Jackson <pj@sgi.com>
Subject: [PATCH 9/10] x86 boot: longer comment explaining sanitize_e820_map routine
Date: Wed, 14 May 2008 08:15:52 -0700	[thread overview]
Message-ID: <20080514151552.148486.84448.sendpatchset@jackhammer.engr.sgi.com> (raw)
In-Reply-To: <20080514151504.148486.32236.sendpatchset@jackhammer.engr.sgi.com>

From: Paul Jackson <pj@sgi.com>

Elaborate on the comment for sanitize_e820_map(), epxlaining more what
it does, what it inputs, and what it returns.  Rearrange the placement of
this comment to fit kernel conventions, before the routine's code rather
than buried inside it.

Signed-off-by: Paul Jackson <pj@sgi.com>

---
 arch/x86/kernel/e820_64.c |   94 +++++++++++++++++++++++++++-------------------
 1 file changed, 56 insertions(+), 38 deletions(-)

--- 2.6.26-rc2-mm1.orig/arch/x86/kernel/e820_64.c	2008-05-14 03:07:30.399683852 -0700
+++ 2.6.26-rc2-mm1/arch/x86/kernel/e820_64.c	2008-05-14 03:07:34.755755053 -0700
@@ -506,9 +506,64 @@ static void __init e820_print_map(char *
  * Sanitize the BIOS e820 map.
  *
  * Some e820 responses include overlapping entries. The following
- * replaces the original e820 map with a new one, removing overlaps.
+ * replaces the original e820 map with a new one, removing overlaps,
+ * and resolving conflicting memory types in favor of highest
+ * numbered type.
  *
+ * The input parameter biosmap points to an array of 'struct
+ * e820entry' which on entry has elements in the range [0, *pnr_map)
+ * valid, and which has space for up to max_nr_map entries.
+ * On return, the resulting sanitized e820 map entries will be in
+ * overwritten in the same location, starting at biosmap.
+ *
+ * The integer pointed to by pnr_map must be valid on entry (the
+ * current number of valid entries located at biosmap) and will
+ * be updated on return, with the new number of valid entries
+ * (something no more than max_nr_map.)
+ *
+ * The return value from sanitize_e820_map() is zero if it
+ * successfully 'sanitized' the map entries passed in, and is -1
+ * if it did nothing, which can happen if either of (1) it was
+ * only passed one map entry, or (2) any of the input map entries
+ * were invalid (start + size < start, meaning that the size was
+ * so big the described memory range wrapped around through zero.)
+ *
+ *	Visually we're performing the following
+ *	(1,2,3,4 = memory types)...
+ *
+ *	Sample memory map (w/overlaps):
+ *	   ____22__________________
+ *	   ______________________4_
+ *	   ____1111________________
+ *	   _44_____________________
+ *	   11111111________________
+ *	   ____________________33__
+ *	   ___________44___________
+ *	   __________33333_________
+ *	   ______________22________
+ *	   ___________________2222_
+ *	   _________111111111______
+ *	   _____________________11_
+ *	   _________________4______
+ *
+ *	Sanitized equivalent (no overlap):
+ *	   1_______________________
+ *	   _44_____________________
+ *	   ___1____________________
+ *	   ____22__________________
+ *	   ______11________________
+ *	   _________1______________
+ *	   __________3_____________
+ *	   ___________44___________
+ *	   _____________33_________
+ *	   _______________2________
+ *	   ________________1_______
+ *	   _________________4______
+ *	   ___________________2____
+ *	   ____________________33__
+ *	   ______________________4_
  */
+
 int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
 				    int *pnr_map)
 {
@@ -529,43 +584,6 @@ int __init sanitize_e820_map(struct e820
 	int old_nr, new_nr, chg_nr;
 	int i;
 
-	/*
-		Visually we're performing the following
-		(1,2,3,4 = memory types)...
-
-		Sample memory map (w/overlaps):
-		   ____22__________________
-		   ______________________4_
-		   ____1111________________
-		   _44_____________________
-		   11111111________________
-		   ____________________33__
-		   ___________44___________
-		   __________33333_________
-		   ______________22________
-		   ___________________2222_
-		   _________111111111______
-		   _____________________11_
-		   _________________4______
-
-		Sanitized equivalent (no overlap):
-		   1_______________________
-		   _44_____________________
-		   ___1____________________
-		   ____22__________________
-		   ______11________________
-		   _________1______________
-		   __________3_____________
-		   ___________44___________
-		   _____________33_________
-		   _______________2________
-		   ________________1_______
-		   _________________4______
-		   ___________________2____
-		   ____________________33__
-		   ______________________4_
-	*/
-
 	/* if there's only one memory region, don't bother */
 	if (*pnr_map < 2)
 		return -1;

-- 
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <pj@sgi.com> 1.650.933.1373

  parent reply	other threads:[~2008-05-14 15:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-14 15:15 [PATCH 1/10] x86 boot: include missing smp.h header Paul Jackson
2008-05-14 15:15 ` [PATCH 2/10] x86 boot: remove some unused extern function declarations Paul Jackson
2008-05-14 15:15 ` [PATCH 3/10] x86 boot: add header comment to dmi.h stating what it is Paul Jackson
2008-05-14 15:15 ` [PATCH 4/10] x86 boot: simplify pageblock_bits enum declaration Paul Jackson
2008-05-14 15:15 ` [PATCH 5/10] x86 boot: minor code format fixes in e820 and efi routines Paul Jackson
2008-05-14 15:15 ` [PATCH 6/10] x86 boot: proper use of ARRAY_SIZE instead of repeated E820MAX constant Paul Jackson
2008-05-14 15:15 ` [PATCH 7/10] x86 boot: extend some internal memory map arrays to handle larger EFI input Paul Jackson
2008-05-14 15:15 ` [PATCH 8/10] x86 boot: change sanitize_e820_map parameter from byte to int to allow bigger memory maps Paul Jackson
2008-05-14 15:15 ` Paul Jackson [this message]
2008-05-14 15:15 ` [PATCH 10/10] x86 boot: add code to add BIOS provided EFI memory entries to kernel Paul Jackson
2008-05-16  0:03   ` Paul Jackson
2008-05-16 12:38     ` Ingo Molnar
2008-05-16 16:30       ` Paul Jackson
2008-05-18  6:49       ` Paul Jackson
2008-05-19 16:10         ` Ingo Molnar
2008-05-27  3:12   ` Huang, Ying
2008-05-27 19:08     ` Paul Jackson
2008-05-27 19:16       ` H. Peter Anvin
2008-05-28  9:59         ` Paul Jackson
2008-05-16 13:20 ` [PATCH 1/10] x86 boot: include missing smp.h header Mike Travis

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=20080514151552.148486.84448.sendpatchset@jackhammer.engr.sgi.com \
    --to=pj@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=steiner@sgi.com \
    --cc=tglx@linutronix.de \
    --cc=travis@sgi.com \
    --cc=ying.huang@intel.com \
    /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

Powered by JetHome