Re: [PATCH] memcg: reduce size of per-cpu-stat to be appropriate size.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



KAMEZAWA Hiroyuki wrote:
> How about this one ?
> tested on x86-64 + mmotm-Nov10, works well. 
> (test on other arch is welcome.)
> 
> -Kame
> ==
> As  Jan Blunck <jblunck@xxxxxxx> pointed out, allocating
> per-cpu stat for memcg to the size of NR_CPUS is not good.
> 
> This patch changes mem_cgroup's cpustat allocation not based
> on NR_CPUS but based on nr_cpu_ids.
> 
> From: Jan Blunck <jblunck@xxxxxxx>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> 

Looks good :) . It's ok to use nr_cpu_ids when cgroup_init() is called 
at boot.

Reviewed-by: Li Zefan <lizf@xxxxxxxxxxxxxx>

except..see comments for mem_cgroup_create()

> +static int mem_cgroup_size(void)
> +{
> +	int cpustat_size = nr_cpu_ids * sizeof(struct mem_cgroup_stat_cpu);
> +	return sizeof(struct mem_cgroup) + cpustat_size;
> +}
> +
> +

minor comment: one empty line is suffice.

...

>  static struct cgroup_subsys_state *
>  mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
>  {
>  	struct mem_cgroup *mem;
>  	int node;
>  
> -	if (unlikely((cont->parent) == NULL)) {
> -		mem = &init_mem_cgroup;
> -	} else {
> -		mem = mem_cgroup_alloc();
> -		if (!mem)
> -			return ERR_PTR(-ENOMEM);
> -	}
> +	mem = mem_cgroup_alloc();
> +	if (!mem)
> +		return ERR_PTR(-ENOMEM);
>  
>  	res_counter_init(&mem->res);
>  

free_out:
	for_each_node_state(node, N_POSSIBLE)
		free_mem_cgroup_per_zone_info(mem, node);
	if (cont->parent != NULL)       <---- this check should be removed
		mem_cgroup_free(mem);

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux