On Mon, Jun 14, 2021 at 10:09:59PM +0530, Aneesh Kumar K.V wrote: > The associativity details of the newly added resourced are collected from > the hypervisor via "ibm,configure-connector" rtas call. Update the numa > distance details of the newly added numa node after the above call. In > later patch we will remove updating NUMA distance when we are looking > for node id from associativity array. > > Signed-off-by: Aneesh Kumar K.V > --- > arch/powerpc/mm/numa.c | 41 +++++++++++++++++++ > arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 + > .../platforms/pseries/hotplug-memory.c | 2 + > arch/powerpc/platforms/pseries/pseries.h | 1 + > 4 files changed, 46 insertions(+) > > diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c > index 192067991f8a..fec47981c1ef 100644 > --- a/arch/powerpc/mm/numa.c > +++ b/arch/powerpc/mm/numa.c > @@ -287,6 +287,47 @@ int of_node_to_nid(struct device_node *device) > } > EXPORT_SYMBOL(of_node_to_nid); > > +static void __initialize_form1_numa_distance(const __be32 *associativity) > +{ > + int i, nid; > + > + if (of_read_number(associativity, 1) >= primary_domain_index) { > + nid = of_read_number(&associativity[primary_domain_index], 1); > + > + for (i = 0; i < max_domain_index; i++) { > + const __be32 *entry; > + > + entry = &associativity[be32_to_cpu(distance_ref_points[i])]; > + distance_lookup_table[nid][i] = of_read_number(entry, 1); > + } > + } > +} This logic is almost identicaly to initialize_distance_lookup_table() - it would be good if they could be consolidated, so it's clear that coldplugged and hotplugged nodes are parsing the NUMA information in the same way. > + > +static void initialize_form1_numa_distance(struct device_node *node) > +{ > + const __be32 *associativity; > + > + associativity = of_get_associativity(node); > + if (!associativity) > + return; > + > + __initialize_form1_numa_distance(associativity); > + return; > +} > + > +/* > + * Used to update distance information w.r.t newly added node. > + */ > +void update_numa_distance(struct device_node *node) > +{ > + if (affinity_form == FORM0_AFFINITY) > + return; > + else if (affinity_form == FORM1_AFFINITY) { > + initialize_form1_numa_distance(node); > + return; > + } > +} > + > static int __init find_primary_domain_index(void) > { > int index; > diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c > index 7e970f81d8ff..778b6ab35f0d 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c > +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c > @@ -498,6 +498,8 @@ static ssize_t dlpar_cpu_add(u32 drc_index) > return saved_rc; > } > > + update_numa_distance(dn); > + > rc = dlpar_online_cpu(dn); > if (rc) { > saved_rc = rc; > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c > index 8377f1f7c78e..0e602c3b01ea 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c > @@ -180,6 +180,8 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) > return -ENODEV; > } > > + update_numa_distance(lmb_node); > + > dr_node = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); > if (!dr_node) { > dlpar_free_cc_nodes(lmb_node); > diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h > index 1f051a786fb3..663a0859cf13 100644 > --- a/arch/powerpc/platforms/pseries/pseries.h > +++ b/arch/powerpc/platforms/pseries/pseries.h > @@ -113,4 +113,5 @@ extern u32 pseries_security_flavor; > void pseries_setup_security_mitigations(void); > void pseries_lpar_read_hblkrm_characteristics(void); > > +void update_numa_distance(struct device_node *node); > #endif /* _PSERIES_PSERIES_H */ -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson