Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc0b5864 authored by Roman Gushchin's avatar Roman Gushchin Committed by Linus Torvalds
Browse files

mm: introduce mem_cgroup_put() helper

Introduce the mem_cgroup_put() helper, which helps to eliminate guarding
memcg css release with "#ifdef CONFIG_MEMCG" in multiple places.

Link: http://lkml.kernel.org/r/20180623000600.5818-2-guro@fb.com


Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarMichal Hocko <mhocko@kernel.org>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1a9b4b3d
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -378,6 +378,11 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){
	return css ? container_of(css, struct mem_cgroup, css) : NULL;
	return css ? container_of(css, struct mem_cgroup, css) : NULL;
}
}


static inline void mem_cgroup_put(struct mem_cgroup *memcg)
{
	css_put(&memcg->css);
}

#define mem_cgroup_from_counter(counter, member)	\
#define mem_cgroup_from_counter(counter, member)	\
	container_of(counter, struct mem_cgroup, member)
	container_of(counter, struct mem_cgroup, member)


@@ -850,6 +855,10 @@ static inline bool task_in_mem_cgroup(struct task_struct *task,
	return true;
	return true;
}
}


static inline void mem_cgroup_put(struct mem_cgroup *memcg)
{
}

static inline struct mem_cgroup *
static inline struct mem_cgroup *
mem_cgroup_iter(struct mem_cgroup *root,
mem_cgroup_iter(struct mem_cgroup *root,
		struct mem_cgroup *prev,
		struct mem_cgroup *prev,