public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Peter Zijlstra <peterz@infradead.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: mingo@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	linux-kernel@vger.kernel.org,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [RFC][PATCH] sched: Optimize cpufreq_update_util
Date: Fri, 19 Mar 2021 15:35:43 +0100	[thread overview]
Message-ID: <5452200.DvuYhMxLoT@kreacher> (raw)
In-Reply-To: <20210319073751.qz2ytpxl2ikrt2b7@vireshk-i7>

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.




  reply	other threads:[~2021-03-19 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 21:28 [RFC][PATCH] sched: Optimize cpufreq_update_util Peter Zijlstra
2021-03-19  7:37 ` Viresh Kumar
2021-03-19 14:35   ` Rafael J. Wysocki [this message]
2021-03-19 15:20     ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5452200.DvuYhMxLoT@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox