linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: wency@cn.fujitsu.com
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: rientjes@google.com, liuj97@gmail.com, len.brown@intel.com,
	benh@kernel.crashing.org, paulus@samba.org,
	minchan.kim@gmail.com, akpm@linux-foundation.org,
	kosaki.motohiro@jp.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com,
	Wen Congyang <wency@cn.fujitsu.com>,
	Christoph Lameter <cl@linux.com>
Subject: [PATCH v3 9/9] memory-hotplug: allocate zone's pcp before onlining pages
Date: Fri, 19 Oct 2012 14:46:42 +0800	[thread overview]
Message-ID: <1350629202-9664-10-git-send-email-wency@cn.fujitsu.com> (raw)
In-Reply-To: <1350629202-9664-1-git-send-email-wency@cn.fujitsu.com>

From: Wen Congyang <wency@cn.fujitsu.com>

We use __free_page() to put a page to buddy system when onlining pages.
__free_page() will store NR_FREE_PAGES in zone's pcp.vm_stat_diff, so we
should allocate zone's pcp before onlining pages, otherwise we will lose
some free pages.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 mm/memory_hotplug.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index ec899a2..eb4c132 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -505,12 +505,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
 	 * So, zonelist must be updated after online.
 	 */
 	mutex_lock(&zonelists_mutex);
-	if (!populated_zone(zone))
+	if (!populated_zone(zone)) {
 		need_zonelists_rebuild = 1;
+		build_all_zonelists(NULL, zone);
+	}
 
 	ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages,
 		online_pages_range);
 	if (ret) {
+		if (need_zonelists_rebuild)
+			zone_pcp_reset(zone);
 		mutex_unlock(&zonelists_mutex);
 		printk(KERN_DEBUG "online_pages [mem %#010llx-%#010llx] failed\n",
 		       (unsigned long long) pfn << PAGE_SHIFT,
@@ -525,9 +529,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
 	zone->zone_pgdat->node_present_pages += onlined_pages;
 	if (onlined_pages) {
 		node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
-		if (need_zonelists_rebuild)
-			build_all_zonelists(NULL, zone);
-		else
+		if (!need_zonelists_rebuild)
 			zone_pcp_update(zone);
 	}
 
-- 
1.7.1

--
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>

  parent reply	other threads:[~2012-10-19  6:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19  6:46 [PATCH v3 0/9] bugfix for memory hotplug wency
2012-10-19  6:46 ` [PATCH v3 1/9] suppress "Device memoryX does not have a release() function" warning wency
2012-10-19  6:46 ` [PATCH v3 2/9] suppress "Device nodeX " wency
2012-10-19  6:53   ` KOSAKI Motohiro
2012-10-22 22:52   ` Andrew Morton
2012-10-22 23:00     ` Greg KH
2012-10-19  6:46 ` [PATCH v3 3/9] memory-hotplug: flush the work for the node when the node is offlined wency
2012-10-19  7:01   ` KOSAKI Motohiro
2012-10-19  7:28     ` Wen Congyang
2012-10-19  6:46 ` [PATCH v3 4/9] clear the memory to store struct page wency
2012-10-19  7:02   ` KOSAKI Motohiro
2012-10-26  9:44   ` Wen Congyang
2012-10-29 21:10     ` Andrew Morton
2012-10-30  2:18       ` Wen Congyang
2012-10-30  2:41         ` Andrew Morton
2012-10-30  2:48           ` Wen Congyang
2012-10-19  6:46 ` [PATCH v3 5/9] memory-hotplug: skip HWPoisoned page when offlining pages wency
2012-10-19  6:46 ` [PATCH v3 6/9] memory-hotplug: update mce_bad_pages when removing the memory wency
2012-10-19  7:06   ` KOSAKI Motohiro
2012-10-19  7:18     ` Wen Congyang
2012-10-19  6:46 ` [PATCH v3 7/9] memory-hotplug: auto offline page_cgroup when onlining memory block failed wency
2012-10-19  6:46 ` [PATCH v3 8/9] memory-hotplug: fix NR_FREE_PAGES mismatch wency
2012-10-19  7:41   ` KOSAKI Motohiro
2012-10-19  8:41     ` Wen Congyang
2012-10-19  6:46 ` wency [this message]
2012-10-19  7:07   ` [PATCH v3 9/9] memory-hotplug: allocate zone's pcp before onlining pages KOSAKI Motohiro
2012-10-19  8:06 ` [PATCH v3 0/9] bugfix for memory hotplug Yasuaki Ishimatsu
2012-10-19  8:19   ` Yasuaki Ishimatsu
2012-10-19  8:45     ` Wen Congyang
2012-10-19  9:39       ` Yasuaki Ishimatsu
2012-10-19 10:15         ` Wen Congyang
2012-10-22 22:38         ` Andrew Morton

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=1350629202-9664-10-git-send-email-wency@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=cl@linux.com \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuj97@gmail.com \
    --cc=minchan.kim@gmail.com \
    --cc=paulus@samba.org \
    --cc=rientjes@google.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).