From: Michael Bringmann <hidden> Date: 2018-10-15 19:57:15
migration/memory: This patch adds a new pseries hotplug action
for CPU and memory operations, PSERIES_HP_ELOG_ACTION_READD_MULTIPLE.
This is a variant of the READD operation which performs the action
upon multiple instances of the resource at one time. The operation
is to be triggered by device-tree analysis of updates by RTAS events
analyzed by 'migation_store' during post-migration processing. It
will be used for memory updates, initially.
Signed-off-by: Michael Bringmann <redacted>
---
Changes in v05:
-- Provide dlpar_memory_readd_helper routine to compress some common code
Changes in v04:
-- Move init of 'lmb->internal_flags' in init_drmem_v2_lmbs to
previous patch.
-- Pull in implementation of dlpar_memory_readd_multiple() to go
with operation flag.
---
arch/powerpc/include/asm/rtas.h | 1 +
arch/powerpc/platforms/pseries/hotplug-memory.c | 44 ++++++++++++++++++++---
2 files changed, 39 insertions(+), 6 deletions(-)
@@ -541,6 +549,23 @@ static int dlpar_memory_readd_by_index(u32 drc_index)returnrc;}+staticintdlpar_memory_readd_multiple(void)+{+structdrmem_lmb*lmb;+intrc;++pr_info("Attempting to update multiple LMBs\n");++for_each_drmem_lmb(lmb){+if(drmem_lmb_update(lmb)){+rc=dlpar_memory_readd_helper(lmb);+drmem_remove_lmb_update(lmb);+}+}++returnrc;+}
This leaves rc potentially uninitialised.
What should the result be in that case, -EINVAL ?
I will force it to be zero (0). Failure to find anything
to update is not an error.
cheers
Thanks.
--
Michael W. Bringmann
Linux Technology Center
IBM Corporation
Tie-Line 363-5196
External: (512) 286-5196
Cell: (512) 466-0650
mwb@linux.vnet.ibm.com
@@ -541,6 +549,23 @@ static int dlpar_memory_readd_by_index(u32 drc_index)returnrc;}+staticintdlpar_memory_readd_multiple(void)+{+structdrmem_lmb*lmb;+intrc;++pr_info("Attempting to update multiple LMBs\n");++for_each_drmem_lmb(lmb){+if(drmem_lmb_update(lmb)){+rc=dlpar_memory_readd_helper(lmb);+drmem_remove_lmb_update(lmb);+}+}++returnrc;+}
This leaves rc potentially uninitialised.
What should the result be in that case, -EINVAL ?
On another note if there are multiple LMBs to update the value of rc only reflects the final dlpar_memory_readd_helper() call.
Correct. But that is what happens when we compress common code
between two disparate uses i.e. updating memory association after
a migration event with no reporting mechanism other than the console
log, vs re-adding a single LMB by index for the purposes of DLPAR / drmgr.
I could discard the return value from dlpar_memory_readd_helper entirely
in this function and just return 0, but in my experience, once errors start
to occur in memory dlpar ops, they tend to keep on occurring, so I was
returning the last one. We could also make the code smart enough to
capture and return the first/last non-zero return code. I didn't believe
that the frequency of errors for this operation warranted the overhead.
-Tyrel
Michael
--
Michael W. Bringmann
Linux Technology Center
IBM Corporation
Tie-Line 363-5196
External: (512) 286-5196
Cell: (512) 466-0650
mwb@linux.vnet.ibm.com
@@ -541,6 +549,23 @@ static int dlpar_memory_readd_by_index(u32 drc_index)returnrc;}+staticintdlpar_memory_readd_multiple(void)+{+structdrmem_lmb*lmb;+intrc;++pr_info("Attempting to update multiple LMBs\n");++for_each_drmem_lmb(lmb){+if(drmem_lmb_update(lmb)){+rc=dlpar_memory_readd_helper(lmb);+drmem_remove_lmb_update(lmb);+}+}++returnrc;+}
This leaves rc potentially uninitialised.
What should the result be in that case, -EINVAL ?
On another note if there are multiple LMBs to update the value of rc only reflects the final dlpar_memory_readd_helper() call.
Correct. But that is what happens when we compress common code
between two disparate uses i.e. updating memory association after
a migration event with no reporting mechanism other than the console
log, vs re-adding a single LMB by index for the purposes of DLPAR / drmgr.
I could discard the return value from dlpar_memory_readd_helper entirely
in this function and just return 0, but in my experience, once errors start
to occur in memory dlpar ops, they tend to keep on occurring, so I was
returning the last one. We could also make the code smart enough to
capture and return the first/last non-zero return code. I didn't believe
that the frequency of errors for this operation warranted the overhead.
The actual error value is probably not very relevant.
But dropping errors entirely is almost always a bad idea.
So I think you should at least return an error if any error occurred,
that way at least an error will be returned up to the caller(s).
Something like:
int rc;
rc = 0;
for_each_drmem_lmb(lmb) {
if (drmem_lmb_update(lmb)) {
rc |= dlpar_memory_readd_helper(lmb);
drmem_remove_lmb_update(lmb);
}
}
if (rc)
return -EIO;
cheers
@@ -541,6 +549,23 @@ static int dlpar_memory_readd_by_index(u32 drc_index)returnrc;}+staticintdlpar_memory_readd_multiple(void)+{+structdrmem_lmb*lmb;+intrc;++pr_info("Attempting to update multiple LMBs\n");++for_each_drmem_lmb(lmb){+if(drmem_lmb_update(lmb)){+rc=dlpar_memory_readd_helper(lmb);+drmem_remove_lmb_update(lmb);+}+}++returnrc;+}
This leaves rc potentially uninitialised.
What should the result be in that case, -EINVAL ?
On another note if there are multiple LMBs to update the value of rc only reflects the final dlpar_memory_readd_helper() call.
Correct. But that is what happens when we compress common code
between two disparate uses i.e. updating memory association after
a migration event with no reporting mechanism other than the console
log, vs re-adding a single LMB by index for the purposes of DLPAR / drmgr.
I could discard the return value from dlpar_memory_readd_helper entirely
in this function and just return 0, but in my experience, once errors start
to occur in memory dlpar ops, they tend to keep on occurring, so I was
returning the last one. We could also make the code smart enough to
capture and return the first/last non-zero return code. I didn't believe
that the frequency of errors for this operation warranted the overhead.
The actual error value is probably not very relevant.
But dropping errors entirely is almost always a bad idea.
So I think you should at least return an error if any error occurred,
that way at least an error will be returned up to the caller(s).
Something like:
int rc;
rc = 0;
for_each_drmem_lmb(lmb) {
if (drmem_lmb_update(lmb)) {
rc |= dlpar_memory_readd_helper(lmb);
drmem_remove_lmb_update(lmb);
}
}
if (rc)
return -EIO;
Okay.
cheers
Thanks.
--
Michael W. Bringmann
Linux Technology Center
IBM Corporation
Tie-Line 363-5196
External: (512) 286-5196
Cell: (512) 466-0650
mwb@linux.vnet.ibm.com