Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30725
b: refs/heads/master
c: 3218ae1
h: refs/heads/master
i:
  30723: b3839e4
v: v3
  • Loading branch information
Yasunori Goto authored and Linus Torvalds committed Jun 28, 2006
1 parent dcd3a95 commit 9a03cd8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 10ad400b49aca15ecf83b0fde7e35e4064b15c85
refs/heads/master: 3218ae14b1e3ee2ab81df30ed690c8e864d23316
2 changes: 2 additions & 0 deletions trunk/include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
}
#endif

extern int kswapd_run(int nid);

#ifdef CONFIG_MMU
/* linux/mm/shmem.c */
extern int shmem_unuse(swp_entry_t entry, struct page *page);
Expand Down
37 changes: 26 additions & 11 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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>
Expand Down Expand Up @@ -1223,7 +1224,6 @@ static int kswapd(void *p)
};
cpumask_t cpumask;

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

/*
* 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 = NODE_DATA(nid);
int ret = 0;

if (pgdat->kswapd)
return 0;

pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
if (IS_ERR(pgdat->kswapd)) {
/* failure at boot is fatal */
BUG_ON(system_state == SYSTEM_BOOTING);
printk("Failed to start kswapd on node %d\n",nid);
ret = -1;
}
return ret;
}

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);
read_lock(&tasklist_lock);
pgdat->kswapd = find_task_by_pid(pid);
read_unlock(&tasklist_lock);
}
for_each_online_node(nid)
kswapd_run(nid);
hotcpu_notifier(cpu_callback, 0);
return 0;
}
Expand Down

0 comments on commit 9a03cd8

Please sign in to comment.