Currently we only recharge pages from an offline memcg or reparented memcg. In the future we may explicitly introduce a need_recharge state for the memcg which should be recharged. Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> --- include/linux/memcontrol.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 9ecead1042b9..cf074156c6ac 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1755,6 +1755,18 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, rcu_read_unlock(); } +static inline bool memcg_need_recharge(struct mem_cgroup *memcg) +{ + if (!memcg || memcg == root_mem_cgroup) + return false; + /* + * Currently we only recharge pages from an offline memcg, + * in the future we may explicitly introduce a need_recharge + * state for the memcg which should be recharged. + */ + return memcg->kmemcg_id == memcg->id.id ? false : true; +} + #else static inline bool mem_cgroup_kmem_disabled(void) { @@ -1806,6 +1818,11 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, { } +static inline bool memcg_need_recharge(struct mem_cgroup *memcg) +{ + return false; +} + #endif /* CONFIG_MEMCG_KMEM */ #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP) -- 2.17.1