Re: [RFC PATCH v4 03/12] PM: Introduce an Energy Model management framework

From: Quentin Perret
Date: Thu Jul 05 2018 - 11:09:20 EST


On Thursday 05 Jul 2018 at 16:39:01 (+0200), Peter Zijlstra wrote:
> On Thu, Jun 28, 2018 at 12:40:34PM +0100, Quentin Perret wrote:
> > +/**
> > + * em_fd_nr_cap_states() - Get the number of capacity states of a freq. domain
> > + * @fd : frequency domain for which want to do this
> > + *
> > + * Return: the number of capacity state in the frequency domain table
> > + */
> > +static inline int em_fd_nr_cap_states(struct em_freq_domain *fd)
> > +{
> > + struct em_cs_table *table;
> > + int nr_states;
> > +
> > + rcu_read_lock();
> > + table = rcu_dereference(fd->cs_table);
> > + nr_states = table->nr_cap_states;
> > + rcu_read_unlock();
>
> So right here, we can continue to free @table...
>
> > +
> > + return nr_states;
> > +}
>
> and then what does the value we return mean?

Hmm that's a good point. In practice the number of entries in the table
never changes, so that makes no sense to keep that value in the
RCU-protected struct. I can just move nr_cap_states in struct
freq_domain directly and access it without RCU protection, it is simply
not needed.

I'll change that for the next version.

Thanks,
Quentin