On 12/10/21 2:05 PM, enh wrote:
> On Fri, Dec 10, 2021 at 3:46 AM Rob Landley <[email protected]
>     Could you ask them what uclamp_validate() in kernel/sched/core.c is 
> trying to
>     do? It seems like if you've set container limits for the largest or 
> smallest
>     allowed uclamp values (like that wiki page was going on about). then it 
> checks
>     THOSE instead of the ones provided by the user to see if they cross. 
> Overwrites
>     the ones provided by the user entirely, and doesn't check them. So I 
> THINK if I
>     set the container min limit to 1 and the container max limit to 1023, I 
> could
>     then have a process within the container request a min of 1000 and a max 
> of 100
>     and it would pass this function? (Or am I misreading it?)
> 
> i must be misreading it too, because i don't even know which lines you're
> referring to, unless we were looking at different versions...
> https://elixir.bootlin.com/linux/latest/source/kernel/sched/core.c#L1780

Yup, that part:

static int uclamp_validate(struct task_struct *p,
                           const struct sched_attr *attr)
{
        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) {
                util_min = attr->sched_util_min;

                if (util_min + 1 > SCHED_CAPACITY_SCALE + 1)
                        return -EINVAL;
        }

        if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) {
                util_max = attr->sched_util_max;

                if (util_max + 1 > SCHED_CAPACITY_SCALE + 1)
                        return -EINVAL;
        }

        if (util_min != -1 && util_max != -1 && util_min > util_max)
                return -EINVAL;

See how util_min is set from uclamp_req at the start, but when
SCHED_FLAG_UTIL_CLAMP_MIN the local variable gets overwritten by the attr->
version, and there's only one util_min > util_max test?

If SCHED_FLAG_UTIIL_CLAMP_BLAH is set, the uclamp_req versions of sched_util_min
and sched_util_max are never examined by this function. Just fetched and then
overwritten.

I.E:

static int uclamp_validate(struct task_struct *p,
                           const struct sched_attr *attr)
{
        int util_min = p->uclamp_req[UCLAMP_MIN].value;

        if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN)
                util_min = attr->sched_util_min;

        if (test util_min)
                return -EINVAL;


Rob
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to