hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8S9BY CVE: NA
--------------------------------
Re-introduce memcg_has_children to check whether a memcg is leaf.
Signed-off-by: Liu Shixin liushixin2@huawei.com --- include/linux/memcontrol.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 19a6d34992b0..5f5bf2466808 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1220,6 +1220,17 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, int memcg_get_swap_type(struct folio *folio); void memcg_remove_swapfile(int type);
+/* Test whether @memcg has children, dead or alive. */ +static inline bool memcg_has_children(struct mem_cgroup *memcg) +{ + bool ret; + + rcu_read_lock(); + ret = css_next_child(NULL, &memcg->css); + rcu_read_unlock(); + return ret; +} + #else /* CONFIG_MEMCG */
#define MEM_CGROUP_ID_SHIFT 0