linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memcg: simplify unreclaimable groups handling in soft limit reclaim
@ 2014-10-20 15:55 Vladimir Davydov
  2014-10-20 18:59 ` Johannes Weiner
  2014-10-21  8:10 ` Michal Hocko
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Davydov @ 2014-10-20 15:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Johannes Weiner, Michal Hocko, linux-mm, linux-kernel

If we fail to reclaim anything from a cgroup during a soft reclaim pass
we want to get the next largest cgroup exceeding its soft limit. To
achieve this, we should obviously remove the current group from the tree
and then pick the largest group. Currently we have a weird loop instead.
Let's simplify it.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
---
 mm/memcontrol.c |   26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e957f0c80c6e..53393e27ff03 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3507,34 +3507,16 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
 		nr_reclaimed += reclaimed;
 		*total_scanned += nr_scanned;
 		spin_lock_irq(&mctz->lock);
+		__mem_cgroup_remove_exceeded(mz, mctz);
 
 		/*
 		 * If we failed to reclaim anything from this memory cgroup
 		 * it is time to move on to the next cgroup
 		 */
 		next_mz = NULL;
-		if (!reclaimed) {
-			do {
-				/*
-				 * Loop until we find yet another one.
-				 *
-				 * By the time we get the soft_limit lock
-				 * again, someone might have aded the
-				 * group back on the RB tree. Iterate to
-				 * make sure we get a different mem.
-				 * mem_cgroup_largest_soft_limit_node returns
-				 * NULL if no other cgroup is present on
-				 * the tree
-				 */
-				next_mz =
-				__mem_cgroup_largest_soft_limit_node(mctz);
-				if (next_mz == mz)
-					css_put(&next_mz->memcg->css);
-				else /* next_mz == NULL or other memcg */
-					break;
-			} while (1);
-		}
-		__mem_cgroup_remove_exceeded(mz, mctz);
+		if (!reclaimed)
+			next_mz = __mem_cgroup_largest_soft_limit_node(mctz);
+
 		excess = soft_limit_excess(mz->memcg);
 		/*
 		 * One school of thought says that we should not add
-- 
1.7.10.4


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

* Re: [PATCH] memcg: simplify unreclaimable groups handling in soft limit reclaim
  2014-10-20 15:55 [PATCH] memcg: simplify unreclaimable groups handling in soft limit reclaim Vladimir Davydov
@ 2014-10-20 18:59 ` Johannes Weiner
  2014-10-21  8:10 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2014-10-20 18:59 UTC (permalink / raw)
  To: Vladimir Davydov; +Cc: Andrew Morton, Michal Hocko, linux-mm, linux-kernel

On Mon, Oct 20, 2014 at 07:55:54PM +0400, Vladimir Davydov wrote:
> If we fail to reclaim anything from a cgroup during a soft reclaim pass
> we want to get the next largest cgroup exceeding its soft limit. To
> achieve this, we should obviously remove the current group from the tree
> and then pick the largest group. Currently we have a weird loop instead.
> Let's simplify it.
> 
> Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>

I wonder if there will be anything left once we removed all that which
is pointless and the unnecessary from the memcg code.

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

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

* Re: [PATCH] memcg: simplify unreclaimable groups handling in soft limit reclaim
  2014-10-20 15:55 [PATCH] memcg: simplify unreclaimable groups handling in soft limit reclaim Vladimir Davydov
  2014-10-20 18:59 ` Johannes Weiner
@ 2014-10-21  8:10 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2014-10-21  8:10 UTC (permalink / raw)
  To: Vladimir Davydov; +Cc: Andrew Morton, Johannes Weiner, linux-mm, linux-kernel

On Mon 20-10-14 19:55:54, Vladimir Davydov wrote:
> If we fail to reclaim anything from a cgroup during a soft reclaim pass
> we want to get the next largest cgroup exceeding its soft limit. To
> achieve this, we should obviously remove the current group from the tree
> and then pick the largest group. Currently we have a weird loop instead.
> Let's simplify it.
> 
> Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>

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

> ---
>  mm/memcontrol.c |   26 ++++----------------------
>  1 file changed, 4 insertions(+), 22 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index e957f0c80c6e..53393e27ff03 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -3507,34 +3507,16 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
>  		nr_reclaimed += reclaimed;
>  		*total_scanned += nr_scanned;
>  		spin_lock_irq(&mctz->lock);
> +		__mem_cgroup_remove_exceeded(mz, mctz);
>  
>  		/*
>  		 * If we failed to reclaim anything from this memory cgroup
>  		 * it is time to move on to the next cgroup
>  		 */
>  		next_mz = NULL;
> -		if (!reclaimed) {
> -			do {
> -				/*
> -				 * Loop until we find yet another one.
> -				 *
> -				 * By the time we get the soft_limit lock
> -				 * again, someone might have aded the
> -				 * group back on the RB tree. Iterate to
> -				 * make sure we get a different mem.
> -				 * mem_cgroup_largest_soft_limit_node returns
> -				 * NULL if no other cgroup is present on
> -				 * the tree
> -				 */
> -				next_mz =
> -				__mem_cgroup_largest_soft_limit_node(mctz);
> -				if (next_mz == mz)
> -					css_put(&next_mz->memcg->css);
> -				else /* next_mz == NULL or other memcg */
> -					break;
> -			} while (1);
> -		}
> -		__mem_cgroup_remove_exceeded(mz, mctz);
> +		if (!reclaimed)
> +			next_mz = __mem_cgroup_largest_soft_limit_node(mctz);
> +
>  		excess = soft_limit_excess(mz->memcg);
>  		/*
>  		 * One school of thought says that we should not add
> -- 
> 1.7.10.4
> 

-- 
Michal Hocko
SUSE Labs

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

end of thread, other threads:[~2014-10-21  8:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-20 15:55 [PATCH] memcg: simplify unreclaimable groups handling in soft limit reclaim Vladimir Davydov
2014-10-20 18:59 ` Johannes Weiner
2014-10-21  8:10 ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).