Note: (Only patch 3 changes from v3)
Abdul reported a warning on a shared lpar.
"WARNING: workqueue cpumask: online intersect > possible intersect".
This is because per node workqueue possible mask is set very early in the
boot process even before the system was querying the home node
associativity. However per node workqueue online cpumask gets updated
dynamically. Hence there is a chance when per node workqueue online cpumask
is a superset of per node workqueue possible mask.
Link for v1: https://patchwork.ozlabs.org/patch/1151658
Changelog: v1->v2
- Handled comments from Nathan Lynch.
Link for v2: http://lkml.kernel.org/r/20190829055023.6171-1-srikar@linux.vnet.ibm.com
Changelog: v2->v3
- Handled comments from Nathan Lynch.
Link for v3: http://lkml.kernel.org/r/20190906135020.19772-1-srikar@linux.vnet.ibm.com
Changelog: v3->v4
- Added a warning as suggested by Nathan Lynch.
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Abdul Haleem <redacted>
Cc: Nathan Lynch <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Satheesh Rajendran <redacted>
Srikar Dronamraju (5):
powerpc/vphn: Check for error from hcall_vphn
powerpc/numa: Handle extra hcall_vphn error cases
powerpc/numa: Use cpu node map of first sibling thread
powerpc/numa: Early request for home node associativity
powerpc/numa: Remove late request for home node associativity
arch/powerpc/include/asm/topology.h | 4 --
arch/powerpc/kernel/smp.c | 5 --
arch/powerpc/mm/numa.c | 99 ++++++++++++++++++++++++++---------
arch/powerpc/platforms/pseries/vphn.c | 3 +-
4 files changed, 77 insertions(+), 34 deletions(-)
--
1.8.3.1
Currently code handles H_FUNCTION, H_SUCCESS, H_HARDWARE return codes.
However hcall_vphn can return other return codes. Now it also handles
H_PARAMETER return code. Also the rest return codes are handled under the
default case.
Signed-off-by: Srikar Dronamraju <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Nathan Lynch <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Satheesh Rajendran <redacted>
Reported-by: Abdul Haleem <redacted>
---
Changelog (v2->v1):
Handled comments from Nathan:
- Split patch from patch 1.
- Corrected a problem where I missed calling stop_topology_update().
- Using pr_err_ratelimited instead of printk.
arch/powerpc/mm/numa.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
Currently code handles H_FUNCTION, H_SUCCESS, H_HARDWARE return codes.
However hcall_vphn can return other return codes. Now it also handles
H_PARAMETER return code. Also the rest return codes are handled under the
default case.
Reviewed-by: Nathan Lynch <redacted>
However:
+ case H_PARAMETER:
+ pr_err_ratelimited("hcall_vphn() was passed an invalid parameter. "
+ "Disabling polling...\n");
Consider including the bad parameter value in the message?
All the sibling threads of a core have to be part of the same node.
To ensure that all the sibling threads map to the same node, always
lookup/update the cpu-to-node map of the first thread in the core.
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog: v3->v4
As suggested by Nathan, add a warning while mapping offline cpu.
arch/powerpc/mm/numa.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
@@ -467,15 +467,20 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb)*/staticintnuma_setup_cpu(unsignedlonglcpu){-intnid=NUMA_NO_NODE;structdevice_node*cpu;+intfcpu=cpu_first_thread_sibling(lcpu);+intnid=NUMA_NO_NODE;/**Ifavalidcpu-to-nodemappingisalreadyavailable,useit*directlyinsteadofqueryingthefirmware,sinceitrepresents*themostrecentmappingnotifiedtousbytheplatform(eg:VPHN).+*Sincecpu_to_nodebindingremainsthesameforallthreadsinthe+*core.Ifavalidcpu-to-nodemappingisalreadyavailable,for+*thefirstthreadinthecore,useit.*/-if((nid=numa_cpu_lookup_table[lcpu])>=0){+nid=numa_cpu_lookup_table[fcpu];+if(nid>=0){map_cpu_to_node(lcpu,nid);returnnid;}
@@ -496,6 +501,19 @@ static int numa_setup_cpu(unsigned long lcpu)if(nid<0||!node_possible(nid))nid=first_online_node;+/*+*Updateforthefirstthreadofthecore.Allthreadsofacore+*havetobepartofthesamenode.Thisnotonlyavoidsquerying+*foreveryotherthreadinthecore,butalwaysavoidsacase+*wherevirtualnodeassociativitychangecausessubsequentthreads+*ofacoretobeassociatedwithdifferentnid.Howeveriffirst+*threadisalreadyonline,expectittohaveavalidmapping.+*/+if(fcpu!=lcpu){+WARN_ON(cpu_online(fcpu));+map_cpu_to_node(fcpu,nid);+}+map_cpu_to_node(lcpu,nid);of_node_put(cpu);out:
All the sibling threads of a core have to be part of the same node.
To ensure that all the sibling threads map to the same node, always
lookup/update the cpu-to-node map of the first thread in the core.
There is no value in unpacking associativity, if
H_HOME_NODE_ASSOCIATIVITY hcall has returned an error.
Signed-off-by: Srikar Dronamraju <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Nathan Lynch <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Satheesh Rajendran <redacted>
Reported-by: Abdul Haleem <redacted>
---
Changelog (v2->v1):
- Split the patch into 2(Suggested by Nathan).
arch/powerpc/platforms/pseries/vphn.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Currently the kernel detects if its running on a shared lpar platform
and requests home node associativity before the scheduler sched_domains
are setup. However between the time NUMA setup is initialized and the
request for home node associativity, workqueue initializes its per node
cpumask. The per node workqueue possible cpumask may turn invalid
after home node associativity resulting in weird situations like
workqueue possible cpumask being a subset of workqueue online cpumask.
This can be fixed by requesting home node associativity earlier just
before NUMA setup. However at the NUMA setup time, kernel may not be in
a position to detect if its running on a shared lpar platform. So
request for home node associativity and if the request fails, fallback
on the device tree property.
Signed-off-by: Srikar Dronamraju <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Nathan Lynch <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Satheesh Rajendran <redacted>
Reported-by: Abdul Haleem <redacted>
---
Changelog (v1->v2):
- Handled comments from Nathan Lynch
* Dont depend on pacas to be setup for the hwid
Changelog (v2->v3):
- Handled comments from Nathan Lynch
* Use first thread of the core for cpu-to-node map.
* get hardware-id in numa_setup_cpu
arch/powerpc/mm/numa.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
@@ -461,13 +461,27 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb)returnnid;}+staticintvphn_get_nid(longhwid)+{+__be32associativity[VPHN_ASSOC_BUFSIZE]={0};+longrc;++rc=hcall_vphn(hwid,VPHN_FLAG_VCPU,associativity);+if(rc==H_SUCCESS)+returnassociativity_to_nid(associativity);++returnNUMA_NO_NODE;+}+/**Figureouttowhichdomainacpubelongsandstickitthere.+*cpu_to_phys_idisonlyvalidbetweensmp_setup_cpu_maps()and+*smp_setup_pacas().Ifcalledoutsidethiswindow,setget_hwidtotrue.*Returntheidofthedomainused.*/-staticintnuma_setup_cpu(unsignedlonglcpu)+staticintnuma_setup_cpu(unsignedlonglcpu,boolget_hwid){-structdevice_node*cpu;+structdevice_node*cpu=NULL;intfcpu=cpu_first_thread_sibling(lcpu);intnid=NUMA_NO_NODE;
@@ -485,6 +499,27 @@ static int numa_setup_cpu(unsigned long lcpu)returnnid;}+/*+*Onasharedlpar,devicetreewillnothavenodeassociativity.+*Atthistimelppaca,orits__old_statusfieldmaynotbe+*updated.Hencekernelcannotdetectifitsonasharedlpar.So+*requestanexplicitassociativityirrespectiveofwhetherthe+*lparissharedordedicated.Usethedevicetreepropertyasa+*fallback.+*/+if(firmware_has_feature(FW_FEATURE_VPHN)){+longhwid;++if(get_hwid)+hwid=get_hard_smp_processor_id(lcpu);+else+hwid=cpu_to_phys_id[lcpu];+nid=vphn_get_nid(hwid);+}++if(nid!=NUMA_NO_NODE)+gotoout_present;+cpu=of_get_cpu_node(lcpu,NULL);if(!cpu){
@@ -496,6 +531,7 @@ static int numa_setup_cpu(unsigned long lcpu)}nid=of_node_to_nid_single(cpu);+of_node_put(cpu);out_present:if(nid<0||!node_possible(nid))
@@ -515,7 +551,6 @@ static int numa_setup_cpu(unsigned long lcpu)}map_cpu_to_node(lcpu,nid);-of_node_put(cpu);out:returnnid;}
@@ -546,7 +581,7 @@ static int ppc_numa_cpu_prepare(unsigned int cpu){intnid;-nid=numa_setup_cpu(cpu);+nid=numa_setup_cpu(cpu,true);verify_cpu_node_mapping(cpu,nid);return0;}
Currently the kernel detects if its running on a shared lpar platform
and requests home node associativity before the scheduler sched_domains
are setup. However between the time NUMA setup is initialized and the
request for home node associativity, workqueue initializes its per node
cpumask. The per node workqueue possible cpumask may turn invalid
after home node associativity resulting in weird situations like
workqueue possible cpumask being a subset of workqueue online cpumask.
This can be fixed by requesting home node associativity earlier just
before NUMA setup. However at the NUMA setup time, kernel may not be in
a position to detect if its running on a shared lpar platform. So
request for home node associativity and if the request fails, fallback
on the device tree property.
With commit ("powerpc/numa: Early request for home node associativity"),
commit 2ea626306810 ("powerpc/topology: Get topology for shared
processors at boot") which was requesting home node associativity
becomes redundant.
Hence remove the late request for home node associativity.
Signed-off-by: Srikar Dronamraju <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Nathan Lynch <redacted>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Satheesh Rajendran <redacted>
Reported-by: Abdul Haleem <redacted>
---
arch/powerpc/include/asm/topology.h | 4 ----
arch/powerpc/kernel/smp.c | 5 -----
arch/powerpc/mm/numa.c | 9 ---------
3 files changed, 18 deletions(-)
With commit ("powerpc/numa: Early request for home node associativity"),
commit 2ea626306810 ("powerpc/topology: Get topology for shared
processors at boot") which was requesting home node associativity
becomes redundant.
Hence remove the late request for home node associativity.
Hi Srikar,
Srikar Dronamraju [off-list ref] writes:
Abdul reported a warning on a shared lpar.
"WARNING: workqueue cpumask: online intersect > possible intersect".
This is because per node workqueue possible mask is set very early in the
boot process even before the system was querying the home node
associativity. However per node workqueue online cpumask gets updated
dynamically. Hence there is a chance when per node workqueue online cpumask
is a superset of per node workqueue possible mask.
Sorry for the delay in following up on these. The series looks good to
me, and I've given it a little testing with LPM and DLPAR. I've also
verified that the cpu assignments occur early as intended on an LPAR
where that workqueue warning had been triggered.
Abdul reported a warning on a shared lpar.
"WARNING: workqueue cpumask: online intersect > possible intersect".
This is because per node workqueue possible mask is set very early in the
boot process even before the system was querying the home node
associativity. However per node workqueue online cpumask gets updated
dynamically. Hence there is a chance when per node workqueue online cpumask
is a superset of per node workqueue possible mask.
Sorry for the delay in following up on these. The series looks good to
me, and I've given it a little testing with LPM and DLPAR. I've also
verified that the cpu assignments occur early as intended on an LPAR
where that workqueue warning had been triggered.
If this is applied I think we can remove about 500 loc from numa.c. Once
splpar cpu-node assignments are done in the same sequence as with
dedicated processor mode, numa_update_cpu_topology() and related code
becomes unneeded.
Michael?
Abdul reported a warning on a shared lpar.
"WARNING: workqueue cpumask: online intersect > possible intersect".
This is because per node workqueue possible mask is set very early in the
boot process even before the system was querying the home node
associativity. However per node workqueue online cpumask gets updated
dynamically. Hence there is a chance when per node workqueue online cpumask
is a superset of per node workqueue possible mask.
Sorry for the delay in following up on these. The series looks good to
me, and I've given it a little testing with LPM and DLPAR. I've also
verified that the cpu assignments occur early as intended on an LPAR
where that workqueue warning had been triggered.
If this is applied I think we can remove about 500 loc from numa.c. Once
splpar cpu-node assignments are done in the same sequence as with
dedicated processor mode, numa_update_cpu_topology() and related code
becomes unneeded.
Since its 2 months since version 5 was posted and more than a month since
Nathan added his reviewed-by, can you please let us know if there is any
reason why this patchset has not been applied yet. Or do let me know if have
any further comments.
--
Thanks and Regards
Srikar Dronamraju