mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: rjw@rjwysocki.net, vincent.guittot@linaro.org,
	linux-kernel@vger.kernel.org,
	Chris Redpath <chris.redpath@linaro.org>,
	Quentin Perret <quentin.perret@linaro.org>,
	Amit Kucheria <amit.kucheria@linaro.org>,
	Nicolas Dechesne <nicolas.dechesne@linaro.org>,
	Niklas Cassel <niklas.cassel@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH 4/4] base/drivers/topology: Default dmpis-mhz if they are not set in DT
Date: Tue, 30 Oct 2018 09:39:56 +0100	[thread overview]
Message-ID: <39cacba7-07e7-b06b-1502-0dc4496c58a8@linaro.org> (raw)
In-Reply-To: <20181030071313.rq2d4cmfrla5boc7@vireshk-i7>

On 30/10/2018 08:13, Viresh Kumar wrote:
> On 29-10-18, 17:23, Daniel Lezcano wrote:
>> In the case of assymetric SoC with the same micro-architecture, we
>> have a group of CPUs with smaller OPPs than the other group. One
>> example is the 96boards dragonboard 820c. There is no dmips/MHz
>> difference between both groups, so no need to specify the values in
>> the DT. Unfortunately, without these defined, there is no scaling
>> capacity comutation triggered, so we need to write
>> 'capacity-dmips-mhz' for each CPU with the same value in order to
>> force the scaled capacity computation.
>>
>> Fix this by setting a default capacity to SCHED_CAPACITY_SCALE, if no
>> 'capacity-dmips-mhz' is defined in the DT.
>>
>> This was tested on db820c:
>>  - specified values in the DT (correct results)
>>  - partial values defined in the DT (error + fallback to defaults)
>>  - no specified values in the DT (correct results)
>>
>> correct results are:
>>   cat /sys/devices/system/cpu/cpu*/cpu_capacity
>>    758
>>    758
>>   1024
>>   1024
>>
>>   ... respectively for CPU0, CPU1, CPU2 and CPU3.
>>
>> That reflects the capacity for the max frequencies 1593600 and 2150400.
>>
>> Cc: Chris Redpath <chris.redpath@linaro.org>
>> Cc: Quentin Perret <quentin.perret@linaro.org>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> Cc: Amit Kucheria <amit.kucheria@linaro.org>
>> Cc: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>> Cc: Niklas Cassel <niklas.cassel@linaro.org>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
>>  drivers/base/arch_topology.c | 27 ++++++++++++++++++++++++++-
>>  1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
>> index 7311641..7d594a6 100644
>> --- a/drivers/base/arch_topology.c
>> +++ b/drivers/base/arch_topology.c
>> @@ -205,6 +205,21 @@ static struct notifier_block init_cpu_capacity_notifier = {
>>  	.notifier_call = init_cpu_capacity_callback,
>>  };
>>  
>> +static int topology_set_default_capacity(void)
>> +{
>> +	int cpu;
>> +
>> +	raw_capacity = kzalloc(num_possible_cpus() * sizeof(*raw_capacity),
>> +			       GFP_KERNEL);
> 
> kmalloc ?
> 
>> +	if (!raw_capacity)
>> +		return -ENOMEM;
>> +
>> +	for_each_possible_cpu(cpu)
>> +		raw_capacity[cpu] = SCHED_CAPACITY_SCALE;
> 
> It makes it look as if it is important to set default values to
> SCHED_CAPACITY_SCALE while that is not the case. Maybe add a comment
> that all CPUs are assumed to have same capacity now. Maybe initialize
> to 1 instead ? Not sure if that would be better or not.

SCHED_CAPACITY_SCALE is the default value in this file.

eg.

DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE
...
pr_err("cpu_capacity: partial information: fallback to 1024 for all
CPUs\n");
...

So I prefer to use the SCHED_CAPACITY_SCALE for consistency.

>> +
>> +	return 0;
>> +}
>> +
>>  static int __init register_cpufreq_notifier(void)
>>  {
>>  	int ret;
>> @@ -214,9 +229,19 @@ static int __init register_cpufreq_notifier(void)
>>  	 * until we have the necessary code to parse the cpu capacity, so
>>  	 * skip registering cpufreq notifier.
>>  	 */
>> -	if (!acpi_disabled || !raw_capacity)
>> +	if (!acpi_disabled)
>>  		return -EINVAL;
>>  
>> +	if (!raw_capacity) {
>> +
>> +		pr_info("cpu_capacity: No capacity defined in DT, set default "
>> +		       "values to %ld\n", SCHED_CAPACITY_SCALE);
> 
> So we will end up doing this also for the case where the DT is
> partially filled with the capacity info and we already printed error
> messages for it. Should we really do that ?

Yes, it is the default behavior as stated in the documentation:

"capacity-dmips-mhz property is all-or-nothing: if it is specified for a
cpu node, it has to be specified for every other cpu nodes, or the
system will fall back to the default capacity value for every CPU."

and also in the error message:

pr_err("cpu_capacity: partial information: fallback to 1024 for all
CPUs\n");

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2018-10-30  8:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 16:23 [PATCH 1/4] base/drivers/arch_topology: Remove useless check Daniel Lezcano
2018-10-29 16:23 ` [PATCH 2/4] base/drivers/arch_topology: Replace mutex with READ_ONCE / WRITE_ONCE Daniel Lezcano
2018-10-30  5:57   ` Viresh Kumar
2018-11-23 13:58   ` Sudeep Holla
2018-11-23 16:04     ` Daniel Lezcano
2018-11-23 16:20       ` Sudeep Holla
2018-11-23 16:54         ` Daniel Lezcano
2018-11-26  8:27           ` Juri Lelli
2018-11-26  8:39             ` Daniel Lezcano
2018-11-26 11:33             ` Mark Brown
2018-10-29 16:23 ` [PATCH 3/4] base/drivers/topology: Move instructions in the error path Daniel Lezcano
2018-10-30  6:12   ` Viresh Kumar
2018-10-30  8:32     ` Daniel Lezcano
2018-10-29 16:23 ` [PATCH 4/4] base/drivers/topology: Default dmpis-mhz if they are not set in DT Daniel Lezcano
2018-10-30  7:13   ` Viresh Kumar
2018-10-30  8:39     ` Daniel Lezcano [this message]
2018-10-30  8:45       ` Viresh Kumar
2018-10-30  8:58   ` Viresh Kumar
2018-11-21 22:12     ` Daniel Lezcano
2018-11-22  4:29       ` Viresh Kumar
2018-11-22 10:29         ` Daniel Lezcano
2018-11-22 10:31           ` Viresh Kumar
2018-11-22 10:32             ` Daniel Lezcano
2018-11-22 11:11             ` Daniel Lezcano
2018-10-30  5:50 ` [PATCH 1/4] base/drivers/arch_topology: Remove useless check Viresh Kumar
2018-10-30  7:55   ` Daniel Lezcano
2018-10-30  8:33     ` Viresh Kumar
2018-10-30 13:35       ` Daniel Lezcano
2018-10-31  4:27         ` 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=39cacba7-07e7-b06b-1502-0dc4496c58a8@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=amit.kucheria@linaro.org \
    --cc=chris.redpath@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.dechesne@linaro.org \
    --cc=niklas.cassel@linaro.org \
    --cc=quentin.perret@linaro.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --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

all inboxes | Powered by JetHome®