Re: [RFC v5 6/6] migration/memory: Update memory for assoc changes
This patch was intended to apply the necessary changes for the 'ibm,dynamic-memory[-v2]' properties. Before the advent of the LMB representation, that code took up a lot more space. At this point, it has shrunk to only one line of unique change. I was hoping to include it here rather than create another patch. But that can be done. Michael On 05/22/2018 04:11 PM, Thomas Falcon wrote: > On 05/21/2018 12:52 PM, Michael Bringmann wrote: >> migration/memory: This patch adds more recognition for changes to >> the associativity of memory blocks described by the device-tree >> properties and updates local and general kernel data structures to >> reflect those changes. These differences may include: >> >> * Evaluating 'ibm,dynamic-memory' properties when processing the >> topology of LPARS in Post Migration events. Previous efforts >> only recognized whether a memory block's assignment had changed >> in the property. Changes here include checking the aa_index >> values for each drc_index of the old/new LMBs and to 'readd' >> any block for which the setting has changed. >> >> * In an LPAR migration scenario, the "ibm,associativity-lookup-arrays" >> property may change. In the event that a row of the array differs, >> locate all assigned memory blocks with that 'aa_index' and 're-add' >> them to the system memory block data structures. In the process of >> the 're-add', the system routines will update the corresponding entry >> for the memory in the LMB structures and any other relevant kernel >> data structures. >> >> * Extend the previous work for the 'ibm,associativity-lookup-array' >> and 'ibm,dynamic-memory' properties to support the property >> 'ibm,dynamic-memory-v2' by means of the DRMEM LMB interpretation >> code. >> >> Signed-off-by: Michael Bringmann >> --- >> Changes in RFC: >> -- Simplify code to update memory nodes during mobility checks. >> -- Reuse code from DRMEM changes to scan for LMBs when updating >> aa_index >> -- Combine common code for properties 'ibm,dynamic-memory' and >> 'ibm,dynamic-memory-v2' after integrating DRMEM features. >> -- Rearrange patches to co-locate memory property-related changes. >> -- Use new paired list iterator for the drmem info arrays. >> -- Use direct calls to add/remove memory from the update drconf >> function as those operations are only intended for user DLPAR >> ops, and should not occur during Migration reconfig notifier >> changes. >> -- Correct processing bug in processing of ibm,associativity-lookup-arrays >> -- Rebase to 4.17-rc5 kernel >> -- Apply minor code cleanups >> --- >> arch/powerpc/platforms/pseries/hotplug-memory.c | 153 >> ++- >> 1 file changed, 121 insertions(+), 32 deletions(-) >> >> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c >> b/arch/powerpc/platforms/pseries/hotplug-memory.c >> index c1578f5..ac329aa 100644 >> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c >> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c >> @@ -994,13 +994,11 @@ static int pseries_add_mem_node(struct device_node *np) >> return (ret < 0) ? -EINVAL : 0; >> } >> >> -static int pseries_update_drconf_memory(struct of_reconfig_data *pr) >> +static int pseries_update_drconf_memory(struct drmem_lmb_info *new_dinfo) >> { >> -struct of_drconf_cell_v1 *new_drmem, *old_drmem; >> +struct drmem_lmb *old_lmb, *new_lmb; >> unsigned long memblock_size; >> -u32 entries; >> -__be32 *p; >> -int i, rc = -EINVAL; >> +int rc = 0; >> >> if (rtas_hp_event) >> return 0; >> @@ -1009,42 +1007,124 @@ static int pseries_update_drconf_memory(struct >> of_reconfig_data *pr) >> if (!memblock_size) >> return -EINVAL; >> >> -p = (__be32 *) pr->old_prop->value; >> -if (!p) >> -return -EINVAL; >> +/* Arrays should have the same size and DRC indexes */ >> +for_each_pair_drmem_lmb(drmem_info, old_lmb, new_dinfo, new_lmb) { >> >> -/* The first int of the property is the number of lmb's described >> - * by the property. This is followed by an array of of_drconf_cell >> - * entries. Get the number of entries and skip to the array of >> - * of_drconf_cell's. >> - */ >> -entries = be32_to_cpu(*p++); >> -old_drmem = (struct of_drconf_cell_v1 *)p; >> - >> -p = (__be32 *)pr->prop->value; >> -p++; >> -new_drmem = (struct of_drconf_cell_v1 *)p; >> +if (new_lmb->drc_index != old_lmb->drc_index) >> +continue; >> >> -for (i = 0; i < entries; i++) { >> -if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) && >> -(!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) >> { >> +if ((old_lmb->flags & DRCONF_MEM_ASSIGNED) && >> +(!(new_lmb->flags & DRCONF_MEM_ASSIGNED))) { >> rc = pseries_remove_memblock( >> -
[RFC v5 6/6] migration/memory: Update memory for assoc changes
migration/memory: This patch adds more recognition for changes to the associativity of memory blocks described by the device-tree properties and updates local and general kernel data structures to reflect those changes. These differences may include: * Evaluating 'ibm,dynamic-memory' properties when processing the topology of LPARS in Post Migration events. Previous efforts only recognized whether a memory block's assignment had changed in the property. Changes here include checking the aa_index values for each drc_index of the old/new LMBs and to 'readd' any block for which the setting has changed. * In an LPAR migration scenario, the "ibm,associativity-lookup-arrays" property may change. In the event that a row of the array differs, locate all assigned memory blocks with that 'aa_index' and 're-add' them to the system memory block data structures. In the process of the 're-add', the system routines will update the corresponding entry for the memory in the LMB structures and any other relevant kernel data structures. * Extend the previous work for the 'ibm,associativity-lookup-array' and 'ibm,dynamic-memory' properties to support the property 'ibm,dynamic-memory-v2' by means of the DRMEM LMB interpretation code. Signed-off-by: Michael Bringmann --- Changes in RFC: -- Simplify code to update memory nodes during mobility checks. -- Reuse code from DRMEM changes to scan for LMBs when updating aa_index -- Combine common code for properties 'ibm,dynamic-memory' and 'ibm,dynamic-memory-v2' after integrating DRMEM features. -- Rearrange patches to co-locate memory property-related changes. -- Use new paired list iterator for the drmem info arrays. -- Use direct calls to add/remove memory from the update drconf function as those operations are only intended for user DLPAR ops, and should not occur during Migration reconfig notifier changes. -- Correct processing bug in processing of ibm,associativity-lookup-arrays -- Rebase to 4.17-rc5 kernel -- Apply minor code cleanups --- arch/powerpc/platforms/pseries/hotplug-memory.c | 153 ++- 1 file changed, 121 insertions(+), 32 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c1578f5..ac329aa 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -994,13 +994,11 @@ static int pseries_add_mem_node(struct device_node *np) return (ret < 0) ? -EINVAL : 0; } -static int pseries_update_drconf_memory(struct of_reconfig_data *pr) +static int pseries_update_drconf_memory(struct drmem_lmb_info *new_dinfo) { - struct of_drconf_cell_v1 *new_drmem, *old_drmem; + struct drmem_lmb *old_lmb, *new_lmb; unsigned long memblock_size; - u32 entries; - __be32 *p; - int i, rc = -EINVAL; + int rc = 0; if (rtas_hp_event) return 0; @@ -1009,42 +1007,124 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) if (!memblock_size) return -EINVAL; - p = (__be32 *) pr->old_prop->value; - if (!p) - return -EINVAL; + /* Arrays should have the same size and DRC indexes */ + for_each_pair_drmem_lmb(drmem_info, old_lmb, new_dinfo, new_lmb) { - /* The first int of the property is the number of lmb's described -* by the property. This is followed by an array of of_drconf_cell -* entries. Get the number of entries and skip to the array of -* of_drconf_cell's. -*/ - entries = be32_to_cpu(*p++); - old_drmem = (struct of_drconf_cell_v1 *)p; - - p = (__be32 *)pr->prop->value; - p++; - new_drmem = (struct of_drconf_cell_v1 *)p; + if (new_lmb->drc_index != old_lmb->drc_index) + continue; - for (i = 0; i < entries; i++) { - if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) && - (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) { + if ((old_lmb->flags & DRCONF_MEM_ASSIGNED) && + (!(new_lmb->flags & DRCONF_MEM_ASSIGNED))) { rc = pseries_remove_memblock( - be64_to_cpu(old_drmem[i].base_addr), -memblock_size); + old_lmb->base_addr, memblock_size); break; - } else if ((!(be32_to_cpu(old_drmem[i].flags) & - DRCONF_MEM_ASSIGNED)) && - (be32_to_cpu(new_drmem[i].flags) & - DRCONF_MEM_ASSIGNED)) { - rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr), - memblock_size); + } else if ((!(old_lmb->flags & D
Re: [RFC v5 6/6] migration/memory: Update memory for assoc changes
On 05/21/2018 12:52 PM, Michael Bringmann wrote: > migration/memory: This patch adds more recognition for changes to > the associativity of memory blocks described by the device-tree > properties and updates local and general kernel data structures to > reflect those changes. These differences may include: > > * Evaluating 'ibm,dynamic-memory' properties when processing the > topology of LPARS in Post Migration events. Previous efforts > only recognized whether a memory block's assignment had changed > in the property. Changes here include checking the aa_index > values for each drc_index of the old/new LMBs and to 'readd' > any block for which the setting has changed. > > * In an LPAR migration scenario, the "ibm,associativity-lookup-arrays" > property may change. In the event that a row of the array differs, > locate all assigned memory blocks with that 'aa_index' and 're-add' > them to the system memory block data structures. In the process of > the 're-add', the system routines will update the corresponding entry > for the memory in the LMB structures and any other relevant kernel > data structures. > > * Extend the previous work for the 'ibm,associativity-lookup-array' > and 'ibm,dynamic-memory' properties to support the property > 'ibm,dynamic-memory-v2' by means of the DRMEM LMB interpretation > code. > > Signed-off-by: Michael Bringmann > --- > Changes in RFC: > -- Simplify code to update memory nodes during mobility checks. > -- Reuse code from DRMEM changes to scan for LMBs when updating > aa_index > -- Combine common code for properties 'ibm,dynamic-memory' and > 'ibm,dynamic-memory-v2' after integrating DRMEM features. > -- Rearrange patches to co-locate memory property-related changes. > -- Use new paired list iterator for the drmem info arrays. > -- Use direct calls to add/remove memory from the update drconf > function as those operations are only intended for user DLPAR > ops, and should not occur during Migration reconfig notifier > changes. > -- Correct processing bug in processing of ibm,associativity-lookup-arrays > -- Rebase to 4.17-rc5 kernel > -- Apply minor code cleanups > --- > arch/powerpc/platforms/pseries/hotplug-memory.c | 153 > ++- > 1 file changed, 121 insertions(+), 32 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c > b/arch/powerpc/platforms/pseries/hotplug-memory.c > index c1578f5..ac329aa 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c > @@ -994,13 +994,11 @@ static int pseries_add_mem_node(struct device_node *np) > return (ret < 0) ? -EINVAL : 0; > } > > -static int pseries_update_drconf_memory(struct of_reconfig_data *pr) > +static int pseries_update_drconf_memory(struct drmem_lmb_info *new_dinfo) > { > - struct of_drconf_cell_v1 *new_drmem, *old_drmem; > + struct drmem_lmb *old_lmb, *new_lmb; > unsigned long memblock_size; > - u32 entries; > - __be32 *p; > - int i, rc = -EINVAL; > + int rc = 0; > > if (rtas_hp_event) > return 0; > @@ -1009,42 +1007,124 @@ static int pseries_update_drconf_memory(struct > of_reconfig_data *pr) > if (!memblock_size) > return -EINVAL; > > - p = (__be32 *) pr->old_prop->value; > - if (!p) > - return -EINVAL; > + /* Arrays should have the same size and DRC indexes */ > + for_each_pair_drmem_lmb(drmem_info, old_lmb, new_dinfo, new_lmb) { > > - /* The first int of the property is the number of lmb's described > - * by the property. This is followed by an array of of_drconf_cell > - * entries. Get the number of entries and skip to the array of > - * of_drconf_cell's. > - */ > - entries = be32_to_cpu(*p++); > - old_drmem = (struct of_drconf_cell_v1 *)p; > - > - p = (__be32 *)pr->prop->value; > - p++; > - new_drmem = (struct of_drconf_cell_v1 *)p; > + if (new_lmb->drc_index != old_lmb->drc_index) > + continue; > > - for (i = 0; i < entries; i++) { > - if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) && > - (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) > { > + if ((old_lmb->flags & DRCONF_MEM_ASSIGNED) && > + (!(new_lmb->flags & DRCONF_MEM_ASSIGNED))) { > rc = pseries_remove_memblock( > - be64_to_cpu(old_drmem[i].base_addr), > - memblock_size); > + old_lmb->base_addr, memblock_size); > break; > - } else if ((!(be32_to_cpu(old_drmem[i].flags) & > - DRCONF_MEM_ASSIGNED)) && > - (be32_to_cpu(new_drmem[i].flags) & > - DRCONF_MEM_ASSIGNED)) { > -
[RFC v5 6/6] migration/memory: Update memory for assoc changes
migration/memory: This patch adds more recognition for changes to the associativity of memory blocks described by the device-tree properties and updates local and general kernel data structures to reflect those changes. These differences may include: * Evaluating 'ibm,dynamic-memory' properties when processing the topology of LPARS in Post Migration events. Previous efforts only recognized whether a memory block's assignment had changed in the property. Changes here include checking the aa_index values for each drc_index of the old/new LMBs and to 'readd' any block for which the setting has changed. * In an LPAR migration scenario, the "ibm,associativity-lookup-arrays" property may change. In the event that a row of the array differs, locate all assigned memory blocks with that 'aa_index' and 're-add' them to the system memory block data structures. In the process of the 're-add', the system routines will update the corresponding entry for the memory in the LMB structures and any other relevant kernel data structures. * Extend the previous work for the 'ibm,associativity-lookup-array' and 'ibm,dynamic-memory' properties to support the property 'ibm,dynamic-memory-v2' by means of the DRMEM LMB interpretation code. Signed-off-by: Michael Bringmann --- Changes in RFC: -- Simplify code to update memory nodes during mobility checks. -- Reuse code from DRMEM changes to scan for LMBs when updating aa_index -- Combine common code for properties 'ibm,dynamic-memory' and 'ibm,dynamic-memory-v2' after integrating DRMEM features. -- Rearrange patches to co-locate memory property-related changes. -- Use new paired list iterator for the drmem info arrays. -- Use direct calls to add/remove memory from the update drconf function as those operations are only intended for user DLPAR ops, and should not occur during Migration reconfig notifier changes. -- Correct processing bug in processing of ibm,associativity-lookup-arrays -- Rebase to 4.17-rc5 kernel -- Apply minor code cleanups --- arch/powerpc/platforms/pseries/hotplug-memory.c | 153 ++- 1 file changed, 121 insertions(+), 32 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c1578f5..ac329aa 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -994,13 +994,11 @@ static int pseries_add_mem_node(struct device_node *np) return (ret < 0) ? -EINVAL : 0; } -static int pseries_update_drconf_memory(struct of_reconfig_data *pr) +static int pseries_update_drconf_memory(struct drmem_lmb_info *new_dinfo) { - struct of_drconf_cell_v1 *new_drmem, *old_drmem; + struct drmem_lmb *old_lmb, *new_lmb; unsigned long memblock_size; - u32 entries; - __be32 *p; - int i, rc = -EINVAL; + int rc = 0; if (rtas_hp_event) return 0; @@ -1009,42 +1007,124 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) if (!memblock_size) return -EINVAL; - p = (__be32 *) pr->old_prop->value; - if (!p) - return -EINVAL; + /* Arrays should have the same size and DRC indexes */ + for_each_pair_drmem_lmb(drmem_info, old_lmb, new_dinfo, new_lmb) { - /* The first int of the property is the number of lmb's described -* by the property. This is followed by an array of of_drconf_cell -* entries. Get the number of entries and skip to the array of -* of_drconf_cell's. -*/ - entries = be32_to_cpu(*p++); - old_drmem = (struct of_drconf_cell_v1 *)p; - - p = (__be32 *)pr->prop->value; - p++; - new_drmem = (struct of_drconf_cell_v1 *)p; + if (new_lmb->drc_index != old_lmb->drc_index) + continue; - for (i = 0; i < entries; i++) { - if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) && - (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) { + if ((old_lmb->flags & DRCONF_MEM_ASSIGNED) && + (!(new_lmb->flags & DRCONF_MEM_ASSIGNED))) { rc = pseries_remove_memblock( - be64_to_cpu(old_drmem[i].base_addr), -memblock_size); + old_lmb->base_addr, memblock_size); break; - } else if ((!(be32_to_cpu(old_drmem[i].flags) & - DRCONF_MEM_ASSIGNED)) && - (be32_to_cpu(new_drmem[i].flags) & - DRCONF_MEM_ASSIGNED)) { - rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr), - memblock_size); + } else if ((!(old_lmb->flags & D