Re: [PATCH] sched: Make uclamp changes depend on CAP_SYS_NICE

From: Quentin Perret
Date: Thu Jun 10 2021 - 03:45:52 EST


On Thursday 10 Jun 2021 at 11:33:04 (+0800), Xuewen Yan wrote:
> On Thu, Jun 10, 2021 at 2:16 AM Quentin Perret <qperret@xxxxxxxxxx> wrote:
> > +static bool uclamp_reduce(struct task_struct *p, const struct sched_attr *attr)
> > +{
> > + int util_min, util_max;
> > +
> > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) {
> > + util_min = p->uclamp_req[UCLAMP_MIN].value;
> > + if (attr->sched_util_min > util_min)
> > + return false;
> > + }
> > +
> > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) {
> > + util_max = p->uclamp_req[UCLAMP_MAX].value;
> > + if (attr->sched_util_max > util_max)
> > + return false;
>
> when the attr->sched_util_max = -1, and the util_max < 1024, here may
> should return false, but it would return ture.

Aha, indeed, I missed that -1 could be used to reset the clamps. I'll
send a v2.

Thanks!
Quentin