From: Thiago Jung Bauermann <bauerman@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: Gautham R Shenoy <ego@linux.vnet.ibm.com>,
Michael Bringmann <mwb@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Subject: Re: [PATCH v3] powerpc/pseries: Only wait for dying CPU after call to rtas_stop_self()
Date: Wed, 17 Apr 2019 22:00:09 -0300 [thread overview]
Message-ID: <87r2a0jffq.fsf@morokweng.localdomain> (raw)
In-Reply-To: <1555389147.okxbj1prw2.astroid@bobo.none>
Hello Nick,
Thank you very much for reviewing this patch!
Nicholas Piggin <npiggin@gmail.com> writes:
> Thiago Jung Bauermann's on April 11, 2019 9:08 am:
>>
>> Thiago Jung Bauermann <bauerman@linux.ibm.com> writes:
>>
>>> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
>>> index 97feb6e79f1a..ac6dc35ab829 100644
>>> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
>>> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
>>> @@ -214,13 +214,22 @@ static void pseries_cpu_die(unsigned int cpu)
>>> msleep(1);
>>> }
>>> } else if (get_preferred_offline_state(cpu) == CPU_STATE_OFFLINE) {
>>> + /*
>>> + * If the current state is not offline yet, it means that the
>>> + * dying CPU (which is either in pseries_mach_cpu_die() or in
>>> + * the process of getting there) didn't have a chance yet to
>>> + * call rtas_stop_self() and therefore it's too early to query
>>> + * if the CPU is stopped.
>>> + */
>>> + spin_event_timeout(get_cpu_current_state(cpu) == CPU_STATE_OFFLINE,
>>> + 100000, 100);
>
> If the CPU state does not go to offline here, you should give up and
> return online, right? Otherwise I think query-cpu-stopped-state can
> get confused by CPUs in idle and you get a false positive.
Can it get confused? My impression from reading the definition for
query-cpu-stopped-state in the PAPR is that it will simply return a
CPU_status value of 2 in that case, meaning that "the processor thread
is not in the RTAS stopped state", but I don't know much about this.
> That race can still happen, we would really need a sequence count check
> over current CPU state to ensure we got a race-free qcss value, but at
> least a check here should make the race implausible to hit.
Actually, since rtas_stop_self() panics if the processor fails to stop
and also since callers of pseries_cpu_die()¹ already assume that it is
going to succeed in stopping the CPU (given that the function returns
void and can't signal an error), a more straightforward way of
eliminating the race is to simply do this:
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 97feb6e79f1a..2331a609f48f 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -215,7 +215,7 @@ static void pseries_cpu_die(unsigned int cpu)
}
} else if (get_preferred_offline_state(cpu) == CPU_STATE_OFFLINE) {
- for (tries = 0; tries < 25; tries++) {
+ while (true) {
cpu_status = smp_query_cpu_stopped(pcpu);
if (cpu_status == QCSS_STOPPED ||
cpu_status == QCSS_HARDWARE_ERROR)
What do you think?
--
Thiago Jung Bauermann
IBM Linux Technology Center
¹ dlpar_offline_cpu() and takedown_cpu() in generic code
next prev parent reply other threads:[~2019-04-18 1:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 19:35 [PATCH v3] powerpc/pseries: Only wait for dying CPU after call to rtas_stop_self() Thiago Jung Bauermann
2019-03-12 9:32 ` Gautham R Shenoy
2019-03-12 16:30 ` Thiago Jung Bauermann
2019-04-10 23:08 ` Thiago Jung Bauermann
2019-04-16 4:36 ` Nicholas Piggin
2019-04-18 1:00 ` Thiago Jung Bauermann [this message]
2019-04-18 1:55 ` Nicholas Piggin
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=87r2a0jffq.fsf@morokweng.localdomain \
--to=bauerman@linux.ibm.com \
--cc=ego@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mwb@linux.vnet.ibm.com \
--cc=npiggin@gmail.com \
--cc=tyreld@linux.vnet.ibm.com \
/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).