|
|
@@ -248,6 +248,12 @@ enum res_type {
|
|
|
iter != NULL; \
|
|
|
iter = mem_cgroup_iter(NULL, iter, NULL))
|
|
|
|
|
|
+static inline bool should_force_charge(void)
|
|
|
+{
|
|
|
+ return tsk_is_oom_victim(current) || fatal_signal_pending(current) ||
|
|
|
+ (current->flags & PF_EXITING);
|
|
|
+}
|
|
|
+
|
|
|
/* Some nice accessors for the vmpressure. */
|
|
|
struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg)
|
|
|
{
|
|
|
@@ -1382,8 +1388,13 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
|
|
|
};
|
|
|
bool ret;
|
|
|
|
|
|
- mutex_lock(&oom_lock);
|
|
|
- ret = out_of_memory(&oc);
|
|
|
+ if (mutex_lock_killable(&oom_lock))
|
|
|
+ return true;
|
|
|
+ /*
|
|
|
+ * A few threads which were not waiting at mutex_lock_killable() can
|
|
|
+ * fail to bail out. Therefore, check again after holding oom_lock.
|
|
|
+ */
|
|
|
+ ret = should_force_charge() || out_of_memory(&oc);
|
|
|
mutex_unlock(&oom_lock);
|
|
|
return ret;
|
|
|
}
|
|
|
@@ -2200,9 +2211,7 @@ retry:
|
|
|
* bypass the last charges so that they can exit quickly and
|
|
|
* free their memory.
|
|
|
*/
|
|
|
- if (unlikely(tsk_is_oom_victim(current) ||
|
|
|
- fatal_signal_pending(current) ||
|
|
|
- current->flags & PF_EXITING))
|
|
|
+ if (unlikely(should_force_charge()))
|
|
|
goto force;
|
|
|
|
|
|
/*
|