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


Groups > linux.kernel > #1454903 > unrolled thread

Re: [PATCH v2 3/3] mm: memcontrol: add sanity checks for memcg->id.ref on get/put

Started byMichal Hocko <mhocko@kernel.org>
First post2016-08-02 18:20 +0200
Last post2016-08-02 18:20 +0200
Articles 1 — 1 participant

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

  Re: [PATCH v2 3/3] mm: memcontrol: add sanity checks for  memcg->id.ref on get/put Michal Hocko <mhocko@kernel.org> - 2016-08-02 18:20 +0200

#1454903 — Re: [PATCH v2 3/3] mm: memcontrol: add sanity checks for memcg->id.ref on get/put

FromMichal Hocko <mhocko@kernel.org>
Date2016-08-02 18:20 +0200
SubjectRe: [PATCH v2 3/3] mm: memcontrol: add sanity checks for memcg->id.ref on get/put
Message-ID<s1KAb-6OZ-45@gated-at.bofh.it>
On Tue 02-08-16 18:00:50, Vladimir Davydov wrote:
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>

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

> ---
>  mm/memcontrol.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 67109d556a4a..32b2f33865f9 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4033,6 +4033,7 @@ static DEFINE_IDR(mem_cgroup_idr);
>  
>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
>  {
> +	VM_BUG_ON(atomic_read(&memcg->id.ref) <= 0);
>  	atomic_add(n, &memcg->id.ref);
>  }
>  
> @@ -4056,6 +4057,7 @@ static struct mem_cgroup *mem_cgroup_id_get_active(struct mem_cgroup *memcg)
>  
>  static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
>  {
> +	VM_BUG_ON(atomic_read(&memcg->id.ref) < n);
>  	if (atomic_sub_and_test(n, &memcg->id.ref)) {
>  		idr_remove(&mem_cgroup_idr, memcg->id.id);
>  		memcg->id.id = 0;
> @@ -4176,6 +4178,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
>  	INIT_LIST_HEAD(&memcg->cgwb_list);
>  #endif
>  	idr_replace(&mem_cgroup_idr, memcg, memcg->id.id);
> +	atomic_set(&memcg->id.ref, 1);
>  	return memcg;
>  fail:
>  	if (memcg->id.id > 0)
> @@ -4245,7 +4248,6 @@ fail:
>  static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
>  {
>  	/* Online state pins memcg ID, memcg ID pins CSS */
> -	mem_cgroup_id_get(mem_cgroup_from_css(css));
>  	css_get(css);
>  	return 0;
>  }
> -- 
> 2.1.4

-- 
Michal Hocko
SUSE Labs

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web