linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] mm/memblock: truncate memblock if necessary
@ 2012-08-24 14:33 Wanpeng Li
  2012-08-24 14:33 ` [PATCH 2/5] mm/memblock: rename get_allocated_memblock_reserved_regions_info() Wanpeng Li
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Wanpeng Li @ 2012-08-24 14:33 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, Michal Hocko, KAMEZAWA Hiroyuki, Minchan Kim,
	Andrew Morton, Gavin Shan, Wanpeng Li

From: Gavin Shan <shangw@linux.vnet.ibm.com>

While enforcing memory limit on current memblock layout, it is
possible that we don't have to change the current memblock layout.
For example, the enforced limited size is bigger than the maximal
address of memory regions. Also, we don't have to change the memory
layout while the enforced limited size is more than the accumulative
size of all memory regions.

The patch checks them and won't change current memblock layout for
those cases, thus to reduce some overhead.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/memblock.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 4d9393c..c1fbb12 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -844,14 +844,14 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit)
 	unsigned long i;
 	phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX;
 
-	if (!limit)
+	if (!limit || limit >= memblock_end_of_DRAM())
 		return;
 
 	/* find out max address */
 	for (i = 0; i < memblock.memory.cnt; i++) {
 		struct memblock_region *r = &memblock.memory.regions[i];
 
-		if (limit <= r->size) {
+		if (limit < r->size) {
 			max_addr = r->base + limit;
 			break;
 		}
@@ -859,8 +859,12 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit)
 	}
 
 	/* truncate both memory and reserved regions */
-	__memblock_remove(&memblock.memory, max_addr, (phys_addr_t)ULLONG_MAX);
-	__memblock_remove(&memblock.reserved, max_addr, (phys_addr_t)ULLONG_MAX);
+	if (max_addr < (phys_addr_t)ULLONG_MAX) {
+		__memblock_remove(&memblock.memory, max_addr,
+						(phys_addr_t)ULLONG_MAX);
+		__memblock_remove(&memblock.reserved, max_addr,
+						(phys_addr_t)ULLONG_MAX);
+	}
 }
 
 static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr)
-- 
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-24 15:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-24 14:33 [PATCH 1/5] mm/memblock: truncate memblock if necessary Wanpeng Li
2012-08-24 14:33 ` [PATCH 2/5] mm/memblock: rename get_allocated_memblock_reserved_regions_info() Wanpeng Li
2012-08-24 15:39   ` Sam Ravnborg
2012-08-24 14:33 ` [PATCH 3/5] mm/memblock: reduce overhead in binary search Wanpeng Li
2012-08-24 14:33 ` [PATCH 4/5] mm/memblock: use existing interface to set nid Wanpeng Li
2012-08-24 14:33 ` [PATCH 5/5] mm/memblock: cleanup early_node_map[] related comments Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).