Merge tag 'sound-4.7-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[deliverable/linux.git] / include / linux / oom.h
index 83b9c39bd8b7cce02e0c477ef2cfc8e14b80ce2c..83469522690a8882f1c8e131d7ad95bad3a2ef95 100644 (file)
@@ -50,24 +50,21 @@ enum oom_scan_t {
        OOM_SCAN_SELECT,        /* always select this thread first */
 };
 
-/* Thread is the potential origin of an oom condition; kill first on oom */
-#define OOM_FLAG_ORIGIN                ((__force oom_flags_t)0x1)
-
 extern struct mutex oom_lock;
 
 static inline void set_current_oom_origin(void)
 {
-       current->signal->oom_flags |= OOM_FLAG_ORIGIN;
+       current->signal->oom_flag_origin = true;
 }
 
 static inline void clear_current_oom_origin(void)
 {
-       current->signal->oom_flags &= ~OOM_FLAG_ORIGIN;
+       current->signal->oom_flag_origin = false;
 }
 
 static inline bool oom_task_origin(const struct task_struct *p)
 {
-       return !!(p->signal->oom_flags & OOM_FLAG_ORIGIN);
+       return p->signal->oom_flag_origin;
 }
 
 extern void mark_oom_victim(struct task_struct *tsk);
@@ -110,13 +107,24 @@ extern struct task_struct *find_lock_task_mm(struct task_struct *p);
 
 static inline bool task_will_free_mem(struct task_struct *task)
 {
+       struct signal_struct *sig = task->signal;
+
        /*
         * A coredumping process may sleep for an extended period in exit_mm(),
         * so the oom killer cannot assume that the process will promptly exit
         * and release memory.
         */
-       return (task->flags & PF_EXITING) &&
-               !(task->signal->flags & SIGNAL_GROUP_COREDUMP);
+       if (sig->flags & SIGNAL_GROUP_COREDUMP)
+               return false;
+
+       if (!(task->flags & PF_EXITING))
+               return false;
+
+       /* Make sure that the whole thread group is going down */
+       if (!thread_group_empty(task) && !(sig->flags & SIGNAL_GROUP_EXIT))
+               return false;
+
+       return true;
 }
 
 /* sysctls */
This page took 0.035829 seconds and 5 git commands to generate.