Re: [RFC PATCH 4/6] sched/fair: Introduce an energy estimation helper function

From: Juri Lelli
Date: Wed Mar 21 2018 - 10:50:46 EST


On 21/03/18 14:26, Quentin Perret wrote:
> On Wednesday 21 Mar 2018 at 12:39:21 (+0000), Patrick Bellasi wrote:
> > On 20-Mar 09:43, Dietmar Eggemann wrote:

[...]

> >
> > If that's the case then, in the previous function, you can certainly
> > avoid the initialization of *cs and maybe also add an explicit:
> >
> > BUG_ON(em->nb_cap_states == 0);
> >
> > which helps even just as "in code documentation".
> >
> > But, I'm not sure if maintainers like BUG_ON in scheduler code :)
>
> Yes, I'm not sure about the BUG_ON either :). I agree that it would be
> nice to document somewhere that compute_energy() is unsafe to call
> without sched_energy_present. I can simply add a proper doc comment to
> this function actually. Would that work ?

If it is something that must not happen and it is also non recoverable
at runtime, then...

$ git grep BUG_ON -- kernel/sched/ | wc -l
50

:)