linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Qais Yousef <qais.yousef@arm.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Patrick Bellasi <patrick.bellasi@matbug.net>,
	Tejun Heo <tj@kernel.org>, Quentin Perret <qperret@google.com>,
	Wei Wang <wvw@google.com>, Yun Hsiang <hsiang023167@gmail.com>,
	Xuewen Yan <xuewen.yan94@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sched/uclamp: Fix uclamp_tg_restrict()
Date: Tue, 22 Jun 2021 15:13:00 +0200	[thread overview]
Message-ID: <YNHh3DeeQF6VbwYX@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210617165155.3774110-1-qais.yousef@arm.com>

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@gmail.com>
> Fixes: 0c18f2ecfcc2 ("sched/uclamp: Fix wrong implementation of cpu.uclamp.min")
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>

Thanks!

  reply	other threads:[~2021-06-22 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 16:51 [PATCH v2] sched/uclamp: Fix uclamp_tg_restrict() Qais Yousef
2021-06-22 13:13 ` Peter Zijlstra [this message]
2021-06-23  8:19 ` [tip: sched/core] " tip-bot2 for Qais Yousef

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNHh3DeeQF6VbwYX@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=hsiang023167@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=patrick.bellasi@matbug.net \
    --cc=qais.yousef@arm.com \
    --cc=qperret@google.com \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=wvw@google.com \
    --cc=xuewen.yan94@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).