Messages in this thread | | | Date | Fri, 30 Apr 2021 13:14:38 +0000 | From | Quentin Perret <> | Subject | Re: [PATCH v2] sched: Fix out-of-bound access in uclamp |
| |
On Friday 30 Apr 2021 at 15:00:00 (+0200), Dietmar Eggemann wrote: > On 30/04/2021 14:03, Vincent Guittot wrote: > IMHO, this asks for > > min_t(unsigned int, clamp_value/UCLAMP_BUCKET_DELTA, UCLAMP_BUCKETS-1);
Yep, that's what I have locally.
> >> } > >> > >> static inline unsigned int uclamp_none(enum uclamp_id clamp_id) > > Looks like this will fix a lot of possible configs: > > nbr buckets 1-4, 7-8, 10-12, 14-17, *20*, 26, 29-32 ... > > We would still introduce larger last buckets, right?
Indeed. The only better alternative I could see was to 'spread' the error accross multiple buckets (e.g. make the last few buckets a bit bigger instead of having all of it accumulated on the last one), but not sure it is worth the overhead.
Suggestions are welcome though.
> Examples: > > nbr_buckets delta last bucket size > > 20 51 +5 = 56 > > 26 39 +10 = 49 > > 29 35 +9 = 44
Yes the error can become worse in the relative sense with a large number of buckets, but again the max is 20 so we should be fine?
Thanks, Quentin
| |