if (cg_read_key_long(child, "memory.events", "oom_kill ") <= 0)
                goto cleanup;
 
-       if (cg_read_key_long(parent, "memory.events", "oom_kill ") <= 0)
+       parent_oom_events = cg_read_key_long(
+                       parent, "memory.events", "oom_kill ");
+       /*
+        * If memory_localevents is not enabled (the default), the parent should
+        * count OOM events in its children groups. Otherwise, it should not
+        * have observed any events.
+        */
+       if (has_localevents && parent_oom_events != 0)
+               goto cleanup;
+       else if (!has_localevents && parent_oom_events <= 0)
                goto cleanup;
 
        ret = KSFT_PASS;
        if (!cg_run(memcg, alloc_anon, (void *)MB(100)))
                goto cleanup;
 
-       parent_oom_events = cg_read_key_long(
-                       parent, "memory.events", "oom_kill ");
-       /*
-        * If memory_localevents is not enabled (the default), the parent should
-        * count OOM events in its children groups. Otherwise, it should not
-        * have observed any events.
-        */
-       if ((has_localevents && parent_oom_events == 0) ||
-            parent_oom_events > 0)
-               ret = KSFT_PASS;
+       if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3)
+               goto cleanup;
 
        if (kill(safe_pid, SIGKILL))
                goto cleanup;
 
+       ret = KSFT_PASS;
+
 cleanup:
        if (memcg)
                cg_destroy(memcg);