linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Lynch <nathanl@linux.ibm.com>
To: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH v3 3/5] powerpc/numa: Use cpu node map of first sibling thread
Date: Thu, 12 Sep 2019 11:41:57 -0500	[thread overview]
Message-ID: <87ftl1qxey.fsf@linux.ibm.com> (raw)
In-Reply-To: <20190911165845.GA31643@linux.vnet.ibm.com>

Hi Srikar,

Srikar Dronamraju <srikar@linux.vnet.ibm.com> writes:
>> > @@ -496,6 +501,16 @@ static int numa_setup_cpu(unsigned long lcpu)
>> >  	if (nid < 0 || !node_possible(nid))
>> >  		nid = first_online_node;
>> >  
>> > +	/*
>> > +	 * Update for the first thread of the core. All threads of a core
>> > +	 * have to be part of the same node. This not only avoids querying
>> > +	 * for every other thread in the core, but always avoids a case
>> > +	 * where virtual node associativity change causes subsequent threads
>> > +	 * of a core to be associated with different nid.
>> > +	 */
>> > +	if (fcpu != lcpu)
>> > +		map_cpu_to_node(fcpu, nid);
>> > +
>> 
>> OK, I see that this somewhat addresses my concern above. But changing
>> this mapping for a remote cpu is unsafe except under specific
>> circumstances. I think this should first assert:
>> 
>> * numa_cpu_lookup_table[fcpu] == NUMA_NO_NODE
>> * cpu_online(fcpu) == false
>> 
>> to document and enforce the conditions that must hold for this to be OK.
>
> I do understand that we shouldn't be modifying the nid for a different cpu.
>
> We just checked above that the mapping for the first cpu doesnt exist.
> If the first cpu (or remote cpu as you coin it) was online, then its
> mapping should have existed and we return even before we come here.

I agree that is how the code will work with your change, and I'm fine
with simply warning if fcpu is offline.

The point is to make this rule more explicit in the code for the benefit
of future readers and to catch violations of it by future changes. There
is a fair amount of code remaining in this file and elsewhere in
arch/powerpc that was written under the impression that changing the
cpu-node relationship at runtime is OK.


> nid = numa_cpu_lookup_table[fcpu];
> if (nid >= 0) {
> 	map_cpu_to_node(lcpu, nid);
> 	return nid;
> }
>
> Currently numa_setup_cpus is only called at very early boot and in cpu
> hotplug. At hotplug time, the oneline of cpus is serialized. Right? Do we 
> see a chance of remote cpu changing its state as we set its nid here?
>
> Also lets say if we assert and for some unknown reason the assertion fails.
> How do we handle the failure case?  We cant get out without setting
> the nid. We cant continue setting the nid. Should we panic the system given
> that the check a few lines above is now turning out to be false? Probably
> no, as I think we can live with it.
>
> Any thoughts?

I think just WARN_ON(cpu_online(fcpu)) would be satisfactory. In my
experience, the downstream effects of violating this condition are
varied and quite difficult to debug. Seems only appropriate to emit a
warning and stack trace before the OS inevitably becomes unstable.

  reply	other threads:[~2019-09-12 16:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 13:50 [PATCH v3 0/5] Early node associativity Srikar Dronamraju
2019-09-06 13:50 ` [PATCH v3 1/5] powerpc/vphn: Check for error from hcall_vphn Srikar Dronamraju
2019-09-06 13:50 ` [PATCH v3 2/5] powerpc/numa: Handle extra hcall_vphn error cases Srikar Dronamraju
2019-09-06 13:50 ` [PATCH v3 3/5] powerpc/numa: Use cpu node map of first sibling thread Srikar Dronamraju
2019-09-11 14:48   ` Nathan Lynch
2019-09-11 17:05     ` Srikar Dronamraju
2019-09-12 16:41       ` Nathan Lynch [this message]
2019-09-12 17:23         ` Srikar Dronamraju
2019-09-12 18:15           ` Nathan Lynch
2019-09-13  5:44             ` Srikar Dronamraju
2019-09-06 13:50 ` [PATCH v3 4/5] powerpc/numa: Early request for home node associativity Srikar Dronamraju
2019-09-06 13:50 ` [PATCH v3 5/5] powerpc/numa: Remove late " Srikar Dronamraju

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=87ftl1qxey.fsf@linux.ibm.com \
    --to=nathanl@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=npiggin@gmail.com \
    --cc=sathnaga@linux.vnet.ibm.com \
    --cc=srikar@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).