linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>, Tejun Heo <tj@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] memcg: fix memory.high target
Date: Tue, 24 Nov 2015 17:38:58 +0100	[thread overview]
Message-ID: <20151124163857.GL29472@dhcp22.suse.cz> (raw)
In-Reply-To: <1448281351-15103-1-git-send-email-vdavydov@virtuozzo.com>

On Mon 23-11-15 15:22:31, Vladimir Davydov wrote:
> When the memory.high threshold is exceeded, try_charge() schedules a
> task_work to reclaim the excess. The reclaim target is set to the number
> of pages requested by try_charge(). This is wrong, because try_charge()
> usually charges more pages than requested (batch > nr_pages) in order to
> refill per cpu stocks. As a result, a process in a cgroup can easily
> exceed memory.high significantly when doing a lot of charges w/o
> returning to userspace (e.g. reading a file in big chunks).
> 
> Fix this issue by assuring that when exceeding memory.high a process
> reclaims as many pages as were actually charged (i.e. batch).

Good point. This will not affect the single page load because the
reclaim is done in SWAP_CLUSTER_MAX chunks anyway.

> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>

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

> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 648cc9f02437..06c476ab0f2c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2133,7 +2133,7 @@ done_restock:
>  	 */
>  	do {
>  		if (page_counter_read(&memcg->memory) > memcg->high) {
> -			current->memcg_nr_pages_over_high += nr_pages;
> +			current->memcg_nr_pages_over_high += batch;
>  			set_notify_resume(current);
>  			break;
>  		}
> -- 
> 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>

      parent reply	other threads:[~2015-11-24 16:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 12:22 Vladimir Davydov
2015-11-23 16:17 ` Johannes Weiner
2015-11-24 16:38 ` Michal Hocko [this message]

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=20151124163857.GL29472@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    --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
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