[Devel] [PATCH 7/7] packet: Pre-account maximum socket buffer into cg memory (v2)

Vladimir Davydov vdavydov at parallels.com
Thu Jun 4 02:02:28 PDT 2015


On Wed, Jun 03, 2015 at 04:35:35PM +0300, Pavel Emelyanov wrote:
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 4d0a756..45bc78d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -534,6 +534,20 @@ void sock_update_memcg(struct sock *sk)
>  }
>  EXPORT_SYMBOL(sock_update_memcg);
>  
> +struct mem_cgroup *try_get_mem_cgroup_from_current(void)
> +{
> +	struct mem_cgroup *cg;
> +
> +	rcu_read_lock();
> +	cg = mem_cgroup_from_task(current);
> +	if (mem_cgroup_is_root(cg) || !css_tryget(&cg->css))
> +		cg = NULL;
> +	rcu_read_unlock();
> +
> +	return cg;
> +}
> +EXPORT_SYMBOL(try_get_mem_cgroup_from_current);
> +

Why not use try_get_mem_cgroup_from_mm(current->mm) instead?



More information about the Devel mailing list