All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: drain stocks on resize limit
@ 2018-05-04 20:55 Shakeel Butt
  2018-05-07 14:48 ` Johannes Weiner
  2018-05-09  7:45 ` Michal Hocko
  0 siblings, 2 replies; 3+ messages in thread
From: Shakeel Butt @ 2018-05-04 20:55 UTC (permalink / raw)
  To: Michal Hocko, Andrew Morton, Greg Thelen, Johannes Weiner,
	Vladimir Davydov
  Cc: Linux MM, Cgroups, LKML, Shakeel Butt

Resizing the memcg limit for cgroup-v2 drains the stocks before
triggering the memcg reclaim. Do the same for cgroup-v1 to make the
behavior consistent.

Signed-off-by: Shakeel Butt <shakeelb@google.com>
---
 mm/memcontrol.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 25b148c2d222..e2d33a37f971 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2463,6 +2463,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 				 unsigned long max, bool memsw)
 {
 	bool enlarge = false;
+	bool drained = false;
 	int ret;
 	bool limits_invariant;
 	struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
@@ -2493,6 +2494,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 		if (!ret)
 			break;
 
+		if (!drained) {
+			drain_all_stock(memcg);
+			drained = true;
+			continue;
+		}
+
 		if (!try_to_free_mem_cgroup_pages(memcg, 1,
 					GFP_KERNEL, !memsw)) {
 			ret = -EBUSY;
-- 
2.17.0.441.gb46fe60e1d-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: drain stocks on resize limit
  2018-05-04 20:55 [PATCH] mm: memcontrol: drain stocks on resize limit Shakeel Butt
@ 2018-05-07 14:48 ` Johannes Weiner
  2018-05-09  7:45 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2018-05-07 14:48 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Michal Hocko, Andrew Morton, Greg Thelen, Vladimir Davydov,
	Linux MM, Cgroups, LKML

On Fri, May 04, 2018 at 01:55:48PM -0700, Shakeel Butt wrote:
> Resizing the memcg limit for cgroup-v2 drains the stocks before
> triggering the memcg reclaim. Do the same for cgroup-v1 to make the
> behavior consistent.
> 
> Signed-off-by: Shakeel Butt <shakeelb@google.com>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: drain stocks on resize limit
  2018-05-04 20:55 [PATCH] mm: memcontrol: drain stocks on resize limit Shakeel Butt
  2018-05-07 14:48 ` Johannes Weiner
@ 2018-05-09  7:45 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2018-05-09  7:45 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Andrew Morton, Greg Thelen, Johannes Weiner, Vladimir Davydov,
	Linux MM, Cgroups, LKML

On Fri 04-05-18 13:55:48, Shakeel Butt wrote:
> Resizing the memcg limit for cgroup-v2 drains the stocks before
> triggering the memcg reclaim. Do the same for cgroup-v1 to make the
> behavior consistent.
> 
> Signed-off-by: Shakeel Butt <shakeelb@google.com>

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

> ---
>  mm/memcontrol.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 25b148c2d222..e2d33a37f971 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2463,6 +2463,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
>  				 unsigned long max, bool memsw)
>  {
>  	bool enlarge = false;
> +	bool drained = false;
>  	int ret;
>  	bool limits_invariant;
>  	struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
> @@ -2493,6 +2494,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
>  		if (!ret)
>  			break;
>  
> +		if (!drained) {
> +			drain_all_stock(memcg);
> +			drained = true;
> +			continue;
> +		}
> +
>  		if (!try_to_free_mem_cgroup_pages(memcg, 1,
>  					GFP_KERNEL, !memsw)) {
>  			ret = -EBUSY;
> -- 
> 2.17.0.441.gb46fe60e1d-goog

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-09  7:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 20:55 [PATCH] mm: memcontrol: drain stocks on resize limit Shakeel Butt
2018-05-07 14:48 ` Johannes Weiner
2018-05-09  7:45 ` Michal Hocko

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.