All of lore.kernel.org
 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 3/5] arm64: Introduce get_cpu_ops() helper function
Date: Wed, 18 Mar 2020 13:22:20 +1100	[thread overview]
Message-ID: <b3f944f0-d595-eb73-6b16-06f6c0c79b95@redhat.com> (raw)
In-Reply-To: <20200317104833.GE8831@lakrids.cambridge.arm.com>

On 3/17/20 9:48 PM, Mark Rutland wrote:
> On Wed, Feb 26, 2020 at 11:23:54AM +1100, Gavin Shan wrote:
>> This introduces get_cpu_ops() to return the CPU operations according to
>> the given CPU index. For now, it simply returns the @cpu_ops[cpu] as
>> before. So it shouldn't introduce any functional changes.
>>
>> Signed-off-by: Gavin Shan <gshan@redhat.com>
> 
> Generally this looks good to me; I like that it simplifies the cases
> where we get the ops repeatedly today.
> 
> I have one comment below.
> 
>> @@ -383,6 +392,7 @@ void cpu_die(void)
>>   void cpu_die_early(void)
>>   {
>>   	int cpu = smp_processor_id();
>> +	const struct cpu_operations *ops = get_cpu_ops(cpu);
>>   
>>   	pr_crit("CPU%d: will not boot\n", cpu);
>>   
>> @@ -392,8 +402,8 @@ void cpu_die_early(void)
>>   #ifdef CONFIG_HOTPLUG_CPU
>>   	update_cpu_boot_status(CPU_KILL_ME);
>>   	/* Check if we can park ourselves */
>> -	if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_die)
>> -		cpu_ops[cpu]->cpu_die(cpu);
>> +	if (ops && ops->cpu_die)
>> +		ops->cpu_die(cpu);
>>   #endif
> 
> Can we factor this out the die logic into a helper:
> 
> | static void __cpu_try_die(int cpu)
> | {
> | #ifdef CONFIG_HOTPLUG_CPU
> | 	const struct cpu_operations *ops = get_cpu_ops(cpu);
> | 	if (ops && ops->cpu_die)
> | 		ops->cpu_die(cpu);
> | #endif
> | }
> 
> ... with cpu_die_early() having:
> 
> | if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) {
> | 	update_cpu_boot_status(CPU_KILL_ME);
> |	__cpu_try_die(cpu);
> | }
> 
> ... and likewise in ipi_cpu_crash_stop(), without the
> update_cpu_boot_status() ...
> 
>> @@ -855,6 +870,10 @@ static atomic_t waiting_for_crash_ipi = ATOMIC_INIT(0);
>>   
>>   static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
>>   {
>> +#ifdef CONFIG_HOTPLUG_CPU
>> +	const struct cpu_operations *ops;
>> +#endif
> 
> ... where this can go ...
> 
>> +
>>   #ifdef CONFIG_KEXEC_CORE
>>   	crash_save_cpu(regs, cpu);
>>   
>> @@ -864,8 +883,9 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
>>   	sdei_mask_local_cpu();
>>   
>>   #ifdef CONFIG_HOTPLUG_CPU
>> -	if (cpu_ops[cpu]->cpu_die)
>> -		cpu_ops[cpu]->cpu_die(cpu);
>> +	ops = get_cpu_ops(cpu);
>> +	if (ops->cpu_die)
>> +		ops->cpu_die(cpu);
>>   #endif
> 
> ... and this can be:
> 
> | if (IS_ENABLED(CONFIG_HOTPLUG_CPU))
> | 	__cpu_try_die(cpu);
> 
> Thanks,
> Mark.
> 

Thanks for the detailed comments. With it, the code looks cleaner. I'll
have this in next revision (v5).

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  2:22 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 [this message]
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
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=b3f944f0-d595-eb73-6b16-06f6c0c79b95@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.