]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm/oom_kill.c: fix uninitialized oc->constraint
authorYafang Shao <laoar.shao@gmail.com>
Fri, 28 Jun 2019 19:06:59 +0000 (12:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Jul 2019 07:02:00 +0000 (09:02 +0200)
[ Upstream commit 432b1de0de02a83f64695e69a2d83cbee10c236f ]

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/1560522038-15879-1-git-send-email-laoar.shao@gmail.com
Fixes: ef8444ea01d7 ("mm, oom: reorganize the oom report in dump_header")
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Wind Yu <yuzhoujian@didichuxing.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mm/oom_kill.c

index 3a2484884cfd14924bee506cb96aeb65982e48b5..263efad6fc7e05ec0ae39c0acb0614ef915a3767 100644 (file)
@@ -985,8 +985,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
 /*
  * Determines whether the kernel must panic because of the panic_on_oom sysctl.
  */
-static void check_panic_on_oom(struct oom_control *oc,
-                              enum oom_constraint constraint)
+static void check_panic_on_oom(struct oom_control *oc)
 {
        if (likely(!sysctl_panic_on_oom))
                return;
@@ -996,7 +995,7 @@ static void check_panic_on_oom(struct oom_control *oc,
                 * does not panic for cpuset, mempolicy, or memcg allocation
                 * failures.
                 */
-               if (constraint != CONSTRAINT_NONE)
+               if (oc->constraint != CONSTRAINT_NONE)
                        return;
        }
        /* Do not panic for oom kills triggered by sysrq */
@@ -1033,7 +1032,6 @@ EXPORT_SYMBOL_GPL(unregister_oom_notifier);
 bool out_of_memory(struct oom_control *oc)
 {
        unsigned long freed = 0;
-       enum oom_constraint constraint = CONSTRAINT_NONE;
 
        if (oom_killer_disabled)
                return false;
@@ -1069,10 +1067,10 @@ bool out_of_memory(struct oom_control *oc)
         * Check if there were limitations on the allocation (only relevant for
         * NUMA and memcg) that may require different handling.
         */
-       constraint = constrained_alloc(oc);
-       if (constraint != CONSTRAINT_MEMORY_POLICY)
+       oc->constraint = constrained_alloc(oc);
+       if (oc->constraint != CONSTRAINT_MEMORY_POLICY)
                oc->nodemask = NULL;
-       check_panic_on_oom(oc, constraint);
+       check_panic_on_oom(oc);
 
        if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task &&
            current->mm && !oom_unkillable_task(current, NULL, oc->nodemask) &&