From: Yinghai Lu <yinghai@kernel.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>,
Be
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 4/8] lmb: seperate region array from lmb_region struct
Date: Wed, 24 Mar 2010 03:34:17 -0700 [thread overview]
Message-ID: <1269426861-20903-5-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1269426861-20903-1-git-send-email-yinghai@kernel.org>
From: Yinghai Lu <yinghai@@kernel.org>
lmb_init() connect them back.
also add nr_regions in lmb_region to tack the region array size.
-v3: seperate lmb core change to seperated patch
-v4: according to Ingo, change >= x -1 to > x
change region_array_size to nr_regions
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
include/linux/lmb.h | 5 ++++-
lib/lmb.c | 9 ++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
index f3d1433..37fd29e 100644
--- a/include/linux/lmb.h
+++ b/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 nr_regions;
};
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);
diff --git a/lib/lmb.c b/lib/lmb.c
index b1fc526..ed4e433 100644
--- a/lib/lmb.c
+++ b/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 lmb_region *rgn,
void __init lmb_init(void)
{
+ lmb.memory.region = lmb_memory_region;
+ lmb.reserved.region = lmb_reserved_region;
+ lmb.memory.nr_regions = ARRAY_SIZE(lmb_memory_region);
+ lmb.reserved.nr_regions = 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_region *rgn, u64 base, u64 size)
if (coalesced)
return coalesced;
- if (rgn->cnt >= MAX_LMB_REGIONS)
+ if (rgn->cnt > rgn->nr_regions)
return -1;
/* Couldn't coalesce the LMB, so add it to the sorted table. */
--
1.6.4.2
WARNING: multiple messages have this Message-ID (diff)
From: Yinghai Lu <yinghai@kernel.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 4/8] lmb: seperate region array from lmb_region struct
Date: Wed, 24 Mar 2010 03:34:17 -0700 [thread overview]
Message-ID: <1269426861-20903-5-git-send-email-yinghai@kernel.org> (raw)
Message-ID: <20100324103417.c7IlF6TkvGk70ipbmbwXXKsS3TsRY807NhnzH8UJMow@z> (raw)
In-Reply-To: <1269426861-20903-1-git-send-email-yinghai@kernel.org>
From: Yinghai Lu <yinghai@@kernel.org>
lmb_init() connect them back.
also add nr_regions in lmb_region to tack the region array size.
-v3: seperate lmb core change to seperated patch
-v4: according to Ingo, change >= x -1 to > x
change region_array_size to nr_regions
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
include/linux/lmb.h | 5 ++++-
lib/lmb.c | 9 ++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
index f3d1433..37fd29e 100644
--- a/include/linux/lmb.h
+++ b/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 nr_regions;
};
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);
diff --git a/lib/lmb.c b/lib/lmb.c
index b1fc526..ed4e433 100644
--- a/lib/lmb.c
+++ b/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 lmb_region *rgn,
void __init lmb_init(void)
{
+ lmb.memory.region = lmb_memory_region;
+ lmb.reserved.region = lmb_reserved_region;
+ lmb.memory.nr_regions = ARRAY_SIZE(lmb_memory_region);
+ lmb.reserved.nr_regions = 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_region *rgn, u64 base, u64 size)
if (coalesced)
return coalesced;
- if (rgn->cnt >= MAX_LMB_REGIONS)
+ if (rgn->cnt > rgn->nr_regions)
return -1;
/* Couldn't coalesce the LMB, so add it to the sorted table. */
--
1.6.4.2
next prev parent reply other threads:[~2010-03-24 10:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-24 10:34 [PATCH -v4 00/08] use lmb with x86 Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` [PATCH 1/8] x86: do not free zero sized per cpu areas Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` [PATCH 2/8] x86: add find_e820_area_node Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` [PATCH 3/8] x86: add sanitize_e820_map Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu [this message]
2010-03-24 10:34 ` [PATCH 4/8] lmb: seperate region array from lmb_region struct Yinghai Lu
2010-03-24 10:34 ` [PATCH 5/8] x86: use lmb to replace early_res Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` [PATCH 6/8] x86: remove find_e820_area Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` [PATCH 7/8] early_res: prepare for other platform to use it Yinghai Lu
2010-03-24 10:34 ` Yinghai Lu
2010-03-24 10:34 ` [PATCH 8/8] powerpc : use early_res/nobootmem Yinghai Lu
2010-03-24 10:34 ` 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=1269426861-20903-5-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--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