Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275277 > unrolled thread

[PATCH] memcg: fix memory.high target

Started byVladimir Davydov <vdavydov@virtuozzo.com>
First post2015-11-23 13:30 +0100
Last post2015-11-24 17:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] memcg: fix memory.high target Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-23 13:30 +0100
    Re: [PATCH] memcg: fix memory.high target Johannes Weiner <hannes@cmpxchg.org> - 2015-11-23 17:20 +0100
    Re: [PATCH] memcg: fix memory.high target Michal Hocko <mhocko@kernel.org> - 2015-11-24 17:40 +0100

#1275277 — [PATCH] memcg: fix memory.high target

FromVladimir Davydov <vdavydov@virtuozzo.com>
Date2015-11-23 13:30 +0100
Subject[PATCH] memcg: fix memory.high target
Message-ID<qxYpP-1FW-1@gated-at.bofh.it>
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).

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1275561

FromJohannes Weiner <hannes@cmpxchg.org>
Date2015-11-23 17:20 +0100
Message-ID<qy20s-4cV-73@gated-at.bofh.it>
In reply to#1275277
On Mon, Nov 23, 2015 at 03:22:31PM +0300, 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).
> 
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1276633

FromMichal Hocko <mhocko@kernel.org>
Date2015-11-24 17:40 +0100
Message-ID<qyoNk-29z-25@gated-at.bofh.it>
In reply to#1275277
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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web