]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - include/linux/oom.h
mm, oom: fix race when specifying a thread as the oom origin
[mirror_ubuntu-artful-kernel.git] / include / linux / oom.h
index 922dab164eb03baacb693955866c7dcd847c3eb7..da60007075b509b864d386b3d9092c77aec97c64 100644 (file)
@@ -29,8 +29,23 @@ enum oom_scan_t {
        OOM_SCAN_SELECT,        /* always select this thread first */
 };
 
-extern void compare_swap_oom_score_adj(short old_val, short new_val);
-extern short test_set_oom_score_adj(short new_val);
+/* Thread is the potential origin of an oom condition; kill first on oom */
+#define OOM_FLAG_ORIGIN                ((__force oom_flags_t)0x1)
+
+static inline void set_current_oom_origin(void)
+{
+       current->signal->oom_flags |= OOM_FLAG_ORIGIN;
+}
+
+static inline void clear_current_oom_origin(void)
+{
+       current->signal->oom_flags &= ~OOM_FLAG_ORIGIN;
+}
+
+static inline bool oom_task_origin(const struct task_struct *p)
+{
+       return !!(p->signal->oom_flags & OOM_FLAG_ORIGIN);
+}
 
 extern unsigned long oom_badness(struct task_struct *p,
                struct mem_cgroup *memcg, const nodemask_t *nodemask,