Commit abe1a624 authored by Liu Shixin's avatar Liu Shixin
Browse files

mm/memcg: introduce mem_cgroup_scan_cgroups to scan all memcgs

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8S9BY


CVE: NA

--------------------------------

Introduce mem_cgroup_scan_cgroups to iterate over memcgs of a memory
cgroup hierarchy.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent ea6de9f6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -883,6 +883,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *);
void mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
			   int (*)(struct task_struct *, void *), void *arg);
void mem_cgroup_scan_cgroups(struct mem_cgroup *memcg,
			     void (*fn)(struct mem_cgroup *, void *),
			     void *arg);

static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg)
{
+18 −0
Original line number Diff line number Diff line
@@ -1310,6 +1310,24 @@ void mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
	}
}

/**
 * mem_cgroup_scan_cgroups - iterate over memcgs of a memory cgroup hierarchy
 * @memcg: hierarchy root
 * @fn: function to call for each memcg
 * @arg: argument passed to @fn
 *
 * This function iterates over memcg attached to @memcg or to any of its
 * descendants and calls @fn for each memcgs.
 */
void mem_cgroup_scan_cgroups(struct mem_cgroup *memcg,
			     void (*fn)(struct mem_cgroup *, void *), void *arg)
{
	struct mem_cgroup *iter;

	for_each_mem_cgroup_tree(iter, memcg)
		fn(iter, arg);
}

#ifdef CONFIG_DEBUG_VM
void lruvec_memcg_debug(struct lruvec *lruvec, struct folio *folio)
{