[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YNHh3DeeQF6VbwYX@hirez.programming.kicks-ass.net>
Date: Tue, 22 Jun 2021 15:13:00 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Qais Yousef <qais.yousef@....com>
Cc: Ingo Molnar <mingo@...nel.org>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Patrick Bellasi <patrick.bellasi@...bug.net>,
Tejun Heo <tj@...nel.org>, Quentin Perret <qperret@...gle.com>,
Wei Wang <wvw@...gle.com>, Yun Hsiang <hsiang023167@...il.com>,
Xuewen Yan <xuewen.yan94@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] sched/uclamp: Fix uclamp_tg_restrict()
On Thu, Jun 17, 2021 at 05:51:55PM +0100, Qais Yousef wrote:
> Now cpu.uclamp.min acts as a protection, we need to make sure that the
> uclamp request of the task is within the allowed range of the cgroup,
> that is it is clamp()'ed correctly by tg->uclamp[UCLAMP_MIN] and
> tg->uclamp[UCLAMP_MAX].
>
> As reported by Xuewen [1] we can have some corner cases where there's
> inversion between uclamp requested by task (p) and the uclamp values of
> the taskgroup it's attached to (tg). Following table demonstrates
> 2 corner cases:
>
> | p | tg | effective
> -----------+-----+------+-----------
> CASE 1
> -----------+-----+------+-----------
> uclamp_min | 60% | 0% | 60%
> -----------+-----+------+-----------
> uclamp_max | 80% | 50% | 50%
> -----------+-----+------+-----------
> CASE 2
> -----------+-----+------+-----------
> uclamp_min | 0% | 30% | 30%
> -----------+-----+------+-----------
> uclamp_max | 20% | 50% | 20%
> -----------+-----+------+-----------
>
> With this fix we get:
>
> | p | tg | effective
> -----------+-----+------+-----------
> CASE 1
> -----------+-----+------+-----------
> uclamp_min | 60% | 0% | 50%
> -----------+-----+------+-----------
> uclamp_max | 80% | 50% | 50%
> -----------+-----+------+-----------
> CASE 2
> -----------+-----+------+-----------
> uclamp_min | 0% | 30% | 30%
> -----------+-----+------+-----------
> uclamp_max | 20% | 50% | 30%
> -----------+-----+------+-----------
>
> Additionally uclamp_update_active_tasks() must now unconditionally
> update both UCLAMP_MIN/MAX because changing the tg's UCLAMP_MAX for
> instance could have an impact on the effective UCLAMP_MIN of the tasks.
>
> | p | tg | effective
> -----------+-----+------+-----------
> old
> -----------+-----+------+-----------
> uclamp_min | 60% | 0% | 50%
> -----------+-----+------+-----------
> uclamp_max | 80% | 50% | 50%
> -----------+-----+------+-----------
> *new*
> -----------+-----+------+-----------
> uclamp_min | 60% | 0% | *60%*
> -----------+-----+------+-----------
> uclamp_max | 80% |*70%* | *70%*
> -----------+-----+------+-----------
>
> [1] https://lore.kernel.org/lkml/CAB8ipk_a6VFNjiEnHRHkUMBKbA+qzPQvhtNjJ_YNzQhqV_o8Zw@mail.gmail.com/
>
> Reported-by: Xuewen Yan <xuewen.yan94@...il.com>
> Fixes: 0c18f2ecfcc2 ("sched/uclamp: Fix wrong implementation of cpu.uclamp.min")
> Signed-off-by: Qais Yousef <qais.yousef@....com>
Thanks!
Powered by blists - more mailing lists