Hi Patrick,

On Monday 08 Jul 2019 at 09:43:53 (+0100), Patrick Bellasi wrote:
> +static inline int uclamp_scale_from_percent(char *buf, u64 *value)
> +{
> +     *value = SCHED_CAPACITY_SCALE;
> +
> +     buf = strim(buf);
> +     if (strncmp("max", buf, 4)) {
> +             s64 percent;
> +             int ret;
> +
> +             ret = cgroup_parse_float(buf, 2, &percent);
> +             if (ret)
> +                     return ret;
> +
> +             percent <<= SCHED_CAPACITY_SHIFT;
> +             *value = DIV_ROUND_CLOSEST_ULL(percent, 10000);
> +     }
> +
> +     return 0;
> +}
> +
> +static inline u64 uclamp_percent_from_scale(u64 value)
> +{
> +     return DIV_ROUND_CLOSEST_ULL(value * 10000, SCHED_CAPACITY_SCALE);
> +}

FWIW, I tried the patches and realized these conversions result in a
'funny' behaviour from a user's perspective. Things like this happen:

   $ echo 20 > cpu.uclamp.min
   $ cat cpu.uclamp.min
   20.2
   $ echo 20.2 > cpu.uclamp.min
   $ cat cpu.uclamp.min
   20.21

Having looked at the code, I get why this is happening, but I'm not sure
if a random user will. It's not an issue per se, but it's just a bit
weird.

I guess one way to fix this would be to revert back to having a
1024-scale for the cgroup interface too ... Though I understand Tejun
wanted % for consistency with other things.

So, I'm not sure if this is still up for discussion, but in any case I
wanted to say I support your original idea of using a 1024-scale for the
cgroups interface, since that would solve the 'issue' above and keeps
things consistent with the per-task API too.

Thanks,
Quentin

Reply via email to