[Devel] [PATCH rh7] sched/core/cfs: don't reset nr_cpus while setting cpu limits

Vladimir Davydov vdavydov at virtuozzo.com
Wed Jun 8 00:44:41 PDT 2016


On Tue, Jun 07, 2016 at 04:50:38PM +0300, Andrey Ryabinin wrote:
> Setting cpu limits reset number of cpus
>     # echo 2 >/sys/fs/cgroup/cpu,cpuacct/101/cpu.nr_cpus
>     # exec 101 cat /proc/cpuinfo |grep -c processor
>      2
>     # echo 160000 >/sys/fs/cgroup/cpu,cpuacct/101/cpu.cfs_quota_us
>     # vzctl exec 101 cat /proc/cpuinfo |grep -c processor
>      4
>     # cat /sys/fs/cgroup/cpu,cpuacct/101/cpu.nr_cpus
>      0
> 
> tg_update_cpu_limit() does that without any apparent reason,
> so let's fix it,.
> 
> https://jira.sw.ru/browse/PSBM-48061
> 
> Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
> ---
>  kernel/sched/core.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 2c147c8..51ebed2 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8696,7 +8696,6 @@ static void tg_update_cpu_limit(struct task_group *tg)
>  	}
>  
>  	tg->cpu_rate = rate;
> -	tg->nr_cpus = 0;

This is incorrect. Suppose nr_cpus = 2 and you set cfs_quota to
4 * cfs_period. If you don't reset nr_cpus, you'll get cpu limit equal
to 400, although it should be min(nr_cpus * 100, cpu_rate) = 200.

>  }
>  
>  static int tg_set_cpu_limit(struct task_group *tg,


More information about the Devel mailing list