linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH: 011/017](RFC) Memory hotplug for new nodes v.3. (start kswapd)
@ 2006-03-08 13:42 Yasunori Goto
  2006-03-09 12:01 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Yasunori Goto @ 2006-03-08 13:42 UTC (permalink / raw)
  To: Luck, Tony, Andi Kleen, Joel Schopp, Dave Hansen
  Cc: linux-ia64, Linux Kernel ML, linux-mm, Andrew Morton

When node is hot-added, kswapd for the node should start.
This export kswapd start function as kswapd_run().


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

Index: pgdat6/mm/vmscan.c
===================================================================
--- pgdat6.orig/mm/vmscan.c	2006-03-06 18:25:37.000000000 +0900
+++ pgdat6/mm/vmscan.c	2006-03-06 18:26:25.000000000 +0900
@@ -35,6 +35,7 @@
 #include <linux/notifier.h>
 #include <linux/rwsem.h>
 #include <linux/delay.h>
+#include <linux/kthread.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
@@ -1842,17 +1843,36 @@ static int __devinit cpu_callback(struct
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
+/*
+ * This kswapd start function will be called by init anod node-hot-add.
+ * On node-hot-add, kswapd will moved to proper cpus if cpus are hot-added.
+ */
+int kswapd_run(int nid)
+{
+	pg_data_t *pgdat = NODE_DATA(nid);
+	int ret = 0;
+
+	if (pgdat->kswapd)
+		return 0;
+
+	pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
+	if (pgdat->kswapd == ERR_PTR(-ENOMEM)) {
+		/* failure at boot is fatal */
+		BUG_ON(system_state == SYSTEM_BOOTING);
+		printk("faled to run kswapd on node %d\n",nid);
+		ret = -1;
+	}
+	return ret;
+}
+EXPORT_SYMBOL(kswapd_run);
+
 static int __init kswapd_init(void)
 {
-	pg_data_t *pgdat;
+	int nid;
 
 	swap_setup();
-	for_each_online_pgdat(pgdat) {
-		pid_t pid;
-
-		pid = kernel_thread(kswapd, pgdat, CLONE_KERNEL);
-		BUG_ON(pid < 0);
-		pgdat->kswapd = find_task_by_pid(pid);
+	for_each_online_node(nid) {
+		kswapd_run(nid);
 	}
 	total_memory = nr_free_pagecache_pages();
 	hotcpu_notifier(cpu_callback, 0);
Index: pgdat6/include/linux/swap.h
===================================================================
--- pgdat6.orig/include/linux/swap.h	2006-03-06 18:25:37.000000000 +0900
+++ pgdat6/include/linux/swap.h	2006-03-06 18:26:25.000000000 +0900
@@ -208,6 +208,11 @@ static inline int migrate_pages(struct l
 #define fail_migrate_page NULL
 #endif
 
+#ifdef CONFIG_MEMORY_HOTPLUG
+/* start new kswapd for new node */
+extern int kswapd_run(int nid);
+#endif
+
 #ifdef CONFIG_MMU
 /* linux/mm/shmem.c */
 extern int shmem_unuse(swp_entry_t entry, struct page *page);

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-09 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-08 13:42 [PATCH: 011/017](RFC) Memory hotplug for new nodes v.3. (start kswapd) Yasunori Goto
2006-03-09 12:01 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox