Re: [RFCv7 PATCH 03/10] sched: scheduler-driven cpu frequency selection

From: Peter Zijlstra
Date: Tue Mar 01 2016 - 07:57:40 EST


On Sat, Feb 27, 2016 at 01:08:02AM +0100, Rafael J. Wysocki wrote:
> @@ -95,18 +98,20 @@ EXPORT_SYMBOL_GPL(cpufreq_set_update_uti
> *
> * This function is called by the scheduler on every invocation of
> * update_load_avg() on the CPU whose utilization is being updated.
> + *
> + * It can only be called from RCU-sched read-side critical sections.
> */
> void cpufreq_update_util(u64 time, unsigned long util, unsigned long max)
> {
> struct update_util_data *data;
>
> - rcu_read_lock();
> -

Maybe, just because I'm paranoid, add something like:

#ifdef CONFIG_LOCKDEP
WARN_ON(debug_locks && !rcu_read_lock_sched_held());
#endif

> data = rcu_dereference(*this_cpu_ptr(&cpufreq_update_util_data));
> - if (data && data->func)
> + /*
> + * If this isn't inside of an RCU-sched read-side critical section, data
> + * may become NULL after the check below.
> + */
> + if (data)
> data->func(data, time, util, max);
> -
> - rcu_read_unlock();
> }