Re: [PATCH v2] sched/uclamp: Fix overzealous type replacement

From: Peter Zijlstra
Date: Fri Nov 15 2019 - 15:21:35 EST


On Fri, Nov 15, 2019 at 06:34:19PM +0100, Vincent Guittot wrote:
> On Fri, 15 Nov 2019 at 18:10, Valentin Schneider
> <valentin.schneider@xxxxxxx> wrote:
> >
> > On 15/11/2019 14:29, Valentin Schneider wrote:
> > > On 15/11/2019 14:07, Vincent Guittot wrote:
> > >>> -static inline enum uclamp_id uclamp_none(enum uclamp_id clamp_id)
> > >>> +static inline unsigned int uclamp_none(enum uclamp_id clamp_id)
> > >>
> > >> Out of curiosity why uclamp decided to use unsigned int to manipulate
> > >> utilization instead of unsigned long which is the type of util_avg ?
> > >>
> > >
> > > I didn't stare at the discussion much, but I think it stems from the
> > > design choices behind struct uclamp_se: everything is crammed in an unsigned
> > > int bitfield. Let me see if I can find some relevant mails.
> > >
> >
> > So I think a relevant mail is:
> >
> > https://lore.kernel.org/lkml/20180912174236.GB24106@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
> >
> > Other than that, the uclamp_se.value field was 'int' in v1 and has been
> > 'unsigned int' for all following versions. uclamp_bucket.value is a bitfield
> > of an 'unsigned long' just because we want more headroom for the tasks count,
> > AFAICT.
>
> Thanks for the pointer and deep diving in the email threads

It was all in an effort to minimize the number of cachelines touched to
maintain this data.