* [PATCH] signal: Make oom_flags a bool
@ 2016-03-21 11:38 Tetsuo Handa
2016-03-28 22:04 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2016-03-21 11:38 UTC (permalink / raw)
To: linux-mm; +Cc: Tetsuo Handa
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>
---
include/linux/oom.h | 9 +++------
include/linux/sched.h | 6 +++++-
include/linux/types.h | 1 -
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/linux/oom.h b/include/linux/oom.h
index dad467a..96da253 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -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);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 888bc15..83bd309b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -784,7 +784,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. */
diff --git a/include/linux/types.h b/include/linux/types.h
index 70dd3df..baf7183 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -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;
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] signal: Make oom_flags a bool
2016-03-21 11:38 [PATCH] signal: Make oom_flags a bool Tetsuo Handa
@ 2016-03-28 22:04 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2016-03-28 22:04 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: linux-mm, Hugh Dickins
On Mon, 21 Mar 2016 20:38:13 +0900 Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> 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.
Making oom_flags atomic wouldn't fix such a race - run_store() and
swapoff() could still much with each other's state.
But no, I don't think it matters a lot - worst case is that the "wrong"
process gets oom-killed. I think.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-28 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-21 11:38 [PATCH] signal: Make oom_flags a bool Tetsuo Handa
2016-03-28 22:04 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).