linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com,
	akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm, memcg: don't protect pages if memcg is not populated
Date: Mon, 25 Nov 2019 09:14:46 +0100	[thread overview]
Message-ID: <20191125081446.GA31714@dhcp22.suse.cz> (raw)
In-Reply-To: <1574488602-11773-1-git-send-email-laoar.shao@gmail.com>

On Sat 23-11-19 00:56:42, Yafang Shao wrote:
> memory.{min, low} keeps protecting pages in a memcg even if there're no
> process running in this memcg. That makes nonsense, because if there're
> no processes running in this memcg there may be something wrong happens
> and these protected pages are not useful now.

Well, the min resp. low limits protect charges rather than tasks. And
thre are cases when there is no direct relation between the charged
memory and a specific task - e.g. long living kernel objects or page
cache. So there is nothing really unusual to have charges in an absence
of any tasks. I do not really see any reason why the protection
shouldn't apply to them. Such a be behavior would be quite inconsistent
btw. Just imagine a case when there is _a_ task but that one doesn't
really have any charges in the memcg. Why should we respect reclaim
protection in that case?

Btw. offlined memcgs already have no min/low watermarks protect.

Do you have any specific usecase that suffers from this behavior?
 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>  mm/memcontrol.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 1c4c08b..c96c282 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -6376,6 +6376,9 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
>  	if (memcg == root)
>  		return MEMCG_PROT_NONE;
>  
> +	if (!cgroup_is_populated(memcg->css.cgroup))
> +		return MEMCG_PROT_NONE;
> +
>  	usage = page_counter_read(&memcg->memory);
>  	if (!usage)
>  		return MEMCG_PROT_NONE;
> -- 
> 1.8.3.1

-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2019-11-25  8:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23  5:56 Yafang Shao
2019-11-25  8:14 ` Michal Hocko [this message]
2019-11-25  9:11   ` Yafang Shao
2019-11-25  9:38     ` 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=20191125081446.GA31714@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=laoar.shao@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox