/* Used to determine mempolicy */
        nodemask_t *nodemask;
 
+       /* Memory cgroup in which oom is invoked, or NULL for global oom */
+       struct mem_cgroup *memcg;
+
        /* Used to determine cpuset and node locality requirement */
        const gfp_t gfp_mask;
 
 
 extern void oom_kill_process(struct oom_control *oc, struct task_struct *p,
                             unsigned int points, unsigned long totalpages,
-                            struct mem_cgroup *memcg, const char *message);
+                            const char *message);
 
 extern void check_panic_on_oom(struct oom_control *oc,
-                              enum oom_constraint constraint,
-                              struct mem_cgroup *memcg);
+                              enum oom_constraint constraint);
 
 extern enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
                struct task_struct *task, unsigned long totalpages);
 
        rcu_read_unlock();
 }
 
-static void dump_header(struct oom_control *oc, struct task_struct *p,
-                       struct mem_cgroup *memcg)
+static void dump_header(struct oom_control *oc, struct task_struct *p)
 {
        pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n",
                current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
 
        cpuset_print_current_mems_allowed();
        dump_stack();
-       if (memcg)
-               mem_cgroup_print_oom_info(memcg, p);
+       if (oc->memcg)
+               mem_cgroup_print_oom_info(oc->memcg, p);
        else
                show_mem(SHOW_MEM_FILTER_NODES);
        if (sysctl_oom_dump_tasks)
-               dump_tasks(memcg, oc->nodemask);
+               dump_tasks(oc->memcg, oc->nodemask);
 }
 
 /*
  */
 void oom_kill_process(struct oom_control *oc, struct task_struct *p,
                      unsigned int points, unsigned long totalpages,
-                     struct mem_cgroup *memcg, const char *message)
+                     const char *message)
 {
        struct task_struct *victim = p;
        struct task_struct *child;
        task_unlock(p);
 
        if (__ratelimit(&oom_rs))
-               dump_header(oc, p, memcg);
+               dump_header(oc, p);
 
        pr_err("%s: Kill process %d (%s) score %u or sacrifice child\n",
                message, task_pid_nr(p), p->comm, points);
                        /*
                         * oom_badness() returns 0 if the thread is unkillable
                         */
-                       child_points = oom_badness(child, memcg, oc->nodemask,
-                                                               totalpages);
+                       child_points = oom_badness(child,
+                                       oc->memcg, oc->nodemask, totalpages);
                        if (child_points > victim_points) {
                                put_task_struct(victim);
                                victim = child;
 /*
  * Determines whether the kernel must panic because of the panic_on_oom sysctl.
  */
-void check_panic_on_oom(struct oom_control *oc, enum oom_constraint constraint,
-                       struct mem_cgroup *memcg)
+void check_panic_on_oom(struct oom_control *oc, enum oom_constraint constraint)
 {
        if (likely(!sysctl_panic_on_oom))
                return;
        /* Do not panic for oom kills triggered by sysrq */
        if (is_sysrq_oom(oc))
                return;
-       dump_header(oc, NULL, memcg);
+       dump_header(oc, NULL);
        panic("Out of memory: %s panic_on_oom is enabled\n",
                sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide");
 }
        constraint = constrained_alloc(oc, &totalpages);
        if (constraint != CONSTRAINT_MEMORY_POLICY)
                oc->nodemask = NULL;
-       check_panic_on_oom(oc, constraint, NULL);
+       check_panic_on_oom(oc, constraint);
 
        if (sysctl_oom_kill_allocating_task && current->mm &&
            !oom_unkillable_task(current, NULL, oc->nodemask) &&
            current->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) {
                get_task_struct(current);
-               oom_kill_process(oc, current, 0, totalpages, NULL,
+               oom_kill_process(oc, current, 0, totalpages,
                                 "Out of memory (oom_kill_allocating_task)");
                return true;
        }
        p = select_bad_process(oc, &points, totalpages);
        /* Found nothing?!?! Either we hang forever, or we panic. */
        if (!p && !is_sysrq_oom(oc)) {
-               dump_header(oc, NULL, NULL);
+               dump_header(oc, NULL);
                panic("Out of memory and no killable processes...\n");
        }
        if (p && p != (void *)-1UL) {
-               oom_kill_process(oc, p, points, totalpages, NULL,
-                                "Out of memory");
+               oom_kill_process(oc, p, points, totalpages, "Out of memory");
                /*
                 * Give the killed process a good chance to exit before trying
                 * to allocate memory again.
        struct oom_control oc = {
                .zonelist = NULL,
                .nodemask = NULL,
+               .memcg = NULL,
                .gfp_mask = 0,
                .order = 0,
        };