mm/memory_hotplug: prevalidate the address range being added with platform
[linux-2.6-microblaze.git] / mm / workingset.c
index 10e96de..cd39902 100644 (file)
@@ -263,10 +263,10 @@ void *workingset_eviction(struct page *page, struct mem_cgroup *target_memcg)
        VM_BUG_ON_PAGE(!PageLocked(page), page);
 
        lruvec = mem_cgroup_lruvec(target_memcg, pgdat);
-       workingset_age_nonresident(lruvec, thp_nr_pages(page));
        /* XXX: target_memcg can be NULL, go through lruvec */
        memcgid = mem_cgroup_id(lruvec_memcg(lruvec));
        eviction = atomic_long_read(&lruvec->nonresident_age);
+       workingset_age_nonresident(lruvec, thp_nr_pages(page));
        return pack_shadow(memcgid, pgdat, eviction, PageWorkingset(page));
 }
 
@@ -461,6 +461,8 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
        unsigned long pages;
 
        nodes = list_lru_shrink_count(&shadow_nodes, sc);
+       if (!nodes)
+               return SHRINK_EMPTY;
 
        /*
         * Approximate a reasonable limit for the nodes
@@ -503,9 +505,6 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
 
        max_nodes = pages >> (XA_CHUNK_SHIFT - 3);
 
-       if (!nodes)
-               return SHRINK_EMPTY;
-
        if (nodes <= max_nodes)
                return 0;
        return nodes - max_nodes;