linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gshan@redhat.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: lorenzo.pieralisi@arm.com, catalin.marinas@arm.com,
	robin.murphy@arm.com, shan.gavin@gmail.com, sudeep.holla@arm.com,
	will@kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 4/5] arm64: Remove CPU operations dereferencing array
Date: Thu, 19 Mar 2020 09:53:15 +1100	[thread overview]
Message-ID: <ec463176-d62d-9f59-130c-4d6beb6e1270@redhat.com> (raw)
In-Reply-To: <a92d9a3a-7bc3-81f0-f4a3-9e1da3623e16@redhat.com>

On 3/18/20 2:53 PM, Gavin Shan wrote:
> On 3/17/20 9:56 PM, Mark Rutland wrote:
>> On Wed, Feb 26, 2020 at 11:23:55AM +1100, Gavin Shan wrote:
>>> One CPU operations is maintained through array @cpu_ops[NR_CPUS]. 2KB
>>> memory is consumed when CONFIG_NR_CPUS is set to 256. It seems too
>>> much memory has been used for this. Also, all CPUs must use same CPU
>>> operations and we shouldn't bring up the broken CPU, as Lorenzo Pieralisi
>>> pointed out.
>>
>> I suspect there might be some pre PSCIv0.2 platforms where the boot CPU
>> doesn't have PSCI, but others do. On those platforms, this could be
>> because CPU0 cannot be hotplugged out, and we must avoid doing so.
>>
>> Can you check the in-kernel DTs to see if any of those exist?
>>
>> Other than that, I agree that mandating uniformity is the best approach
>> here.
>>
> 
> Thanks for the comments, Mark. There are platforms where the CPU#0 and other
> CPUs have different "enable-method" specified. More specificly, CPU#0 doesn't
> have "enable-method" while other CPUs have "psci" specified:
> 
>     lg/lg1312.dtsi
>     lg/lg1313.dtsi
>     mediatek/mt2712e.dtsi
> 
> In order to support two enable methods, I think we have two options here:
> (1) Revert the code to what we had in v2. Two bits consumed by one CPU,
> which is taken as index to a CPU operation array. The code can be found in
> link [1] (2) Two CPU operation pointers are maintained. One is used to track
> the CPU#0's operations and other one is for other cpus.
> 
> [1] https://patchwork.kernel.org/patch/11363745/
> 
> Please let me know which one is better.
> 

Mark, I plan to post a new revision to have option#2 after thinking
about it: we will have two pointers to track the operations for boot cpu
and the secondary CPUs separately. the consumed memory isn't scaled up to
the configured CPU number. So I think it's better than option#1, which
uses two-bits as index to CPU operation array.

Thanks,
Gavin

>>>   int __init init_cpu_ops(int cpu)
>>>   {
>>> -    const char *enable_method = cpu_read_enable_method(cpu);
>>> -
>>> -    if (!enable_method)
>>> -        return -ENODEV;
>>> +    const struct cpu_operations *ops = get_cpu_method(cpu);
>>> -    cpu_ops[cpu] = cpu_get_ops(enable_method);
>>> -    if (!cpu_ops[cpu]) {
>>> -        pr_warn("Unsupported enable-method: %s\n", enable_method);
>>> +    if (!ops)
>>>           return -EOPNOTSUPP;
>>> +
>>> +    /* Update global CPU operations if it's not initialized yet */
>>> +    if (!cpu_ops) {
>>> +        cpu_ops = ops;
>>> +        return 0;
>>> +    }
>>
>> As above, I don't think this is quite right. If we're going to mandate
>> uniformity, we should init the ops from the boot CPU, and then verify
>> that every other CPU matches that. The initialization of the global ops
>> should not be conditional.> 
> I think you're correct because CPU#0's "enable-method" can be unspecified.
> In this case, the CPU#0's operations will be set to same one as other CPUs,
> which isn't correct. I will see how to handle this comments when the above
> comments is resolved. This might become invalid after the above comments get
> resolved.
> 
> Thanks,
> Gavin
> 


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

  reply	other threads:[~2020-03-18 22:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26  0:23 [PATCH v4 0/5] arm64: Dereference CPU operations indirectly Gavin Shan
2020-02-26  0:23 ` [PATCH v4 1/5] arm64: Declare ACPI parking protocol CPU operation if needed Gavin Shan
2020-03-17 10:28   ` Mark Rutland
2020-03-18  2:06     ` Gavin Shan
2020-02-26  0:23 ` [PATCH v4 2/5] arm64: Rename cpu_read_ops() to init_cpu_ops() Gavin Shan
2020-03-17 10:20   ` Mark Rutland
2020-02-26  0:23 ` [PATCH v4 3/5] arm64: Introduce get_cpu_ops() helper function Gavin Shan
2020-03-17 10:48   ` Mark Rutland
2020-03-18  2:22     ` Gavin Shan
2020-02-26  0:23 ` [PATCH v4 4/5] arm64: Remove CPU operations dereferencing array Gavin Shan
2020-03-17 10:56   ` Mark Rutland
2020-03-18  3:53     ` Gavin Shan
2020-03-18 22:53       ` Gavin Shan [this message]
2020-02-26  0:23 ` [PATCH v4 5/5] arm64: Remove argument @cpu of get_cpu_ops() Gavin Shan
2020-03-16  3:05 ` [PATCH v4 0/5] arm64: Dereference CPU operations indirectly Gavin Shan

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=ec463176-d62d-9f59-130c-4d6beb6e1270@redhat.com \
    --to=gshan@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=shan.gavin@gmail.com \
    --cc=sudeep.holla@arm.com \
    --cc=will@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).