linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qais Yousef <qais.yousef@arm.com>
To: Xuewen Yan <xuewen.yan94@gmail.com>
Cc: Valentin Schneider <valentin.schneider@arm.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>,
	Patrick Bellasi <patrick.bellasi@matbug.net>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Quentin Perret <qperret@google.com>
Subject: Re: [PATCH] sched/uclamp: Fix getting unreasonable ucalmp_max when rq is idle
Date: Wed, 30 Jun 2021 15:11:22 +0100	[thread overview]
Message-ID: <20210630141122.h5tktnx6kdnlmd32@e107158-lin.cambridge.arm.com> (raw)
In-Reply-To: <CAB8ipk9TMTbw2WGrbLuewk_CaYxrvMOp2Ui5xiHiwYB4NmoRhA@mail.gmail.com>

Thanks for the CC.

On 06/30/21 09:24, Xuewen Yan wrote:
> On Tue, Jun 29, 2021 at 9:50 PM Valentin Schneider
> <valentin.schneider@arm.com> wrote:
> >
> >
> > +Cc Patrick's current address
> >
> > On 18/06/21 15:23, Xuewen Yan wrote:
> > > From: Xuewen Yan <xuewen.yan@unisoc.com>
> > >
> > > Now in uclamp_rq_util_with(), when the task != NULL, the uclamp_max as following:
> > > uc_rq_max = rq->uclamp[UCLAMP_MAX].value;
> > > uc_eff_max = uclamp_eff_value(p, UCLAMP_MAX);
> > > uclamp_max = max{uc_rq_max, uc_eff_max};
> > >
> > > Consider the following scenario:
> > > (1)the rq is idle, the uc_rq_max is last task's UCLAMP_MAX;
> > > (2)the p's uc_eff_max < uc_rq_max.
> > >
> > > The result is the uclamp_max = uc_rq_max instead of uc_eff_max, it is unreasonable.
> > >
> > > The scenario often happens in find_energy_efficient_cpu(), when the task has smaller UCLAMP_MAX.
> > >
> > > Inserts whether the rq is idle in the uclamp_rq_util_with().
> > >
> > > Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
> > > ---
> > >  kernel/sched/sched.h | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> > > index a189bec13729..0feef6af89f2 100644
> > > --- a/kernel/sched/sched.h
> > > +++ b/kernel/sched/sched.h
> > > @@ -2550,7 +2550,10 @@ unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util,
> > >
> > >       if (p) {
> > >               min_util = max(min_util, uclamp_eff_value(p, UCLAMP_MIN));
> > > -             max_util = max(max_util, uclamp_eff_value(p, UCLAMP_MAX));
> > > +             if (rq->uclamp_flags & UCLAMP_FLAG_IDLE)
> > > +                     max_util = uclamp_eff_value(p, UCLAMP_MAX);
> > > +             else
> > > +                     max_util = max(max_util, uclamp_eff_value(p, UCLAMP_MAX));
> >
> > That makes sense to me - enqueuing the task will lift UCLAMP_FLAG_IDLE and
> > set the rq clamp as the task's via uclamp_idle_reset().
> >
> > Does this want a
> >
> >   Fixes: 9d20ad7dfc9a ("sched/uclamp: Add uclamp_util_with()")
> >
> > ?
> 
> Yes,add it.

+1

> 
> >
> > Also, when we have UCLAMP_FLAG_IDLE, we don't even need to read the rq max
> > - and I'm pretty sure the same applies to the rq min. What about something like:

uclamp_min is fine since it defaults to 0. But the suggested improvement looks
good to me.

Thanks

--
Qais Yousef

      parent reply	other threads:[~2021-06-30 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18  7:23 [PATCH] sched/uclamp: Fix getting unreasonable ucalmp_max when rq is idle Xuewen Yan
2021-06-29  3:11 ` Xuewen Yan
2021-06-29 13:50 ` Valentin Schneider
2021-06-30  1:24   ` Xuewen Yan
2021-06-30 11:31     ` Valentin Schneider
2021-06-30 12:05       ` Xuewen Yan
2021-06-30 14:11     ` Qais Yousef [this message]

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=20210630141122.h5tktnx6kdnlmd32@e107158-lin.cambridge.arm.com \
    --to=qais.yousef@arm.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=qperret@google.com \
    --cc=rostedt@goodmis.org \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=xuewen.yan94@gmail.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
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).