Skip to content

Commit 432b1de

Browse files
laoartorvalds
authored andcommitted
mm/oom_kill.c: fix uninitialized oc->constraint
In dump_oom_summary() oc->constraint is used to show oom_constraint_text, but it hasn't been set before. So the value of it is always the default value 0. We should inititialize it before. Bellow is the output when memcg oom occurs, before this patch: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null), cpuset=/,mems_allowed=0,oom_memcg=/foo,task_memcg=/foo,task=bash,pid=7997,uid=0 after this patch: oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null), cpuset=/,mems_allowed=0,oom_memcg=/foo,task_memcg=/foo,task=bash,pid=13681,uid=0 Link: http://lkml.kernel.org/r/[email protected] Fixes: ef8444e ("mm, oom: reorganize the oom report in dump_header") Signed-off-by: Yafang Shao <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Wind Yu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent faf53de commit 432b1de

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mm/oom_kill.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
987987
/*
988988
* Determines whether the kernel must panic because of the panic_on_oom sysctl.
989989
*/
990-
static void check_panic_on_oom(struct oom_control *oc,
991-
enum oom_constraint constraint)
990+
static void check_panic_on_oom(struct oom_control *oc)
992991
{
993992
if (likely(!sysctl_panic_on_oom))
994993
return;
@@ -998,7 +997,7 @@ static void check_panic_on_oom(struct oom_control *oc,
998997
* does not panic for cpuset, mempolicy, or memcg allocation
999998
* failures.
1000999
*/
1001-
if (constraint != CONSTRAINT_NONE)
1000+
if (oc->constraint != CONSTRAINT_NONE)
10021001
return;
10031002
}
10041003
/* Do not panic for oom kills triggered by sysrq */
@@ -1035,7 +1034,6 @@ EXPORT_SYMBOL_GPL(unregister_oom_notifier);
10351034
bool out_of_memory(struct oom_control *oc)
10361035
{
10371036
unsigned long freed = 0;
1038-
enum oom_constraint constraint = CONSTRAINT_NONE;
10391037

10401038
if (oom_killer_disabled)
10411039
return false;
@@ -1071,10 +1069,10 @@ bool out_of_memory(struct oom_control *oc)
10711069
* Check if there were limitations on the allocation (only relevant for
10721070
* NUMA and memcg) that may require different handling.
10731071
*/
1074-
constraint = constrained_alloc(oc);
1075-
if (constraint != CONSTRAINT_MEMORY_POLICY)
1072+
oc->constraint = constrained_alloc(oc);
1073+
if (oc->constraint != CONSTRAINT_MEMORY_POLICY)
10761074
oc->nodemask = NULL;
1077-
check_panic_on_oom(oc, constraint);
1075+
check_panic_on_oom(oc);
10781076

10791077
if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task &&
10801078
current->mm && !oom_unkillable_task(current, NULL, oc->nodemask) &&

0 commit comments

Comments
 (0)