[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1269642114-16588-18-git-send-email-yinghai@kernel.org>
Date: Fri, 26 Mar 2010 15:21:47 -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>,
David Miller <davem@...emloft.net>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Johannes Weiner <hannes@...xchg.org>, linux-kernel@...r.kernel.org,
linux-arch@...r.kernel.org, Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH 17/24] lmb: Add lmb_memory_size()
It will return memory size in specified range according to lmb.memory.region
Try to share some code with lmb_free_memory_size() by passing get_free to
__lmb_memory_size().
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
include/linux/lmb.h | 1 +
mm/lmb.c | 18 +++++++++++++++++-
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
index 51a8653..285f287 100644
--- a/include/linux/lmb.h
+++ b/include/linux/lmb.h
@@ -102,6 +102,7 @@ void lmb_register_active_regions(int nid, unsigned long start_pfn,
unsigned long last_pfn);
u64 lmb_hole_size(u64 start, u64 end);
u64 lmb_free_memory_size(u64 addr, u64 limit);
+u64 lmb_memory_size(u64 addr, u64 limit);
#include <asm/lmb.h>
diff --git a/mm/lmb.c b/mm/lmb.c
index a98ab51..0dab3b6 100644
--- a/mm/lmb.c
+++ b/mm/lmb.c
@@ -756,7 +756,7 @@ void __init lmb_to_bootmem(u64 start, u64 end)
}
#endif
-u64 __init lmb_free_memory_size(u64 addr, u64 limit)
+static u64 __init __lmb_memory_size(u64 addr, u64 limit, bool get_free)
{
int i, count;
struct range *range;
@@ -786,6 +786,10 @@ u64 __init lmb_free_memory_size(u64 addr, u64 limit)
}
subtract_range(range, count, 0, addr);
subtract_range(range, count, limit, -1ULL);
+
+ /* Subtract lmb.reserved.region in range ? */
+ if (!get_free)
+ goto sort_and_count_them;
for (i = 0; i < lmb.reserved.cnt; i++) {
struct lmb_property *r = &lmb.reserved.region[i];
@@ -798,6 +802,8 @@ u64 __init lmb_free_memory_size(u64 addr, u64 limit)
subtract_range(range, count, final_start, final_end);
}
+
+sort_and_count_them:
nr_range = clean_sort_range(range, count);
free_size = 0;
@@ -807,6 +813,16 @@ u64 __init lmb_free_memory_size(u64 addr, u64 limit)
return free_size << PAGE_SHIFT;
}
+u64 __init lmb_free_memory_size(u64 addr, u64 limit)
+{
+ return __lmb_memory_size(addr, limit, true);
+}
+
+u64 __init lmb_memory_size(u64 addr, u64 limit)
+{
+ return __lmb_memory_size(addr, limit, false);
+}
+
static int __init find_overlapped_early(u64 start, u64 end)
{
int i;
--
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