From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, Michal Hocko <mhocko@suse.cz>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Gavin Shan <shangw@linux.vnet.ibm.com>,
Wanpeng Li <liwanp@linux.vnet.ibm.com>
Subject: [PATCH 1/5] mm/memblock: truncate memblock if necessary
Date: Fri, 24 Aug 2012 22:33:36 +0800 [thread overview]
Message-ID: <1345818820-12102-1-git-send-email-liwanp@linux.vnet.ibm.com> (raw)
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>
next reply other threads:[~2012-08-24 14:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 14:33 Wanpeng Li [this message]
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
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=1345818820-12102-1-git-send-email-liwanp@linux.vnet.ibm.com \
--to=liwanp@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=minchan@kernel.org \
--cc=shangw@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).