linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Nicola Mazzucato <nicola.mazzucato@arm.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, sudeep.holla@arm.com,
	rjw@rjwysocki.net, vireshk@kernel.org, robh+dt@kernel.org,
	sboyd@kernel.org, nm@ti.com, daniel.lezcano@linaro.org
Cc: chris.redpath@arm.com, morten.rasmussen@arm.com,
	nicola.mazzucato@arm.com
Subject: [PATCH v3 3/3] [RFC] CPUFreq: Add support for cpu-perf-dependencies
Date: Mon,  2 Nov 2020 12:01:15 +0000	[thread overview]
Message-ID: <20201102120115.29993-4-nicola.mazzucato@arm.com> (raw)
In-Reply-To: <20201102120115.29993-1-nicola.mazzucato@arm.com>

Hi All,

This is a continuation of the previous v2, where we focused mostly on the
dt binding.

I am seeking some feedback/comments on the following two approaches.

Intro:
We have seen that in a system where performance control and hardware
description do not match (i.e. per-cpu), we still need the information of
how the v/f lines are shared among the cpus. We call this information
"performance dependencies".
We got this info through the opp-shared (the previous 2 patches aim for
that).

Problem:
How do we share such info (retrieved from a cpufreq driver) to other
consumers that rely on it? I have two proposals.

First proposal:
Having a new cpumask 'dependent_cpus' to represent the
CPU performance dependencies seems a viable and scalable way.

The main reason for a new cpumaks is that although 'related_cpus'
could be (or could have been) used for such purpose, its meaning has
changed over time [1].

Provided that the cpufreq driver will populate dependent_cpus and set
shared_type accordingly, the s/w components that rely on such description
(we focus on energy-model and cpufreq_cooling for now) will always be
provided with the correct information, when picking the new cpumask.

Proposed changes (at high level)(3):

1) cpufreq: Add new dependent_cpus cpumaks in cpufreq_policy

   * New cpumask addition
   <snippet>
struct cpufreq_policy {
        cpumask_var_t           related_cpus; /* Online + Offline CPUs */
        cpumask_var_t           real_cpus; /* Related and present */

+       /*
+        * CPUs with hardware clk/perf dependencies
+        *
+        * For sw components that rely on h/w info of clk dependencies when hw
+        * coordinates. This cpumask should always reflect the hw dependencies.
+        */
+       cpumask_var_t           dependent_cpus;                 /* all clk-dependent cpus */
+
        unsigned int            shared_type; /* ACPI: ANY or ALL affected CPUs
   </snippet>

   * Fallback mechanism for dependent_cpus. With this, s/w components can
     always pick dependent_cpus regardless the coordination type.
   <snippet>
static int cpufreq_online(unsigned int cpu)

                /* related_cpus should at least include policy->cpus. */
                cpumask_copy(policy->related_cpus, policy->cpus);
+
+               /* dependent_cpus should differ only when hw coordination is in place */
+               if (policy->shared_type != CPUFREQ_SHARED_TYPE_HW)
+                       cpumask_copy(policy->dependent_cpus, policy->cpus);
        }
   </snippet>

   * Add sysfs attribute for dependent_cpus

2) drivers/thermal/cpufreq_cooling: Replace related_cpus with dependent_cpus

3) drivers/cpufreq/scmi-cpufreq: Get perf-dependencies from dev_pm_opp_of_get_sharing_cpus()

   * Call dev_pm_opp_of_get_sharing_cpus()

   * Populate policy->dependent_cpus if possible

   * Set policy->shared_type accordingly

   * Provide to EM the correct performance dependencies information
   <snippet>
-       em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus);
+       /*
+       * EM needs accurate information about perf boundaries, thus provide the
+       * correct cpumask.
+       */
+       if (policy->shared_type == CPUFREQ_SHARED_TYPE_HW)
+               em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb,
+                                           policy->dependent_cpus);
+       else
+               em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb,
+                                           policy->cpus);
   </snippet>

Second proposal:

Another option could be for each driver to store internally the performance
dependencies and let the driver directly provide the correct cpumask for
any consumer.
Whilst this works fine for energy model (see above), it is not the case
(currently) for cpufreq_cooling, thus we would need to add a new interface for
it. That way the driver can call directly the registration function.
This seems to be possible since the CPUFreq core can skip to register
cpufreq_cooling (flag CPUFREQ_IS_COOLING_DEV).

In comparison with the first proposal this one is less scalable since each
driver will have to call the registration functions, while in some cases
the CPUFreq core could do it.

Any comments/preferences?

Many Thanks
Nicola

[1] https://lkml.org/lkml/2020/9/24/399
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-11-02 12:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 12:01 [PATCH v3 0/3] CPUFreq: Add support for cpu performance dependencies Nicola Mazzucato
2020-11-02 12:01 ` [PATCH v3 1/3] dt-bindings/opp: Update documentation for opp-shared Nicola Mazzucato
2020-11-02 12:01 ` [PATCH v3 2/3] opp/of: Allow empty opp-table with opp-shared Nicola Mazzucato
2020-11-03  5:01   ` Viresh Kumar
2020-11-04 17:54     ` Nicola Mazzucato
2020-11-05  4:41       ` Viresh Kumar
2020-11-16 11:45         ` Nicola Mazzucato
2020-11-02 12:01 ` Nicola Mazzucato [this message]
2020-11-06  9:20   ` [PATCH v3 3/3] [RFC] CPUFreq: Add support for cpu-perf-dependencies Viresh Kumar
2020-11-06 10:37     ` Lukasz Luba
2020-11-06 10:55       ` Viresh Kumar
2020-11-06 11:14         ` Lukasz Luba
2020-11-09  6:57           ` Viresh Kumar
2020-11-16 11:33             ` Lukasz Luba
2020-11-17 10:11               ` Viresh Kumar
2020-11-17 10:47                 ` Nicola Mazzucato
2020-11-17 10:53                   ` Viresh Kumar
2020-11-17 13:06                     ` Rafael J. Wysocki
2020-11-18  4:42                       ` Viresh Kumar
2020-11-18 12:00                         ` Rafael J. Wysocki
2020-11-19  6:40                           ` Viresh Kumar
2020-11-17 10:47                 ` Lukasz Luba
2020-11-17 10:55                   ` Viresh Kumar
2020-11-06  9:24   ` Viresh Kumar
2020-11-19  6:43   ` Viresh Kumar
2020-11-03 10:18 ` [PATCH v3 0/3] CPUFreq: Add support for cpu performance dependencies Viresh Kumar
2020-11-04 18:04   ` Nicola Mazzucato
2020-11-05 14:25     ` Vincent Guittot
2020-11-05 15:46       ` Ionela Voinescu

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=20201102120115.29993-4-nicola.mazzucato@arm.com \
    --to=nicola.mazzucato@arm.com \
    --cc=chris.redpath@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=morten.rasmussen@arm.com \
    --cc=nm@ti.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=vireshk@kernel.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;
as well as URLs for NNTP newsgroup(s).