linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: Pass NULL memcg for oom_badness() check.
@ 2016-02-19 13:51 Tetsuo Handa
  2016-02-19 14:04 ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: Tetsuo Handa @ 2016-02-19 13:51 UTC (permalink / raw)
  To: rientjes, hannes, mhocko, vdavydov; +Cc: linux-mm, Tetsuo Handa

Currently, mem_cgroup_out_of_memory() is calling
oom_scan_process_thread(&oc, task, totalpages) which includes
a call to oom_unkillable_task(task, NULL, NULL) and then is
calling oom_badness(task, memcg, NULL, totalpages) which includes
a call to oom_unkillable_task(task, memcg, NULL).

Since for_each_mem_cgroup_tree() iterates on only tasks from the given
memcg hierarchy, there is no point with passing non-NULL memcg argument
to oom_unkillable_task() via oom_badness().

Replace memcg argument with NULL in order to save a call to
task_in_mem_cgroup(task, memcg) in oom_unkillable_task()
which is always true.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ae8b81c..3c96dd3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1290,7 +1290,7 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
 			case OOM_SCAN_OK:
 				break;
 			};
-			points = oom_badness(task, memcg, NULL, totalpages);
+			points = oom_badness(task, NULL, NULL, totalpages);
 			if (!points || points < chosen_points)
 				continue;
 			/* Prefer thread group leaders for display purposes */
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: Pass NULL memcg for oom_badness() check.
  2016-02-19 13:51 [PATCH] mm: memcontrol: Pass NULL memcg for oom_badness() check Tetsuo Handa
@ 2016-02-19 14:04 ` Michal Hocko
  2016-02-19 14:36   ` Tetsuo Handa
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2016-02-19 14:04 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: rientjes, hannes, vdavydov, linux-mm

On Fri 19-02-16 22:51:38, Tetsuo Handa wrote:
> Currently, mem_cgroup_out_of_memory() is calling
> oom_scan_process_thread(&oc, task, totalpages) which includes
> a call to oom_unkillable_task(task, NULL, NULL) and then is
> calling oom_badness(task, memcg, NULL, totalpages) which includes
> a call to oom_unkillable_task(task, memcg, NULL).
> 
> Since for_each_mem_cgroup_tree() iterates on only tasks from the given
> memcg hierarchy, there is no point with passing non-NULL memcg argument
> to oom_unkillable_task() via oom_badness().
> 
> Replace memcg argument with NULL in order to save a call to
> task_in_mem_cgroup(task, memcg) in oom_unkillable_task()
> which is always true.

yes this is true but oom_badness is called from super slow path here so
I am not sure this change will buy anything. It makes the code little
bit more confusing because now you have to think twice (or git blame) to
see why the memcg == NULL is really OK.

So I do not think this is an improvement. If anything wouldn't it be
cleaner to remove memcg parameter from oom_badness altogether and
instead do the task_in_mem_cgroup check where it is really needed?
In other words do the check in oom_kill_process when evaluating children
to sacrifice them?

> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index ae8b81c..3c96dd3 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1290,7 +1290,7 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
>  			case OOM_SCAN_OK:
>  				break;
>  			};
> -			points = oom_badness(task, memcg, NULL, totalpages);
> +			points = oom_badness(task, NULL, NULL, totalpages);
>  			if (!points || points < chosen_points)
>  				continue;
>  			/* Prefer thread group leaders for display purposes */
> -- 
> 1.8.3.1

-- 
Michal Hocko
SUSE Labs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: Pass NULL memcg for oom_badness() check.
  2016-02-19 14:04 ` Michal Hocko
@ 2016-02-19 14:36   ` Tetsuo Handa
  0 siblings, 0 replies; 3+ messages in thread
From: Tetsuo Handa @ 2016-02-19 14:36 UTC (permalink / raw)
  To: mhocko; +Cc: rientjes, hannes, vdavydov, linux-mm

Michal Hocko wrote:
> On Fri 19-02-16 22:51:38, Tetsuo Handa wrote:
> > Currently, mem_cgroup_out_of_memory() is calling
> > oom_scan_process_thread(&oc, task, totalpages) which includes
> > a call to oom_unkillable_task(task, NULL, NULL) and then is
> > calling oom_badness(task, memcg, NULL, totalpages) which includes
> > a call to oom_unkillable_task(task, memcg, NULL).
> > 
> > Since for_each_mem_cgroup_tree() iterates on only tasks from the given
> > memcg hierarchy, there is no point with passing non-NULL memcg argument
> > to oom_unkillable_task() via oom_badness().
> > 
> > Replace memcg argument with NULL in order to save a call to
> > task_in_mem_cgroup(task, memcg) in oom_unkillable_task()
> > which is always true.
> 
> yes this is true but oom_badness is called from super slow path here so
> I am not sure this change will buy anything. It makes the code little
> bit more confusing because now you have to think twice (or git blame) to
> see why the memcg == NULL is really OK.
> 
> So I do not think this is an improvement. If anything wouldn't it be
> cleaner to remove memcg parameter from oom_badness altogether and
> instead do the task_in_mem_cgroup check where it is really needed?
> In other words do the check in oom_kill_process when evaluating children
> to sacrifice them?

This patch is a clarification before proposing
http://lkml.kernel.org/r/1455892411-7611-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp
which converts two oom_unkillable_task() calls into one and
fixes infinite loop which will occur after we merge the OOM reaper.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-19 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-19 13:51 [PATCH] mm: memcontrol: Pass NULL memcg for oom_badness() check Tetsuo Handa
2016-02-19 14:04 ` Michal Hocko
2016-02-19 14:36   ` Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).