linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yasunori Goto <y-goto@jp.fujitsu.com>
To: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mel@csn.ul.ie>,
	Christoph Lameter <cl@linux-foundation.org>,
	linux-mm <linux-mm@kvack.org>,
	Linux Kernel ML <linux-kernel@vger.kernel.org>
Subject: [RFC:Patch: 008/008](memory hotplug) remove_pgdat() function
Date: Thu, 31 Jul 2008 21:04:31 +0900	[thread overview]
Message-ID: <20080731210326.2A51.E1E9C6FF@jp.fujitsu.com> (raw)
In-Reply-To: <20080731203549.2A3F.E1E9C6FF@jp.fujitsu.com>

remove_pgdat() is main code for pgdat removing.
remove_pgdat() should be called for node-hotremove, but nothing calls
it. Sysfs interface (or anything else?) will be necessary.

And current offline_pages() has to be update zonelist and N_HIGH_MEMORY
if there is no present_pages on the node, and stop kswapd().


Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>


---
 mm/memory_hotplug.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)

Index: current/mm/memory_hotplug.c
===================================================================
--- current.orig/mm/memory_hotplug.c	2008-07-29 22:17:24.000000000 +0900
+++ current/mm/memory_hotplug.c	2008-07-29 22:17:32.000000000 +0900
@@ -241,6 +241,82 @@ static int __add_section(struct zone *zo
 	return register_new_memory(__pfn_to_section(phys_start_pfn));
 }
 
+static int cpus_busy_on_node(int nid)
+{
+	cpumask_t tmp = node_to_cpumask(nid);
+	int cpu, ret;
+
+	for_each_cpu_mask(cpu, tmp) {
+		if (cpu_online(cpu)) {
+			printk(KERN_INFO "cpu %d is busy\n", cpu);
+			ret = 1 ;
+		}
+	}
+	return 0;
+}
+
+static int sections_busy_on_node(struct pglist_data *pgdat)
+{
+	unsigned long section_nr, num, i;
+	int ret = 0;
+
+	section_nr = pfn_to_section_nr(pgdat->node_start_pfn);
+	num = pfn_to_section_nr(pgdat->node_spanned_pages);
+
+	for (i = section_nr; i < num; i++) {
+		if (present_section_nr(i)) {
+			printk(KERN_INFO "section %ld is busy\n", i);
+			ret = 1;
+		}
+	}
+	return ret;
+}
+
+void free_pgdat(int offline_nid, struct pglist_data *pgdat)
+{
+	struct page *page = virt_to_page(pgdat);
+
+	arch_refresh_nodedata(offline_nid, NULL);
+
+	if (PageSlab(page)) {
+		/* This pgdat is allocated on other node via hot-add */
+		arch_free_nodedata(pgdat);
+		return;
+	}
+
+	if (offline_nid != page_to_nid(page)) {
+		/* This pgdat is allocated on other node as memoryless node */
+		put_page_bootmem(page);
+		return;
+	}
+
+	/*
+	 * Ok. This pgdat is same node of offlining node.
+	 * Don't free it. Because this area will be removed physically at
+	 * next step.
+	 */
+
+}
+
+int remove_pgdat(int nid)
+{
+	struct pglist_data *pgdat = NODE_DATA(nid);
+
+	if (cpus_busy_on_node(nid))
+		return -EBUSY;
+
+	if (sections_busy_on_node(pgdat))
+		return -EBUSY;
+
+	node_set_offline(nid);
+	synchronize_sched();
+	synchronize_srcu(&pgdat_remove_srcu);
+
+	free_pgdat(nid, pgdat);
+
+	return 0;
+}
+
 #ifdef CONFIG_SPARSEMEM_VMEMMAP
 static int __remove_section(struct zone *zone, struct mem_section *ms)
 {
@@ -473,7 +549,6 @@ static void rollback_node_hotadd(int nid
 	return;
 }
 
-
 int add_memory(int nid, u64 start, u64 size)
 {
 	pg_data_t *pgdat = NULL;
@@ -842,6 +917,14 @@ repeat:
 	vm_total_pages = nr_free_pagecache_pages();
 	writeback_set_ratelimit();
 
+	if (zone->present_pages == 0)
+		build_all_zonelists();
+
+	if (zone->zone_pgdat->node_present_pages == 0) {
+		node_clear_state(node, N_HIGH_MEMORY);
+		kswapd_stop(node);
+	}
+
 	memory_notify(MEM_OFFLINE, &arg);
 	return 0;
 

-- 
Yasunori Goto 


--
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:[~2008-07-31 12:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-31 11:50 [RFC:Patch: 000/008](memory hotplug) rough idea of pgdat removing Yasunori Goto
2008-07-31 11:55 ` [RFC:Patch: 001/008](memory hotplug) change parameter from pointer of zonelist to node id Yasunori Goto
2008-07-31 11:56 ` [RFC:Patch: 002/008](memory hotplug) pgdat_remove_read_lock/unlock Yasunori Goto
2008-07-31 11:58 ` [RFC:Patch: 003/008](memory hotplug) check node online in __alloc_pages Yasunori Goto
2008-07-31 12:00 ` [RFC:Patch: 004/008](memory hotplug) Use lock for for_each_online_node Yasunori Goto
2008-07-31 12:01 ` [RFC:Patch: 005/008](memory hotplug) check node online before NODE_DATA and so on Yasunori Goto
2008-07-31 12:02 ` [RFC:Patch: 006/008](memory hotplug) kswapd_stop() definition Yasunori Goto
2008-07-31 12:03 ` [RFC:Patch: 007/008](memory hotplug) callback routine for mempolicy Yasunori Goto
2008-07-31 12:04 ` Yasunori Goto [this message]
2008-09-06 14:21   ` [RFC:Patch: 008/008](memory hotplug) remove_pgdat() function Peter Zijlstra
2008-09-08  3:07     ` Yasunori Goto
2008-07-31 14:04 ` [RFC:Patch: 000/008](memory hotplug) rough idea of pgdat removing Christoph Lameter
2008-08-01  9:42   ` Yasunori Goto
2008-08-01 13:51     ` Christoph Lameter
2008-08-02  0:16       ` Yasunori Goto
2008-08-04 13:25         ` Christoph Lameter
2008-08-05  6:39           ` Yasunori Goto
2008-08-05 11:14             ` Mel Gorman
2008-08-05 17:08               ` Christoph Lameter

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=20080731210326.2A51.E1E9C6FF@jp.fujitsu.com \
    --to=y-goto@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=pbadari@us.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