From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Nigel Cunningham <ncunningham@crca.org.au>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Yasunori Goto <y-goto@jp.fujitsu.com>,
Matt Tolentino <matthew.e.tolentino@intel.com>,
linux-pm@lists.osdl.org, Dave Hansen <haveblue@us.ibm.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org, pavel@suse.cz,
Mel Gorman <mel@skynet.ie>, Andy Whitcroft <apw@shadowen.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [linux-pm] [PATCH] hibernation should work ok with memory hotplug
Date: Thu, 6 Nov 2008 12:12:12 +0900 [thread overview]
Message-ID: <20081106121212.e609476d.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20081106110709.b168cc30.kamezawa.hiroyu@jp.fujitsu.com>
On Thu, 6 Nov 2008 11:07:09 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> Okay. then we can add "kernel thread for calling add/remove memory" and say
> "PLEASE WAIT UNTIL HIBERNATION IS READY".
>
> I can try that by myself but doesn't have suitable machine....
> I think I can show you pseudo code in hours. please wait a bit.
>
How about this one ? as a start step ?
I have no test environment. So please take this as a sample.
-Kame
=
Now, MEMORY_HOTPLUG and HIBERNATION is mutually exclusive in Kconfig.
That's because
- memory hotplug changes pgdat/zone/memmap range.
- hibernation countes # of memory based on pgdate/zone/memmap.
This patch adds rwsemaphore for making them not to run at the same time.
IIUC, add_memory() is called from following places.
- probe interface
- acpi handler
It seems both can sleep. (acpi handler uses sleepable memory allocator etc...)
online/offline handlers also sleeps.
Anyway, the most difficult thing is how to test this.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
mm/Kconfig | 2 -
mm/memory_hotplug.c | 61 +++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 54 insertions(+), 9 deletions(-)
Index: linux-2.6.27.4/mm/memory_hotplug.c
===================================================================
--- linux-2.6.27.4.orig/mm/memory_hotplug.c
+++ linux-2.6.27.4/mm/memory_hotplug.c
@@ -31,6 +31,13 @@
#include "internal.h"
+struct rw_semaphore memhp_mutex;
+
+static int init_memhp_mutex(void)
+{
+ init_rwsem(&memhp_mutex);
+}
+
/* add this memory to iomem resource */
static struct resource *register_memory_resource(u64 start, u64 size)
{
@@ -381,6 +388,7 @@ int online_pages(unsigned long pfn, unsi
int ret;
struct memory_notify arg;
+ down_read(&memhp_mutex);
arg.start_pfn = pfn;
arg.nr_pages = nr_pages;
arg.status_change_nid = -1;
@@ -392,6 +400,7 @@ int online_pages(unsigned long pfn, unsi
ret = memory_notify(MEM_GOING_ONLINE, &arg);
ret = notifier_to_errno(ret);
if (ret) {
+ up_read(&memhp_mutex);
memory_notify(MEM_CANCEL_ONLINE, &arg);
return ret;
}
@@ -415,6 +424,7 @@ int online_pages(unsigned long pfn, unsi
printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
nr_pages, pfn);
memory_notify(MEM_CANCEL_ONLINE, &arg);
+ up_read(&memhp_mutex);
return ret;
}
@@ -436,7 +446,7 @@ int online_pages(unsigned long pfn, unsi
if (onlined_pages)
memory_notify(MEM_ONLINE, &arg);
-
+ up_read(&memhp_mutex);
return 0;
}
#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
@@ -477,14 +487,18 @@ int add_memory(int nid, u64 start, u64 s
struct resource *res;
int ret;
+ down_read(&memhp_mutex);
res = register_memory_resource(start, size);
- if (!res)
+ if (!res) {
+ up_read(&memhp_mutex);
return -EEXIST;
-
+ }
if (!node_online(nid)) {
pgdat = hotadd_new_pgdat(nid, start);
- if (!pgdat)
+ if (!pgdat) {
+ up_read(&memhp_mutex);
return -ENOMEM;
+ }
new_pgdat = 1;
}
@@ -508,7 +522,7 @@ int add_memory(int nid, u64 start, u64 s
*/
BUG_ON(ret);
}
-
+ up_read(&memhp_mutex);
return ret;
error:
/* rollback pgdat allocation and others */
@@ -517,10 +531,12 @@ error:
if (res)
release_memory_resource(res);
+ up_read(&memhp_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(add_memory);
+
#ifdef CONFIG_MEMORY_HOTREMOVE
/*
* A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
@@ -750,20 +766,23 @@ int offline_pages(unsigned long start_pf
return -EINVAL;
if (!IS_ALIGNED(end_pfn, pageblock_nr_pages))
return -EINVAL;
+
/* This makes hotplug much easier...and readable.
we assume this for now. .*/
if (!test_pages_in_a_zone(start_pfn, end_pfn))
return -EINVAL;
+ down_read(&memhp_mutex);
zone = page_zone(pfn_to_page(start_pfn));
node = zone_to_nid(zone);
nr_pages = end_pfn - start_pfn;
/* set above range as isolated */
ret = start_isolate_page_range(start_pfn, end_pfn);
- if (ret)
+ if (ret) {
+ up_read(&memhp_mutex);
return ret;
-
+ }
arg.start_pfn = start_pfn;
arg.nr_pages = nr_pages;
arg.status_change_nid = -1;
@@ -838,6 +857,7 @@ repeat:
writeback_set_ratelimit();
memory_notify(MEM_OFFLINE, &arg);
+ up_read(&memhp_mutex);
return 0;
failed_removal:
@@ -846,7 +866,7 @@ failed_removal:
memory_notify(MEM_CANCEL_OFFLINE, &arg);
/* pushback to free area */
undo_isolate_page_range(start_pfn, end_pfn);
-
+ up_read(&memhp_mutex);
return ret;
}
#else
@@ -856,3 +876,34 @@ int remove_memory(u64 start, u64 size)
}
EXPORT_SYMBOL_GPL(remove_memory);
#endif /* CONFIG_MEMORY_HOTREMOVE */
+
+
+#ifdef CONFIG_HIBERNATION
+
+int memhp_hibenation_callback(struct notifier_block *self,
+ unsigned long action,
+ void *arg)
+{
+ int ret;
+
+ switch(action) {
+ case PM_HIBERNATION_PREPARE:
+ down_write(&memhp_mutex);
+ break;
+ case PM_POST_HIBERNATION:
+ up_write(&memhp_mutex);
+ break;
+ case PM_RESTORE_PREPARE:
+ down_write(&memhp_mutex);
+ break;
+ case PM_POST_RESTORE:
+ up_write(&memhp_mutex);
+ break;
+ default:
+ break;
+ }
+ return NOTIFY_OK;
+}
+#endif
+
+
Index: linux-2.6.27.4/mm/Kconfig
===================================================================
--- linux-2.6.27.4.orig/mm/Kconfig
+++ linux-2.6.27.4/mm/Kconfig
@@ -128,12 +128,9 @@ config SPARSEMEM_VMEMMAP
config MEMORY_HOTPLUG
bool "Allow for memory hot-add"
depends on SPARSEMEM || X86_64_ACPI_NUMA
- depends on HOTPLUG && !HIBERNATION && ARCH_ENABLE_MEMORY_HOTPLUG
+ depends on HOTPLUG && ARCH_ENABLE_MEMORY_HOTPLUG
depends on (IA64 || X86 || PPC64 || SUPERH || S390)
-comment "Memory hotplug is currently incompatible with Software Suspend"
- depends on SPARSEMEM && HOTPLUG && HIBERNATION
-
config MEMORY_HOTPLUG_SPARSE
def_bool y
depends on SPARSEMEM && MEMORY_HOTPLUG
--
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:[~2008-11-06 3:12 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081029105956.GA16347@atrey.karlin.mff.cuni.cz>
[not found] ` <200810291325.01481.rjw@sisk.pl>
2008-11-03 20:51 ` Andrew Morton
2008-11-03 21:18 ` [linux-pm] " Nigel Cunningham
2008-11-03 21:21 ` Dave Hansen
2008-11-03 22:24 ` Rafael J. Wysocki
2008-11-03 22:34 ` Dave Hansen
2008-11-03 23:05 ` Rafael J. Wysocki
2008-11-03 23:10 ` Dave Hansen
2008-11-04 0:29 ` Rafael J. Wysocki
2008-11-04 0:52 ` Dave Hansen
2008-11-03 23:39 ` Andy Whitcroft
2008-11-04 4:02 ` [linux-pm] " Nigel Cunningham
2008-11-04 7:08 ` Rafael J. Wysocki
2008-11-04 7:36 ` Dave Hansen
2008-11-04 8:54 ` Rafael J. Wysocki
2008-11-04 15:21 ` Dave Hansen
2008-11-04 15:35 ` Rafael J. Wysocki
2008-11-04 15:39 ` Dave Hansen
2008-11-04 16:34 ` Rafael J. Wysocki
2008-11-04 16:59 ` Dave Hansen
2008-11-05 0:38 ` KAMEZAWA Hiroyuki
2008-11-05 11:08 ` Rafael J. Wysocki
2008-11-06 0:14 ` KAMEZAWA Hiroyuki
2008-11-06 0:28 ` Dave Hansen
2008-11-06 0:53 ` KAMEZAWA Hiroyuki
2008-11-06 2:03 ` Nigel Cunningham
2008-11-06 2:13 ` KAMEZAWA Hiroyuki
2008-11-06 14:47 ` Alan Stern
2008-11-07 1:09 ` KAMEZAWA Hiroyuki
2008-11-06 8:47 ` Pavel Machek
2008-11-06 1:17 ` KAMEZAWA Hiroyuki
2008-11-06 1:43 ` Nigel Cunningham
2008-11-06 1:54 ` KAMEZAWA Hiroyuki
2008-11-06 1:59 ` KAMEZAWA Hiroyuki
2008-11-06 2:00 ` Nigel Cunningham
2008-11-06 2:07 ` KAMEZAWA Hiroyuki
2008-11-06 3:12 ` KAMEZAWA Hiroyuki [this message]
2008-11-06 3:28 ` Yasunori Goto
2008-11-06 6:04 ` KAMEZAWA Hiroyuki
2008-11-06 14:48 ` Alan Stern
2008-11-06 20:46 ` Nigel Cunningham
2008-11-06 9:12 ` Pavel Machek
2008-11-06 9:12 ` KAMEZAWA Hiroyuki
2008-11-06 9:26 ` Nigel Cunningham
2008-11-06 14:43 ` Alan Stern
2008-11-04 7:09 ` Dave Hansen
2008-11-04 7:30 ` Nigel Cunningham
2008-11-04 7:53 ` Dave Hansen
2008-11-05 9:10 ` Nigel Cunningham
2008-11-05 10:58 ` Rafael J. Wysocki
2008-11-05 16:23 ` Dave Hansen
2008-11-06 12:28 ` Pavel Machek
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=20081106121212.e609476d.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=apw@shadowen.org \
--cc=dave@linux.vnet.ibm.com \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@lists.osdl.org \
--cc=matthew.e.tolentino@intel.com \
--cc=mel@skynet.ie \
--cc=ncunningham@crca.org.au \
--cc=pavel@suse.cz \
--cc=rjw@sisk.pl \
--cc=y-goto@jp.fujitsu.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