signal: make oom_flags a bool
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 23 May 2016 23:23:57 +0000 (16:23 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 24 May 2016 00:04:14 +0000 (17:04 -0700)
Currently the size of "struct signal_struct"->oom_flags member is
sizeof(unsigned) bytes, but only one flag OOM_FLAG_ORIGIN which is
updated by current thread is defined.  We can convert OOM_FLAG_ORIGIN
into a bool, and reuse the saved bytes for updating from the OOM killer
and/or the OOM reaper thread.

By the way, do we care about a race window between run_store() and
swapoff() because it would be theoretically possible that two threads
sharing the "struct signal_struct" concurrently call respective
functions? If we care, we can make oom_flags an atomic_t.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/oom.h
include/linux/sched.h
include/linux/types.h

index d3f533f2f4817a2157039408c25e9066888f8e3c..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);
index 2c036de6c1eeb683b3613042e7f5abdc207974b2..21c26e78aec5a36a018e8c95b7ea5221e8381eb1 100644 (file)
@@ -794,7 +794,11 @@ struct signal_struct {
        struct tty_audit_buf *tty_audit_buf;
 #endif
 
-       oom_flags_t oom_flags;
+       /*
+        * Thread is the potential origin of an oom condition; kill first on
+        * oom
+        */
+       bool oom_flag_origin;
        short oom_score_adj;            /* OOM kill score adjustment */
        short oom_score_adj_min;        /* OOM kill score adjustment min value.
                                         * Only settable by CAP_SYS_RESOURCE. */
index 70dd3dfde6319e661069f6b8c2d5a6b15804f27f..baf718324f4ab5bbd10d0a9ffa7069fdba8b2f18 100644 (file)
@@ -156,7 +156,6 @@ typedef u32 dma_addr_t;
 
 typedef unsigned __bitwise__ gfp_t;
 typedef unsigned __bitwise__ fmode_t;
-typedef unsigned __bitwise__ oom_flags_t;
 
 #ifdef CONFIG_PHYS_ADDR_T_64BIT
 typedef u64 phys_addr_t;