From: KAMEZAWA Hiroyuki Date: Thu, 7 Feb 2008 08:14:28 +0000 (-0800) Subject: memory cgroup enhancements: implicit force_empty() at rmdir X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=df878fb04dea044378274d40d063279a9cb787fb;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git memory cgroup enhancements: implicit force_empty() at rmdir Add pre_destroy handler for mem_cgroup and try to make mem_cgroup empty at rmdir(). Signed-off-by: KAMEZAWA Hiroyuki Cc: "Eric W. Biederman" Cc: Balbir Singh Cc: David Rientjes Cc: Herbert Poetzl Cc: Kirill Korotaev Cc: Nick Piggin Cc: Paul Menage Cc: Pavel Emelianov Cc: Peter Zijlstra Cc: Vaidyanathan Srinivasan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 904e9a9c223..14cb6142ec4 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -895,6 +895,13 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) return &mem->css; } +static void mem_cgroup_pre_destroy(struct cgroup_subsys *ss, + struct cgroup *cont) +{ + struct mem_cgroup *mem = mem_cgroup_from_cont(cont); + mem_cgroup_force_empty(mem); +} + static void mem_cgroup_destroy(struct cgroup_subsys *ss, struct cgroup *cont) { @@ -946,6 +953,7 @@ struct cgroup_subsys mem_cgroup_subsys = { .name = "memory", .subsys_id = mem_cgroup_subsys_id, .create = mem_cgroup_create, + .pre_destroy = mem_cgroup_pre_destroy, .destroy = mem_cgroup_destroy, .populate = mem_cgroup_populate, .attach = mem_cgroup_move_task,