* Re: [RFC][PATCH] sched: Optimize cpufreq_update_util [not found] ` <20210319073751.qz2ytpxl2ikrt2b7@vireshk-i7> @ 2021-03-19 14:35 ` Rafael J. Wysocki 2021-03-19 15:20 ` Viresh Kumar 0 siblings, 1 reply; 2+ messages in thread From: Rafael J. Wysocki @ 2021-03-19 14:35 UTC (permalink / raw) To: Peter Zijlstra, Viresh Kumar Cc: mingo, vincent.guittot, dietmar.eggemann, rostedt, linux-kernel, Josh Poimboeuf, Linux PM, Rafael J. Wysocki On Friday, March 19, 2021 8:37:51 AM CET Viresh Kumar wrote: > On 18-03-21, 22:28, Peter Zijlstra wrote: > > Also, is there a lock order comment in cpufreq somewhere? > > I don't think so. > > > I tried > > following it, but eventually gave up and figured 'asking' lockdep was > > far simpler. > > This will get called from CPU's online/offline path at worst, nothing more. I'm not sure if I understand you correctly, but for completeness the callback is also set/unset on driver registration and governor switch. > > +static void cpufreq_update_optimize(void) > > +{ > > + struct update_util_data *data; > > + cpu_util_update_f func = NULL, dfunc; > > + int cpu; > > + > > + for_each_online_cpu(cpu) { > > + data = per_cpu(cpufreq_update_util_data, cpu); > > + dfunc = data ? READ_ONCE(data->func) : NULL; > > + > > + if (dfunc) { > > + if (!func) > > + func = dfunc; > > + else if (func != dfunc) > > + return; > > + } else if (func) > > + return; > > + } > > So there is nothing cpufreq specific IIRC that can help make this better, this > is basically per policy. Well, in some cases the driver knows that there will never be more that 1 CPU per policy and so schedutil will never use the "shared" variant. For instance, with intel_pstate all CPUs will always use the same callback. > For example, on an ARM platform we have two cpufreq policies with one policy > covering 4 CPUs, while the other one covering only 1 (maybe because we didn't > add those CPUs in DT or something else), then also we will end up separate > routines. > > Or if we take all CPUs of a policy offline and then bring them up one by one, I > think for the first CPU online event in that policy we will end up using the > sugov_update_single_freq() variant for some time, until the time more CPUs come > up. > > So traversing the way you did this is probably something that will work properly > in all corner cases. Agreed. It might be simplified in some cases, though, AFAICS. ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC][PATCH] sched: Optimize cpufreq_update_util 2021-03-19 14:35 ` [RFC][PATCH] sched: Optimize cpufreq_update_util Rafael J. Wysocki @ 2021-03-19 15:20 ` Viresh Kumar 0 siblings, 0 replies; 2+ messages in thread From: Viresh Kumar @ 2021-03-19 15:20 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Peter Zijlstra, mingo, vincent.guittot, dietmar.eggemann, rostedt, linux-kernel, Josh Poimboeuf, Linux PM, Rafael J. Wysocki On 19-03-21, 15:35, Rafael J. Wysocki wrote: > On Friday, March 19, 2021 8:37:51 AM CET Viresh Kumar wrote: > > On 18-03-21, 22:28, Peter Zijlstra wrote: > > > Also, is there a lock order comment in cpufreq somewhere? > > > > I don't think so. > > > > > I tried > > > following it, but eventually gave up and figured 'asking' lockdep was > > > far simpler. > > > > This will get called from CPU's online/offline path at worst, nothing more. > > I'm not sure if I understand you correctly, but for completeness the callback > is also set/unset on driver registration and governor switch. Right, I believe that those cases don't have any specific locking constraints and so scheduler code doesn't need to worry about them. cpuslocked stuff needs to be considered though. > > > +static void cpufreq_update_optimize(void) > > > +{ > > > + struct update_util_data *data; > > > + cpu_util_update_f func = NULL, dfunc; > > > + int cpu; > > > + > > > + for_each_online_cpu(cpu) { > > > + data = per_cpu(cpufreq_update_util_data, cpu); > > > + dfunc = data ? READ_ONCE(data->func) : NULL; > > > + > > > + if (dfunc) { > > > + if (!func) > > > + func = dfunc; > > > + else if (func != dfunc) > > > + return; > > > + } else if (func) > > > + return; > > > + } > > > > So there is nothing cpufreq specific IIRC that can help make this better, this > > is basically per policy. > > Well, in some cases the driver knows that there will never be more that 1 CPU > per policy and so schedutil will never use the "shared" variant. > > For instance, with intel_pstate all CPUs will always use the same callback. Right, only for single policy cases we can have some optimization (though I don't feel its worth here) as this isn't going to happen in hotpath. -- viresh ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-19 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210318212826.GW4746@worktop.programming.kicks-ass.net>
[not found] ` <20210319073751.qz2ytpxl2ikrt2b7@vireshk-i7>
2021-03-19 14:35 ` [RFC][PATCH] sched: Optimize cpufreq_update_util Rafael J. Wysocki
2021-03-19 15:20 ` Viresh Kumar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox