LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Xuewen Yan <xuewen.yan94@gmail.com>
To: Qais Yousef <qais.yousef@arm.com>
Cc: Quentin Perret <qperret@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Benjamin Segall <bsegall@google.com>,
	Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Ryan Y <xuewyan@foxmail.com>,
	Patrick Bellasi <patrick.bellasi@matbug.net>,
	tj@kernel.org
Subject: Re: [PATCH] sched/uclamp: Avoid setting cpu.uclamp.min bigger than cpu.uclamp.max
Date: Sat, 5 Jun 2021 21:24:20 +0800
Message-ID: <CAB8ipk_a6VFNjiEnHRHkUMBKbA+qzPQvhtNjJ_YNzQhqV_o8Zw@mail.gmail.com> (raw)
In-Reply-To: <20210605114908.mqfsip5pskamls6k@e107158-lin.cambridge.arm.com>

Hi Qais

On Sat, Jun 5, 2021 at 7:49 PM Qais Yousef <qais.yousef@arm.com> wrote:
> > >
> > In addition,In your patch:
> > 6938840392c89 ("sched/uclamp: Fix wrong implementation of cpu.uclamp.min")
> > https://lkml.kernel.org/r/20210510145032.1934078-2-qais.yousef@arm.com
> >
> > + switch (clamp_id) {
> > + case UCLAMP_MIN: {
> > + struct uclamp_se uc_min = task_group(p)->uclamp[clamp_id];
> > + if (uc_req.value < uc_min.value)
> > + return uc_min;
> > + break;
> >
> > When the clamp_id = UCLAMP_MIN, why not judge the uc_req.value is
> > bigger than task_group(p)->uclamp[UCLAMP_MAX] ?
>
> Because of the requirement I pointed you to in cgroup-v2.rst. We must allow any
> value to be requested.
>
> Ultimately if we had
>
>         cpu.uclamp.min = 80
>         cpu.uclamp.max = 50
>
> then we want to remember the original request but make sure the effective value
> is capped.
>
> For the user in the future modifies the values such that
>
>         cpu.uclamp.max = max
>
> Then we want to remember cpu.uclamp.min = 80 and apply it since now the
> cpu.uclamp.max was relaxed to allow the boost value.
>
> > Because when the p->uclamp_req[UCLAMP_MIN] >  task_group(p)->uclamp[UCLAMP_MAX],
> > the patch can not clamp the p->uclamp_req[UCLAMP_MIN/MAX] into
> > [ task_group(p)->uclamp[UCLAMP_MAX],  task_group(p)->uclamp[UCLAMP_MAX] ].
> >
> > Is it necessary to fix it here?
>
> Nope. We must allow any combination values to be accepted and remember them so
> if one changes we ensure the new effective value is updated accordingly.
> This is how cgroups API works.

Sorry. I may not have expressed it clearly. In your patch (which has
not yet merged into the mainline):

6938840392c89 ("sched/uclamp: Fix wrong implementation of cpu.uclamp.min")
 https://lkml.kernel.org/r/20210510145032.1934078-2-qais.yousef@arm.com

This patch will not affect p->uclamp_req, but consider the following situation:

tg->cpu.uclamp.min = 0
tg->cpu.uclamp.max = 50%

p->uclamp_req[UCLAMP_MIN] = 60%
p->uclamp_req[UCLAMP_MIN] = 80%

The function call process is as follows:
uclamp_eff_value() -> uclamp_eff_get() ->uclamp_tg_restrict()

with your patch, the result is:

p->effective_uclamp_min = 60%
p->effective_uclamp_max = 50%

It would not affect the uclamp_task_util(p), but affect the rq:
when p enqueued:
rq->uclamp[UCLAMP_MIN] = 60%
rq->uclamp[UCLAMP_MIN] = 50%

futher more,  in uclamp_rq_util_with() {
...

min_util = READ_ONCE(rq->uclamp[UCLAMP_MIN].value); //60%
max_util = READ_ONCE(rq->uclamp[UCLAMP_MAX].value);//50%
...
if (unlikely(min_util >= max_util))
return min_util;

return clamp(util, min_util, max_util);
...
}
as a result, it would return 60%.

Thanks!
xuewen

  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 12:38 Xuewen Yan
2021-06-02 13:22 ` Quentin Perret
2021-06-03  2:24   ` Xuewen Yan
2021-06-04 16:08     ` Qais Yousef
2021-06-04 16:22       ` Dietmar Eggemann
2021-06-05  2:14         ` Xuewen Yan
2021-06-05  2:12       ` Xuewen Yan
2021-06-05 11:49         ` Qais Yousef
2021-06-05 13:24           ` Xuewen Yan [this message]
2021-06-05 14:14             ` Qais Yousef
2021-06-07 13:49             ` Qais Yousef
2021-06-08 11:45               ` Xuewen Yan
2021-06-08 14:25                 ` Qais Yousef
2021-06-08 15:01                   ` Xuewen Yan
2021-06-08 18:21                     ` 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=CAB8ipk_a6VFNjiEnHRHkUMBKbA+qzPQvhtNjJ_YNzQhqV_o8Zw@mail.gmail.com \
    --to=xuewen.yan94@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=patrick.bellasi@matbug.net \
    --cc=peterz@infradead.org \
    --cc=qais.yousef@arm.com \
    --cc=qperret@google.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=xuewyan@foxmail.com \
    --cc=zhang.lyra@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git