From: Yun Hsiang <hsiang023167@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
linux-kernel@vger.kernel.org, qais.yousef@arm.com,
patrick.bellasi@matbug.net, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v5 1/1] sched/uclamp: add SCHED_FLAG_UTIL_CLAMP_RESET flag to reset uclamp
Date: Thu, 12 Nov 2020 13:44:45 +0800 [thread overview]
Message-ID: <20201112054445.GA1257287@ubuntu> (raw)
In-Reply-To: <20201111180441.GJ2628@hirez.programming.kicks-ass.net>
On Wed, Nov 11, 2020 at 07:04:41PM +0100, Peter Zijlstra wrote:
> On Wed, Nov 11, 2020 at 06:41:07PM +0100, Dietmar Eggemann wrote:
> > diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h
> > index c852153ddb0d..b9165f17dddc 100644
> > --- a/include/uapi/linux/sched/types.h
> > +++ b/include/uapi/linux/sched/types.h
> > @@ -115,8 +115,8 @@ struct sched_attr {
> > __u64 sched_period;
> >
> > /* Utilization hints */
> > - __u32 sched_util_min;
> > - __u32 sched_util_max;
> > + __s32 sched_util_min;
> > + __s32 sched_util_max;
>
> So that's UAPI, not sure we can change the type here.
+1
I am also concerned about changing UAPI.
But if we can chage sched_util_{min/max} to __s32, use -1 to reset is better than
adding flags.
>
> > };
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 3dc415f58bd7..caaa2a8434b9 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -1413,17 +1413,24 @@ int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
> > static int uclamp_validate(struct task_struct *p,
> > const struct sched_attr *attr)
> > {
> > - unsigned int lower_bound = p->uclamp_req[UCLAMP_MIN].value;
> > - unsigned int upper_bound = p->uclamp_req[UCLAMP_MAX].value;
> > + int util_min = p->uclamp_req[UCLAMP_MIN].value;
> > + int util_max = p->uclamp_req[UCLAMP_MAX].value;
> >
> > - if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN)
> > - lower_bound = attr->sched_util_min;
> > - if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX)
> > - upper_bound = attr->sched_util_max;
> > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) {
> > + util_min = attr->sched_util_min;
> >
> > - if (lower_bound > upper_bound)
> > - return -EINVAL;
> > - if (upper_bound > SCHED_CAPACITY_SCALE)
> > + if (util_min < -1 || util_min > SCHED_CAPACITY_SCALE)
> > + return -EINVAL;
> > + }
> > +
> > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) {
> > + util_max = attr->sched_util_max;
> > +
> > + if (util_max < -1 || util_max > SCHED_CAPACITY_SCALE)
> > + return -EINVAL;
> > + }
>
> Luckily we can write that range as a single branch like:
>
> if (util_{min,max} + 1 > SCHED_CAPACITY_SCALE+1)
>
> which assumes u32 :-)
>
> > +
> > + if (util_min != -1 && util_max != -1 && util_min > util_max)
> > return -EINVAL;
>
> I think that will compile as is, otherwise write it like ~0u, which is
> the same bit pattern.
>
next prev parent reply other threads:[~2020-11-12 5:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 2:37 [PATCH v5 1/1] sched/uclamp: add SCHED_FLAG_UTIL_CLAMP_RESET flag to reset uclamp Yun Hsiang
2020-11-03 13:46 ` Qais Yousef
2020-11-03 13:48 ` Qais Yousef
2020-11-04 9:45 ` Dietmar Eggemann
2020-11-07 18:24 ` Yun Hsiang
2020-11-06 10:36 ` Patrick Bellasi
2020-11-07 19:15 ` Yun Hsiang
2020-11-09 13:41 ` Qais Yousef
2020-11-10 12:18 ` Peter Zijlstra
2020-11-10 12:21 ` Peter Zijlstra
2020-11-11 17:41 ` Dietmar Eggemann
2020-11-11 18:04 ` Peter Zijlstra
2020-11-12 5:44 ` Yun Hsiang [this message]
2020-11-12 13:05 ` Dietmar Eggemann
2020-11-12 14:41 ` Qais Yousef
2020-11-12 16:01 ` Dietmar Eggemann
2020-11-13 11:45 ` Dietmar Eggemann
2020-11-13 12:26 ` 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=20201112054445.GA1257287@ubuntu \
--to=hsiang023167@gmail.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=patrick.bellasi@matbug.net \
--cc=peterz@infradead.org \
--cc=qais.yousef@arm.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