mm: workingset: don't drop refault information prematurely
[muen/linux.git] / mm / workingset.c
index 4516dd790129131d4d989d2967bf59c3645e51d4..7d5fa0dd2b38047ac60a3339bc8179ee0e8b3583 100644 (file)
@@ -364,7 +364,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
 {
        unsigned long max_nodes;
        unsigned long nodes;
 {
        unsigned long max_nodes;
        unsigned long nodes;
-       unsigned long cache;
+       unsigned long pages;
 
        nodes = list_lru_shrink_count(&shadow_nodes, sc);
 
 
        nodes = list_lru_shrink_count(&shadow_nodes, sc);
 
@@ -390,14 +390,20 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
         *
         * PAGE_SIZE / radix_tree_nodes / node_entries * 8 / PAGE_SIZE
         */
         *
         * PAGE_SIZE / radix_tree_nodes / node_entries * 8 / PAGE_SIZE
         */
+#ifdef CONFIG_MEMCG
        if (sc->memcg) {
        if (sc->memcg) {
-               cache = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid,
-                                                    LRU_ALL_FILE);
-       } else {
-               cache = node_page_state(NODE_DATA(sc->nid), NR_ACTIVE_FILE) +
-                       node_page_state(NODE_DATA(sc->nid), NR_INACTIVE_FILE);
-       }
-       max_nodes = cache >> (RADIX_TREE_MAP_SHIFT - 3);
+               struct lruvec *lruvec;
+
+               pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid,
+                                                    LRU_ALL);
+               lruvec = mem_cgroup_lruvec(NODE_DATA(sc->nid), sc->memcg);
+               pages += lruvec_page_state(lruvec, NR_SLAB_RECLAIMABLE);
+               pages += lruvec_page_state(lruvec, NR_SLAB_UNRECLAIMABLE);
+       } else
+#endif
+               pages = node_present_pages(sc->nid);
+
+       max_nodes = pages >> (RADIX_TREE_MAP_SHIFT - 3);
 
        if (!nodes)
                return SHRINK_EMPTY;
 
        if (!nodes)
                return SHRINK_EMPTY;