Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: roy.qing.li@gmail.com
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org,
	vdavydov@virtuozzo.com
Subject: Re: [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin
Date: Wed, 25 May 2016 17:51:22 +0200
Message-ID: <20160525155122.GK20132@dhcp22.suse.cz> (raw)
In-Reply-To: <1464068266-27736-1-git-send-email-roy.qing.li@gmail.com>

On Tue 24-05-16 13:37:46, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
> 
> The margin may be set to the difference value between memory limit and
> memory count firstly. which maybe returned wrongly if memsw.count excess
> memsw.limit, because try_charge forces charging __GFP_NOFAIL allocations,
> which may result in memsw.limit excess. If we are below memory.limit
> and there's nothing to reclaim to reduce memsw.usage, might end up
> looping in try_charge forever.

This is quite hard for me to grasp. What would you say about the
following:
"
mem_cgroup_margin might return memory.limit - memory_count when
the memsw.limit is in excess. This
doesn't happen usually because we do not allow excess on hard limits and
memory.limit <= memsw.limit but __GFP_NOFAIL charges can force the charge
and cause the excess when no memory is really swapable (swap is full or
no anonymous memory is left).
"

> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com>
> Cc: Michal Hocko <mhocko@suse.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/memcontrol.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 00981d2..12aaadd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1090,6 +1090,8 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)
>  		limit = READ_ONCE(memcg->memsw.limit);
>  		if (count <= limit)
>  			margin = min(margin, limit - count);
> +		else
> +			margin = 0;
>  	}
>  
>  	return margin;
> -- 
> 2.1.4

-- 
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>

  reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  5:37 roy.qing.li
2016-05-25 15:51 ` Michal Hocko [this message]
2016-05-26  1:28   ` Li RongQing

Reply instructions:

You may reply publically 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=20160525155122.GK20132@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=roy.qing.li@gmail.com \
    --cc=vdavydov@virtuozzo.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

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git