All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com,
	akpm@linux-foundation.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: memcontrol: remove obsolete comment of mem_cgroup_unmark_under_oom()
Date: Tue, 29 Sep 2020 16:29:20 +0200	[thread overview]
Message-ID: <20200929142920.GD2277@dhcp22.suse.cz> (raw)
In-Reply-To: <20200917105900.4337-1-linmiaohe@huawei.com>

On Thu 17-09-20 06:59:00, Miaohe Lin wrote:
> Since commit 79dfdaccd1d5 ("memcg: make oom_lock 0 and 1 based rather than
> counter"), the mem_cgroup_unmark_under_oom() is added and the comment of
> the mem_cgroup_oom_unlock() is moved here. But this comment make no sense
> here because mem_cgroup_oom_lock() does not operate on under_oom field.

OK, so I've looked into this more deeply and I finally remember why we
have this comment here. The point is that under_oom shouldn't underflow
and that we have to explicitly check for > 0 because a new child memcg
could have been added between mem_cgroup_mark_under_oom and
mem_cgroup_unmark_under_oom.

So the comment makes sense although it is not as helpful as it could be.
I think that changing it to the following will be more usefule

	/*
	 * Be careful about under_oom underflows becase a child memcg
	 * could have neem added after mem_cgroup_mark_under_oom
	 */
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/memcontrol.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index cd5f83de9a6f..e44f5afaf78b 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1848,10 +1848,6 @@ static void mem_cgroup_unmark_under_oom(struct mem_cgroup *memcg)
>  {
>  	struct mem_cgroup *iter;
>  
> -	/*
> -	 * When a new child is created while the hierarchy is under oom,
> -	 * mem_cgroup_oom_lock() may not be called. Watch for underflow.
> -	 */
>  	spin_lock(&memcg_oom_lock);
>  	for_each_mem_cgroup_tree(iter, memcg)
>  		if (iter->under_oom > 0)
> -- 
> 2.19.1

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2020-09-29 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 10:59 [PATCH v2] mm: memcontrol: remove obsolete comment of mem_cgroup_unmark_under_oom() Miaohe Lin
2020-09-17 10:59 ` Miaohe Lin
2020-09-29 14:29 ` Michal Hocko [this message]
2020-09-30  1:34 linmiaohe
2020-09-30  8:43 ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200929142920.GD2277@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vdavydov.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.