@@ -54,6 +54,7 @@ enum mem_cgroup_protection {
MEMCG_PROT_NONE,
MEMCG_PROT_LOW,
MEMCG_PROT_MIN,
+ MEMCG_PROT_SKIP, /* For zero usage case */
};
struct mem_cgroup_reclaim_cookie {
@@ -6292,7 +6292,7 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
usage = page_counter_read(&memcg->memory);
if (!usage)
- return MEMCG_PROT_NONE;
+ return MEMCG_PROT_SKIP;
emin = memcg->memory.min;
elow = memcg->memory.low;
@@ -2677,6 +2677,12 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc)
* thresholds (see get_scan_count).
*/
break;
+ case MEMCG_PROT_SKIP:
+ /*
+ * Skip scanning this memcg if the usage of it is
+ * zero.
+ */
+ continue;
}
reclaimed = sc->nr_reclaimed;
If the usage of a memcg is zero, we don't need to do useless work to scan it. That is a minor optimization. Cc: Roman Gushchin <guro@fb.com> Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- include/linux/memcontrol.h | 1 + mm/memcontrol.c | 2 +- mm/vmscan.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-)