From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Mel Gorman <mgorman@suse.de>,
David Rientjes <rientjes@google.com>,
LKML <linux-kernel@vger.kernel.org>,
x86 maintainers <x86@kernel.org>
Cc: Jiang Liu <jiang.liu@huawei.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Yinghai Lu <yinghai@kernel.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Yasuaki ISIMATU <isimatu.yasuaki@jp.fujitsu.com>,
Andrew Morton <akpm@linux-foundation.org>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
Wen Congyang <wency@cn.fujitsu.com>,
linux-mm@kvack.org
Subject: [V5 PATCH 03/26] memory_hotplug: ensure every online node has NORMAL memory
Date: Mon, 29 Oct 2012 23:20:53 +0800 [thread overview]
Message-ID: <1351524078-20363-2-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1351523301-20048-1-git-send-email-laijs@cn.fujitsu.com>
Old memory hotplug code and new online/movable may cause a online node
don't have any normal memory, but memory-management acts bad when we have
nodes which is online but don't have any normal memory.
Example: it may cause a bound task fail on all kernel allocation and
cause the task can't create task or create other kernel object.
So we disable non-normal-memory-node here, we will enable it
when we prepared.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
mm/memory_hotplug.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index bdcdaf6..9af9641 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -589,6 +589,12 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
return 0;
}
+/* ensure every online node has NORMAL memory */
+static bool can_online_high_movable(struct zone *zone)
+{
+ return node_state(zone_to_nid(zone), N_NORMAL_MEMORY);
+}
+
/* check which state of node_states will be changed when online memory */
static void node_states_check_changes_online(unsigned long nr_pages,
struct zone *zone, struct memory_notify *arg)
@@ -654,6 +660,12 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
*/
zone = page_zone(pfn_to_page(pfn));
+ if ((zone_idx(zone) > ZONE_NORMAL || online_type == ONLINE_MOVABLE) &&
+ !can_online_high_movable(zone)) {
+ unlock_memory_hotplug();
+ return -1;
+ }
+
if (online_type == ONLINE_KERNEL && zone_idx(zone) == ZONE_MOVABLE) {
if (move_pfn_range_left(zone - 1, zone, pfn, pfn + nr_pages)) {
unlock_memory_hotplug();
@@ -1058,6 +1070,30 @@ check_pages_isolated(unsigned long start_pfn, unsigned long end_pfn)
return offlined;
}
+/* ensure the node has NORMAL memory if it is still online */
+static bool can_offline_normal(struct zone *zone, unsigned long nr_pages)
+{
+ struct pglist_data *pgdat = zone->zone_pgdat;
+ unsigned long present_pages = 0;
+ enum zone_type zt;
+
+ for (zt = 0; zt <= ZONE_NORMAL; zt++)
+ present_pages += pgdat->node_zones[zt].present_pages;
+
+ if (present_pages > nr_pages)
+ return true;
+
+ present_pages = 0;
+ for (; zt <= ZONE_MOVABLE; zt++)
+ present_pages += pgdat->node_zones[zt].present_pages;
+
+ /*
+ * we can't offline the last normal memory until all
+ * higher memory is offlined.
+ */
+ return present_pages == 0;
+}
+
/* check which state of node_states will be changed when offline memory */
static void node_states_check_changes_offline(unsigned long nr_pages,
struct zone *zone, struct memory_notify *arg)
@@ -1145,6 +1181,10 @@ static int __ref __offline_pages(unsigned long start_pfn,
node = zone_to_nid(zone);
nr_pages = end_pfn - start_pfn;
+ ret = -EINVAL;
+ if (zone_idx(zone) <= ZONE_NORMAL && !can_offline_normal(zone, nr_pages))
+ goto out;
+
/* set above range as isolated */
ret = start_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE, true);
if (ret)
--
1.7.4.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 prev parent reply other threads:[~2012-10-29 15:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1351523301-20048-1-git-send-email-laijs@cn.fujitsu.com>
2012-10-29 15:20 ` [V5 PATCH 02/26] memory_hotplug: handle empty zone when online_movable/online_kernel Lai Jiangshan
2012-10-29 15:20 ` Lai Jiangshan [this message]
2012-10-29 15:20 ` [V5 PATCH 08/26] memcontrol: use N_MEMORY instead N_HIGH_MEMORY Lai Jiangshan
2012-10-29 16:22 ` Michal Hocko
2012-10-29 20:40 ` David Rientjes
2012-10-29 20:58 ` Michal Hocko
2012-10-29 21:08 ` David Rientjes
2012-10-29 21:34 ` Michal Hocko
2012-10-31 13:18 ` Michal Hocko
2012-10-29 15:20 ` [V5 PATCH 09/26] oom: " Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 10/26] mm,migrate: " Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 11/26] mempolicy: " Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 12/26] hugetlb: " Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 13/26] vmstat: " Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 16/26] vmscan: " Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 17/26] page_alloc: use N_MEMORY instead N_HIGH_MEMORY change the node_states initialization Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 18/26] hotplug: update nodemasks management Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 19/26] numa: add CONFIG_MOVABLE_NODE for movable-dedicated node Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 20/26] memory_hotplug: allow online/offline memory to result movable node Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 21/26] page_alloc: add kernelcore_max_addr Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 24/26] memblock: limit memory address from memblock Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 25/26] memblock: compare current_limit with end variable at memblock_find_in_range_node() Lai Jiangshan
2012-10-29 15:21 ` [V5 PATCH 26/26] mempolicy: fix is_valid_nodemask() Lai Jiangshan
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=1351524078-20363-2-git-send-email-laijs@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=rientjes@google.com \
--cc=rusty@rustcorp.com.au \
--cc=wency@cn.fujitsu.com \
--cc=x86@kernel.org \
--cc=yinghai@kernel.org \
/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).