* [patch -mm 1/2] mm, oom: add description of struct oom_control
@ 2015-07-14 23:45 David Rientjes
2015-07-14 23:45 ` [patch -mm 2/2] mm, oom: remove unnecessary variable David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2015-07-14 23:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Sergey Senozhatsky, Michal Hocko, linux-kernel, linux-mm
Describe the purpose of struct oom_control and what each member does.
Also make gfp_mask and order const since they are never manipulated or
passed to functions that discard the qualifier.
Signed-off-by: David Rientjes <rientjes@google.com>
---
include/linux/oom.h | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/include/linux/oom.h b/include/linux/oom.h
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -12,11 +12,25 @@ struct notifier_block;
struct mem_cgroup;
struct task_struct;
+/*
+ * Details of the page allocation that triggered the oom killer that are used to
+ * determine what should be killed.
+ */
struct oom_control {
+ /* Used to determine cpuset */
struct zonelist *zonelist;
- nodemask_t *nodemask;
- gfp_t gfp_mask;
- int order;
+
+ /* Used to determine mempolicy */
+ nodemask_t *nodemask;
+
+ /* Used to determine cpuset and node locality requirement */
+ const gfp_t gfp_mask;
+
+ /*
+ * order == -1 means the oom kill is required by sysrq, otherwise only
+ * for display purposes.
+ */
+ const int order;
};
/*
--
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] 3+ messages in thread
* [patch -mm 2/2] mm, oom: remove unnecessary variable
2015-07-14 23:45 [patch -mm 1/2] mm, oom: add description of struct oom_control David Rientjes
@ 2015-07-14 23:45 ` David Rientjes
2015-07-15 9:33 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2015-07-14 23:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Sergey Senozhatsky, Michal Hocko, linux-kernel, linux-mm
The "killed" variable in out_of_memory() can be removed since the call to
oom_kill_process() where we should block to allow the process time to
exit is obvious.
Signed-off-by: David Rientjes <rientjes@google.com>
---
mm/oom_kill.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -645,7 +645,6 @@ bool out_of_memory(struct oom_control *oc)
unsigned long freed = 0;
unsigned int uninitialized_var(points);
enum oom_constraint constraint = CONSTRAINT_NONE;
- int killed = 0;
if (oom_killer_disabled)
return false;
@@ -653,7 +652,7 @@ bool out_of_memory(struct oom_control *oc)
blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
if (freed > 0)
/* Got some memory back in the last second. */
- goto out;
+ return true;
/*
* If current has a pending SIGKILL or is exiting, then automatically
@@ -666,7 +665,7 @@ bool out_of_memory(struct oom_control *oc)
if (current->mm &&
(fatal_signal_pending(current) || task_will_free_mem(current))) {
mark_oom_victim(current);
- goto out;
+ return true;
}
/*
@@ -684,7 +683,7 @@ bool out_of_memory(struct oom_control *oc)
get_task_struct(current);
oom_kill_process(oc, current, 0, totalpages, NULL,
"Out of memory (oom_kill_allocating_task)");
- goto out;
+ return true;
}
p = select_bad_process(oc, &points, totalpages);
@@ -696,16 +695,12 @@ bool out_of_memory(struct oom_control *oc)
if (p && p != (void *)-1UL) {
oom_kill_process(oc, p, points, totalpages, NULL,
"Out of memory");
- killed = 1;
- }
-out:
- /*
- * Give the killed threads a good chance of exiting before trying to
- * allocate memory again.
- */
- if (killed)
+ /*
+ * Give the killed process a good chance to exit before trying
+ * to allocate memory again.
+ */
schedule_timeout_killable(1);
-
+ }
return true;
}
--
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] 3+ messages in thread
* Re: [patch -mm 2/2] mm, oom: remove unnecessary variable
2015-07-14 23:45 ` [patch -mm 2/2] mm, oom: remove unnecessary variable David Rientjes
@ 2015-07-15 9:33 ` Michal Hocko
0 siblings, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2015-07-15 9:33 UTC (permalink / raw)
To: David Rientjes; +Cc: Andrew Morton, Sergey Senozhatsky, linux-kernel, linux-mm
On Tue 14-07-15 16:45:13, David Rientjes wrote:
> The "killed" variable in out_of_memory() can be removed since the call to
> oom_kill_process() where we should block to allow the process time to
> exit is obvious.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/oom_kill.c | 21 ++++++++-------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -645,7 +645,6 @@ bool out_of_memory(struct oom_control *oc)
> unsigned long freed = 0;
> unsigned int uninitialized_var(points);
> enum oom_constraint constraint = CONSTRAINT_NONE;
> - int killed = 0;
>
> if (oom_killer_disabled)
> return false;
> @@ -653,7 +652,7 @@ bool out_of_memory(struct oom_control *oc)
> blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
> if (freed > 0)
> /* Got some memory back in the last second. */
> - goto out;
> + return true;
>
> /*
> * If current has a pending SIGKILL or is exiting, then automatically
> @@ -666,7 +665,7 @@ bool out_of_memory(struct oom_control *oc)
> if (current->mm &&
> (fatal_signal_pending(current) || task_will_free_mem(current))) {
> mark_oom_victim(current);
> - goto out;
> + return true;
> }
>
> /*
> @@ -684,7 +683,7 @@ bool out_of_memory(struct oom_control *oc)
> get_task_struct(current);
> oom_kill_process(oc, current, 0, totalpages, NULL,
> "Out of memory (oom_kill_allocating_task)");
> - goto out;
> + return true;
> }
>
> p = select_bad_process(oc, &points, totalpages);
> @@ -696,16 +695,12 @@ bool out_of_memory(struct oom_control *oc)
> if (p && p != (void *)-1UL) {
> oom_kill_process(oc, p, points, totalpages, NULL,
> "Out of memory");
> - killed = 1;
> - }
> -out:
> - /*
> - * Give the killed threads a good chance of exiting before trying to
> - * allocate memory again.
> - */
> - if (killed)
> + /*
> + * Give the killed process a good chance to exit before trying
> + * to allocate memory again.
> + */
> schedule_timeout_killable(1);
> -
> + }
> return true;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Michal Hocko
SUSE Labs
--
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] 3+ messages in thread
end of thread, other threads:[~2015-07-15 9:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 23:45 [patch -mm 1/2] mm, oom: add description of struct oom_control David Rientjes
2015-07-14 23:45 ` [patch -mm 2/2] mm, oom: remove unnecessary variable David Rientjes
2015-07-15 9:33 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox