[Devel] [PATCH vz7 v2 6/7] ub stat: sync memcg contents with beancounter if required

Vladimir Davydov vdavydov at virtuozzo.com
Fri Oct 2 10:56:24 PDT 2015


On Thu, Oct 01, 2015 at 05:38:43PM +0400, Stanislav Kinsburskiy wrote:

> @@ -224,6 +224,22 @@ int ubstat_alloc_store(struct user_beancounter *ub)
>  }
>  EXPORT_SYMBOL(ubstat_alloc_store);
>  
> +static bool ubstat_need_memcg_sync(long cmd)
> +{
> +	if (UBSTAT_CMD(cmd) != UBSTAT_READ_ONE)
> +		return true;
> +
> +	switch (UBSTAT_PARMID(cmd)) {
> +		case UB_KMEMSIZE:
> +		case UB_DCACHESIZE:
> +		case UB_PHYSPAGES:
> +		case UB_SWAPPAGES:
> +		case UB_OOMGUARPAGES:
> +			return true;
> +	}
> +	return false;
> +}
> +
>  static int ubstat_check_cmd(long cmd)
>  {
>  	switch (UBSTAT_CMD(cmd)) {
> @@ -255,6 +271,9 @@ static int ubstat_get_stat(struct user_beancounter *ub, long cmd,
>  	if (retval)
>  		goto out;
>  
> +	if (ubstat_need_memcg_sync(cmd))
> +		ub_sync_memcg(ub);
> +

May be, just call ub_sync_memcg() unconditionally? It's not that heavy,
besides ubstat is a part of the legacy API, so why overcomplicate?

>  	spin_lock(&ubs_notify_lock);
>  	switch (UBSTAT_CMD(cmd)) {
>  		case UBSTAT_READ_ONE:



More information about the Devel mailing list