mm: memcontrol: push down mem_cgroup_node_nr_lru_pages()
authorJohannes Weiner <hannes@cmpxchg.org>
Tue, 14 May 2019 00:18:05 +0000 (17:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 May 2019 16:47:46 +0000 (09:47 -0700)
mem_cgroup_node_nr_lru_pages() is just a convenience wrapper around
lruvec_page_state() that takes bitmasks of lru indexes and aggregates the
counts for those.

Replace callsites where the bitmask is simple enough with direct
lruvec_page_state() calls.

This removes the last extern user of mem_cgroup_node_nr_lru_pages(), so
make that function private again, too.

Link: http://lkml.kernel.org/r/20190228163020.24100-5-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/memcontrol.h
mm/memcontrol.c
mm/workingset.c

index 65f381b..30561a9 100644 (file)
@@ -501,9 +501,6 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
 void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
                int zid, int nr_pages);
 
-unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
-                                          int nid, unsigned int lru_mask);
-
 static inline
 unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
                enum lru_list lru, int zone_idx)
@@ -954,13 +951,6 @@ unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
        return 0;
 }
 
-static inline unsigned long
-mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
-                            int nid, unsigned int lru_mask)
-{
-       return 0;
-}
-
 static inline unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg)
 {
        return 0;
index 4000ea4..268a0bd 100644 (file)
@@ -725,7 +725,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,
        __this_cpu_add(memcg->stat_cpu->nr_page_events, nr_pages);
 }
 
-unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
+static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
                                           int nid, unsigned int lru_mask)
 {
        struct lruvec *lruvec = mem_cgroup_lruvec(NODE_DATA(nid), memcg);
@@ -1425,11 +1425,15 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
 static bool test_mem_cgroup_node_reclaimable(struct mem_cgroup *memcg,
                int nid, bool noswap)
 {
-       if (mem_cgroup_node_nr_lru_pages(memcg, nid, LRU_ALL_FILE))
+       struct lruvec *lruvec = mem_cgroup_lruvec(NODE_DATA(nid), memcg);
+
+       if (lruvec_page_state(lruvec, NR_INACTIVE_FILE) ||
+           lruvec_page_state(lruvec, NR_ACTIVE_FILE))
                return true;
        if (noswap || !total_swap_pages)
                return false;
-       if (mem_cgroup_node_nr_lru_pages(memcg, nid, LRU_ALL_ANON))
+       if (lruvec_page_state(lruvec, NR_INACTIVE_ANON) ||
+           lruvec_page_state(lruvec, NR_ACTIVE_ANON))
                return true;
        return false;
 
index 0bedf67..6419bae 100644 (file)
@@ -426,10 +426,11 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
 #ifdef CONFIG_MEMCG
        if (sc->memcg) {
                struct lruvec *lruvec;
+               int i;
 
-               pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid,
-                                                    LRU_ALL);
                lruvec = mem_cgroup_lruvec(NODE_DATA(sc->nid), sc->memcg);
+               for (pages = 0, i = 0; i < NR_LRU_LISTS; i++)
+                       pages += lruvec_page_state(lruvec, NR_LRU_BASE + i);
                pages += lruvec_page_state(lruvec, NR_SLAB_RECLAIMABLE);
                pages += lruvec_page_state(lruvec, NR_SLAB_UNRECLAIMABLE);
        } else