mm: workingset: size shadow nodes lru basing on file cache size
[linux-2.6-block.git] / mm / memory_hotplug.c
index 24ea06393816c58b43a857bb5e1cc05dbdfc4712..c832ef3565cc87e277084ca99702eb19f477c693 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/hugetlb.h>
 #include <linux/memblock.h>
 #include <linux/bootmem.h>
+#include <linux/compaction.h>
 
 #include <asm/tlbflush.h>
 
@@ -1054,7 +1055,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
        arg.nr_pages = nr_pages;
        node_states_check_changes_online(nr_pages, zone, &arg);
 
-       nid = pfn_to_nid(pfn);
+       nid = zone_to_nid(zone);
 
        ret = memory_notify(MEM_GOING_ONLINE, &arg);
        ret = notifier_to_errno(ret);
@@ -1094,7 +1095,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
        pgdat_resize_unlock(zone->zone_pgdat, &flags);
 
        if (onlined_pages) {
-               node_states_set_node(zone_to_nid(zone), &arg);
+               node_states_set_node(nid, &arg);
                if (need_zonelists_rebuild)
                        build_all_zonelists(NULL, NULL);
                else
@@ -1105,8 +1106,10 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
 
        init_per_zone_wmark_min();
 
-       if (onlined_pages)
-               kswapd_run(zone_to_nid(zone));
+       if (onlined_pages) {
+               kswapd_run(nid);
+               kcompactd_run(nid);
+       }
 
        vm_total_pages = nr_free_pagecache_pages();
 
@@ -1880,8 +1883,10 @@ repeat:
                zone_pcp_update(zone);
 
        node_states_clear_node(node, &arg);
-       if (arg.status_change_nid >= 0)
+       if (arg.status_change_nid >= 0) {
                kswapd_stop(node);
+               kcompactd_stop(node);
+       }
 
        vm_total_pages = nr_free_pagecache_pages();
        writeback_set_ratelimit();