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


Groups > linux.kernel > #1286746 > unrolled thread

[PATCH 2/8] mm: memcontrol: remove double kmem page_counter init

Started byJohannes Weiner <hannes@cmpxchg.org>
First post2015-12-08 19:40 +0100
Last post2015-12-10 13:50 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/8] mm: memcontrol: remove double kmem page_counter init Johannes Weiner <hannes@cmpxchg.org> - 2015-12-08 19:40 +0100
    Re: [PATCH 2/8] mm: memcontrol: remove double kmem page_counter init Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-12-09 10:10 +0100
    Re: [PATCH 2/8] mm: memcontrol: remove double kmem page_counter init Michal Hocko <mhocko@kernel.org> - 2015-12-10 13:50 +0100

#1286746 — [PATCH 2/8] mm: memcontrol: remove double kmem page_counter init

FromJohannes Weiner <hannes@cmpxchg.org>
Date2015-12-08 19:40 +0100
Subject[PATCH 2/8] mm: memcontrol: remove double kmem page_counter init
Message-ID<qDvl9-5U7-35@gated-at.bofh.it>
The kmem page_counter's limit is initialized to PAGE_COUNTER_MAX
inside mem_cgroup_css_online(). There is no need to repeat this
from memcg_propagate_kmem().

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/memcontrol.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index eda8d43..02167db 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2840,8 +2840,7 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
 }
 
 #ifdef CONFIG_MEMCG_KMEM
-static int memcg_activate_kmem(struct mem_cgroup *memcg,
-			       unsigned long nr_pages)
+static int memcg_activate_kmem(struct mem_cgroup *memcg)
 {
 	int err = 0;
 	int memcg_id;
@@ -2876,13 +2875,6 @@ static int memcg_activate_kmem(struct mem_cgroup *memcg,
 		goto out;
 	}
 
-	/*
-	 * We couldn't have accounted to this cgroup, because it hasn't got
-	 * activated yet, so this should succeed.
-	 */
-	err = page_counter_limit(&memcg->kmem, nr_pages);
-	VM_BUG_ON(err);
-
 	static_branch_inc(&memcg_kmem_enabled_key);
 	/*
 	 * A memory cgroup is considered kmem-active as soon as it gets
@@ -2903,10 +2895,14 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
 	int ret;
 
 	mutex_lock(&memcg_limit_mutex);
-	if (!memcg_kmem_is_active(memcg))
-		ret = memcg_activate_kmem(memcg, limit);
-	else
-		ret = page_counter_limit(&memcg->kmem, limit);
+	/* Top-level cgroup doesn't propagate from root */
+	if (!memcg_kmem_is_active(memcg)) {
+		ret = memcg_activate_kmem(memcg);
+		if (ret)
+			goto out;
+	}
+	ret = page_counter_limit(&memcg->kmem, limit);
+out:
 	mutex_unlock(&memcg_limit_mutex);
 	return ret;
 }
@@ -2925,7 +2921,7 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
 	 * after this point, because it has at least one child already.
 	 */
 	if (memcg_kmem_is_active(parent))
-		ret = memcg_activate_kmem(memcg, PAGE_COUNTER_MAX);
+		ret = memcg_activate_kmem(memcg);
 	mutex_unlock(&memcg_limit_mutex);
 	return ret;
 }
-- 
2.6.3

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


#1287220

FromVladimir Davydov <vdavydov@virtuozzo.com>
Date2015-12-09 10:10 +0100
Message-ID<qDIV5-6nQ-39@gated-at.bofh.it>
In reply to#1286746
On Tue, Dec 08, 2015 at 01:34:19PM -0500, Johannes Weiner wrote:
> The kmem page_counter's limit is initialized to PAGE_COUNTER_MAX
> inside mem_cgroup_css_online(). There is no need to repeat this
> from memcg_propagate_kmem().
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com>
--
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]


#1288483

FromMichal Hocko <mhocko@kernel.org>
Date2015-12-10 13:50 +0100
Message-ID<qE8Pv-6ig-7@gated-at.bofh.it>
In reply to#1286746
On Tue 08-12-15 13:34:19, Johannes Weiner wrote:
> The kmem page_counter's limit is initialized to PAGE_COUNTER_MAX
> inside mem_cgroup_css_online(). There is no need to repeat this
> from memcg_propagate_kmem().
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

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

> ---
>  mm/memcontrol.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index eda8d43..02167db 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2840,8 +2840,7 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
>  }
>  
>  #ifdef CONFIG_MEMCG_KMEM
> -static int memcg_activate_kmem(struct mem_cgroup *memcg,
> -			       unsigned long nr_pages)
> +static int memcg_activate_kmem(struct mem_cgroup *memcg)
>  {
>  	int err = 0;
>  	int memcg_id;
> @@ -2876,13 +2875,6 @@ static int memcg_activate_kmem(struct mem_cgroup *memcg,
>  		goto out;
>  	}
>  
> -	/*
> -	 * We couldn't have accounted to this cgroup, because it hasn't got
> -	 * activated yet, so this should succeed.
> -	 */
> -	err = page_counter_limit(&memcg->kmem, nr_pages);
> -	VM_BUG_ON(err);
> -
>  	static_branch_inc(&memcg_kmem_enabled_key);
>  	/*
>  	 * A memory cgroup is considered kmem-active as soon as it gets
> @@ -2903,10 +2895,14 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
>  	int ret;
>  
>  	mutex_lock(&memcg_limit_mutex);
> -	if (!memcg_kmem_is_active(memcg))
> -		ret = memcg_activate_kmem(memcg, limit);
> -	else
> -		ret = page_counter_limit(&memcg->kmem, limit);
> +	/* Top-level cgroup doesn't propagate from root */
> +	if (!memcg_kmem_is_active(memcg)) {
> +		ret = memcg_activate_kmem(memcg);
> +		if (ret)
> +			goto out;
> +	}
> +	ret = page_counter_limit(&memcg->kmem, limit);
> +out:
>  	mutex_unlock(&memcg_limit_mutex);
>  	return ret;
>  }
> @@ -2925,7 +2921,7 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
>  	 * after this point, because it has at least one child already.
>  	 */
>  	if (memcg_kmem_is_active(parent))
> -		ret = memcg_activate_kmem(memcg, PAGE_COUNTER_MAX);
> +		ret = memcg_activate_kmem(memcg);
>  	mutex_unlock(&memcg_limit_mutex);
>  	return ret;
>  }
> -- 
> 2.6.3

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