[RFC PATCH -v3 1/2] lmb: seperate region array from lmb_region struct

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Yinghai Lu
Date: Tuesday, March 23, 2010 - 3:36 am

lmb_init() connect them back.

also add region_array_size in lmb_region to tack the region array size.

-v3: seperate lmb core change to seperated patch

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

---
 include/linux/lmb.h |    5 ++++-
 lib/lmb.c           |   11 ++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

Index: linux-2.6/include/linux/lmb.h
===================================================================
--- linux-2.6.orig/include/linux/lmb.h
+++ linux-2.6/include/linux/lmb.h
@@ -26,7 +26,8 @@ struct lmb_property {
 struct lmb_region {
 	unsigned long cnt;
 	u64 size;
-	struct lmb_property region[MAX_LMB_REGIONS+1];
+	struct lmb_property *region;
+	unsigned long region_array_size;
 };
 
 struct lmb {
@@ -37,6 +38,8 @@ struct lmb {
 };
 
 extern struct lmb lmb;
+extern struct lmb_property lmb_memory_region[MAX_LMB_REGIONS + 1];
+extern struct lmb_property lmb_reserved_region[MAX_LMB_REGIONS + 1];
 
 extern void __init lmb_init(void);
 extern void __init lmb_analyze(void);
Index: linux-2.6/lib/lmb.c
===================================================================
--- linux-2.6.orig/lib/lmb.c
+++ linux-2.6/lib/lmb.c
@@ -18,6 +18,8 @@
 #define LMB_ALLOC_ANYWHERE	0
 
 struct lmb lmb;
+struct lmb_property lmb_memory_region[MAX_LMB_REGIONS + 1];
+struct lmb_property lmb_reserved_region[MAX_LMB_REGIONS + 1];
 
 static int lmb_debug;
 
@@ -106,6 +108,11 @@ static void lmb_coalesce_regions(struct
 
 void __init lmb_init(void)
 {
+	lmb.memory.region   = lmb_memory_region;
+	lmb.memory.region_array_size   = ARRAY_SIZE(lmb_memory_region);
+	lmb.reserved.region = lmb_reserved_region;
+	lmb.reserved.region_array_size = ARRAY_SIZE(lmb_reserved_region);
+
 	/* Create a dummy zero size LMB which will get coalesced away later.
 	 * This simplifies the lmb_add() code below...
 	 */
@@ -169,7 +176,7 @@ static long lmb_add_region(struct lmb_re
 
 	if (coalesced)
 		return coalesced;
-	if (rgn->cnt >= MAX_LMB_REGIONS)
+	if (rgn->cnt >= (rgn->region_array_size - 1))
 		return -1;
 
 	/* Couldn't coalesce the LMB, so add it to the sorted table. */
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH -v3 1/2] lmb: seperate region array from lmb_re ..., Yinghai Lu, (Tue Mar 23, 3:36 am)
Re: [RFC PATCH -v3 1/2] lmb: seperate region array from lm ..., Benjamin Herrenschmidt, (Tue Mar 23, 9:45 pm)
[RFC PATCH -v4 2/2] x86: use lmb to replace early_res, Yinghai Lu, (Tue Mar 23, 10:37 pm)
Re: [RFC PATCH -v3 1/2] lmb: seperate region array from lm ..., Benjamin Herrenschmidt, (Wed Mar 24, 12:41 am)