Re: [PATCH] mm: memcontrol: drop unnecessary task_will_free_mem() check.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Weiner wrote:
> On Wed, Mar 09, 2016 at 12:15:10AM +0900, Tetsuo Handa wrote:
> > Since mem_cgroup_out_of_memory() is called by
> > mem_cgroup_oom_synchronize(true) via pagefault_out_of_memory() via
> > page fault, and possible allocations between setting PF_EXITING and
> > calling exit_mm() are tty_audit_exit() and taskstats_exit() which will
> > not trigger page fault, task_will_free_mem(current) in
> > mem_cgroup_out_of_memory() is never true.
> > 
> > Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
> 
> This opens us up to subtle bugs when somebody later changes the order
> and adds new possible allocation sites between the sequence points you
> describe above, or maybe adds other mem_cgroup_out_of_memory() callers.
> 
> It looks like a simplification, but it actually complicates things.
> 

If currently not needed, it should be removed. This is for a clarification.

Also, what is the reason we do not need below change?
I think there is a small race window because oom_killer_disabled needs to be
checked after oom_killer_disable() held oom_lock. Is it because all userspace
processes except current are frozen before oom_killer_disable() is called and
not-yet frozen threads (i.e. kernel threads) never call mem_cgroup_out_of_memory() ?

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ae8b81c..521cd33 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1253,6 +1253,10 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
 
 	mutex_lock(&oom_lock);
 
+	/* Check if we raced with oom_killer_disable(). */
+	if (oom_killer_disabled)
+		goto unlock;
+
 	/*
 	 * If current has a pending SIGKILL or is exiting, then automatically
 	 * select it.  The goal is to allow it to allocate so that it may

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]