[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1273331860-14325-4-git-send-email-yinghai@kernel.org>
Date: Sat, 8 May 2010 08:17:21 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: David Miller <davem@...emloft.net>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH 03/22] lmb: Seperate __lmb_find_base() from __lmb_alloc_base()
So We can construct one generic __find_lmb_area() later
-v2: Add LMB_ERROR according to Ben.
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
include/linux/lmb.h | 1 +
mm/lmb.c | 21 +++++++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
index e14ea8d..d2e456b 100644
--- a/include/linux/lmb.h
+++ b/include/linux/lmb.h
@@ -17,6 +17,7 @@
#include <linux/mm.h>
#define MAX_LMB_REGIONS 128
+#define LMB_ERROR (-1ULL)
struct lmb_property {
u64 base;
diff --git a/mm/lmb.c b/mm/lmb.c
index d49c589..d130527 100644
--- a/mm/lmb.c
+++ b/mm/lmb.c
@@ -393,7 +393,7 @@ u64 __init lmb_alloc_base(u64 size, u64 align, u64 max_addr)
return alloc;
}
-u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
+static u64 __init __lmb_find_base(u64 size, u64 align, u64 max_addr)
{
long i, j;
u64 base = 0;
@@ -426,8 +426,6 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
j = lmb_overlaps_region(&lmb.reserved, base, size);
if (j < 0) {
/* this area isn't reserved, take it */
- if (lmb_add_region(&lmb.reserved, base, size) < 0)
- return 0;
return base;
}
res_base = lmb.reserved.region[j].base;
@@ -436,7 +434,22 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
base = lmb_align_down(res_base - size, align);
}
}
- return 0;
+ return LMB_ERROR;
+}
+
+u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
+{
+ u64 base;
+
+ base = __lmb_find_base(size, align, max_addr);
+
+ if (base == LMB_ERROR)
+ return 0;
+
+ if (lmb_add_region(&lmb.reserved, base, size) < 0)
+ return 0;
+
+ return base;
}
/* You must call lmb_analyze() before this. */
--
1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists