@@ -565,6 +565,23 @@ static inline bool task_in_memcg_oom(struct task_struct *p)
return p->memcg_in_oom;
}
+/* Bail out from the charge path if no victim found in memcg oom */
+static inline enum oom_status task_in_memcg_oom_set(struct task_struct *p,
+ struct mem_cgroup *memcg,
+ gfp_t mask,
+ int order)
+{
+ if (!current->in_user_fault)
+ return OOM_SKIPPED;
+
+ css_get(&memcg->css);
+ p->memcg_in_oom = memcg;
+ p->memcg_oom_gfp_mask = mask;
+ p->memcg_oom_order = order;
+
+ return OOM_ASYNC;
+}
+
bool mem_cgroup_oom_synchronize(bool wait);
struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim,
struct mem_cgroup *oom_domain);
@@ -1031,6 +1048,14 @@ static inline bool task_in_memcg_oom(struct task_struct *p)
return false;
}
+static inline enum oom_status task_in_memcg_oom_set(struct task_struct *p,
+ struct mem_cgroup *memcg,
+ gfp_t mask,
+ int order)
+{
+ return OOM_SUCCESS;
+}
+
static inline bool mem_cgroup_oom_synchronize(bool wait)
{
return false;
@@ -1800,16 +1800,8 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int
* Please note that mem_cgroup_out_of_memory might fail to find a
* victim and then we have to bail out from the charge path.
*/
- if (memcg->oom_kill_disable) {
- if (!current->in_user_fault)
- return OOM_SKIPPED;
- css_get(&memcg->css);
- current->memcg_in_oom = memcg;
- current->memcg_oom_gfp_mask = mask;
- current->memcg_oom_order = order;
-
- return OOM_ASYNC;
- }
+ if (memcg->oom_kill_disable)
+ return task_in_memcg_oom_set(current, memcg, mask, order);
mem_cgroup_mark_under_oom(memcg);
A new helper task_in_memcg_oom_set() is introduced for later use. It will be used to bail out from the charge path if no victim can be found in memcg oom. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- include/linux/memcontrol.h | 25 +++++++++++++++++++++++++ mm/memcontrol.c | 12 ++---------- 2 files changed, 27 insertions(+), 10 deletions(-)