Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3218ae14 authored by Yasunori Goto's avatar Yasunori Goto Committed by Linus Torvalds
Browse files

[PATCH] pgdat allocation for new node add (export kswapd start func)



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

[akpm@osdl.org: daemonize() isn't needed when using the kthread API]
Signed-off-by: default avatarYasunori Goto <y-goto@jp.fujitsu.com>
Signed-off-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 10ad400b
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -199,6 +199,8 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
}
}
#endif
#endif


extern int kswapd_run(int nid);

#ifdef CONFIG_MMU
#ifdef CONFIG_MMU
/* linux/mm/shmem.c */
/* linux/mm/shmem.c */
extern int shmem_unuse(swp_entry_t entry, struct page *page);
extern int shmem_unuse(swp_entry_t entry, struct page *page);
+26 −11
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@
#include <linux/notifier.h>
#include <linux/notifier.h>
#include <linux/rwsem.h>
#include <linux/rwsem.h>
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/kthread.h>


#include <asm/tlbflush.h>
#include <asm/tlbflush.h>
#include <asm/div64.h>
#include <asm/div64.h>
@@ -1223,7 +1224,6 @@ static int kswapd(void *p)
	};
	};
	cpumask_t cpumask;
	cpumask_t cpumask;


	daemonize("kswapd%d", pgdat->node_id);
	cpumask = node_to_cpumask(pgdat->node_id);
	cpumask = node_to_cpumask(pgdat->node_id);
	if (!cpus_empty(cpumask))
	if (!cpus_empty(cpumask))
		set_cpus_allowed(tsk, cpumask);
		set_cpus_allowed(tsk, cpumask);
@@ -1468,20 +1468,35 @@ static int cpu_callback(struct notifier_block *nfb,
}
}
#endif /* CONFIG_HOTPLUG_CPU */
#endif /* CONFIG_HOTPLUG_CPU */


static int __init kswapd_init(void)
/*
 * This kswapd start function will be called by init and 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;
	pg_data_t *pgdat = NODE_DATA(nid);
	int ret = 0;


	swap_setup();
	if (pgdat->kswapd)
	for_each_online_pgdat(pgdat) {
		return 0;
		pid_t pid;


		pid = kernel_thread(kswapd, pgdat, CLONE_KERNEL);
	pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
		BUG_ON(pid < 0);
	if (IS_ERR(pgdat->kswapd)) {
		read_lock(&tasklist_lock);
		/* failure at boot is fatal */
		pgdat->kswapd = find_task_by_pid(pid);
		BUG_ON(system_state == SYSTEM_BOOTING);
		read_unlock(&tasklist_lock);
		printk("Failed to start kswapd on node %d\n",nid);
		ret = -1;
	}
	}
	return ret;
}

static int __init kswapd_init(void)
{
	int nid;

	swap_setup();
	for_each_online_node(nid)
 		kswapd_run(nid);
	hotcpu_notifier(cpu_callback, 0);
	hotcpu_notifier(cpu_callback, 0);
	return 0;
	return 0;
}
}