diff --git a/include/linux/oom.h b/include/linux/oom.h index 53ab3299678809e6bbd86b2193094b2ce3896c5d..d554ec3b30f481c1a7c31b372a159862d7d74643 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -109,6 +109,7 @@ extern unsigned long oom_badness(struct task_struct *p, extern bool out_of_memory(struct oom_control *oc); extern void exit_oom_victim(void); +extern void mem_cgroup_oom_notify(struct mem_cgroup *memcg); extern int register_oom_notifier(struct notifier_block *nb); extern int unregister_oom_notifier(struct notifier_block *nb); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8ee61f4b37062c97a3660d2f3d7bb50740ce6adf..3384c2c7a01f6e2a374b49676cfc1fd81f35bb34 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -186,7 +186,6 @@ struct mem_cgroup_event { }; static void mem_cgroup_threshold(struct mem_cgroup *memcg); -static void mem_cgroup_oom_notify(struct mem_cgroup *memcg); /* Stuffs for move charges at task migration. */ /* @@ -5069,7 +5068,7 @@ static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg) return 0; } -static void mem_cgroup_oom_notify(struct mem_cgroup *memcg) +void mem_cgroup_oom_notify(struct mem_cgroup *memcg) { struct mem_cgroup *iter; diff --git a/mm/oom_kill.c b/mm/oom_kill.c index e96d5260177046c6d05d73635e94e8f67cce1414..8d504bac28096ceba4bb421cdb3b44e36a373d50 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -970,6 +970,11 @@ static void oom_kill_process(struct oom_control *oc, const char *message) struct task_struct *child; struct task_struct *t; struct mem_cgroup *oom_group; + +#ifdef CONFIG_MEMCG + struct mem_cgroup *memcg; +#endif + unsigned int victim_points = 0; static DEFINE_RATELIMIT_STATE(oom_global_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); @@ -1045,6 +1050,16 @@ static void oom_kill_process(struct oom_control *oc, const char *message) put_task_struct(p); read_unlock(&tasklist_lock); +#ifdef CONFIG_MEMCG + rcu_read_lock(); + memcg = mem_cgroup_from_task(victim); + if (memcg != NULL && memcg != root_mem_cgroup && !is_memcg_oom(oc)) { + css_get(&memcg->css); + mem_cgroup_oom_notify(memcg); + css_put(&memcg->css); + } + rcu_read_unlock(); +#endif /* * Do we need to kill the entire memory cgroup? * Or even one of the ancestor memory cgroups?