Re: [PATCH v4 2/2] powerpc/pseries: Implement indexed-count hotplug memory remove
flat view
From: Michael Roth <hidden>
Date: 2016-08-23 23:03:28
Quoting Sahil Mehta (2016-08-01 12:23:16)
Indexed-count remove for memory hotplug guarantees that a contiguous block of <count> lmbs beginning at a specified <index> will be unassigned (NOT that <count> lmbs will be removed). Because of Qemu's per-DIMM memory management, the removal of a contiguous block of memory currently requires a series of individual calls. Indexed-count remove reduces this series into a single call. =
Signed-off-by: Sahil Mehta <redacted>
---
v2: -use u32s drc_index and count instead of u32 ic[]
in dlpar_memory
v3: -add logic to handle invalid drc_index input
v4: -none
=arch/powerpc/platforms/pseries/hotplug-memory.c | 90 +++++++++++++++++=
++++++
1 file changed, 90 insertions(+) =
quoted hunk ↗ jump to hunk
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/power=
pc/platforms/pseries/hotplug-memory.c
quoted hunk ↗ jump to hunk
index 2d4ceb3..dd5eb38 100644--- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c@@ -503,6 +503,92 @@ static int dlpar_memory_remove_by_index(u32 drc_inde=
x, struct property *prop)
return rc; } =
quoted hunk ↗ jump to hunk
+static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index, + struct property *prop) +{ + struct of_drconf_cell *lmbs; + u32 num_lmbs, *p; + int i, rc, start_lmb_found; + int lmbs_available =3D 0, start_index =3D 0, end_index; + + pr_info("Attempting to hot-remove %u LMB(s) at %x\n", + lmbs_to_remove, drc_index); + + if (lmbs_to_remove =3D=3D 0) + return -EINVAL; + + p =3D prop->value; + num_lmbs =3D *p++; + lmbs =3D (struct of_drconf_cell *)p; + start_lmb_found =3D 0; + + /* Navigate to drc_index */ + while (start_index < num_lmbs) { + if (lmbs[start_index].drc_index =3D=3D drc_index) { + start_lmb_found =3D 1; + break; + } + + start_index++; + } + + if (!start_lmb_found) + return -EINVAL; + + end_index =3D start_index + lmbs_to_remove; + + /* Validate that there are enough LMBs to satisfy the request */ + for (i =3D start_index; i < end_index; i++) { + if (lmbs[i].flags & DRCONF_MEM_RESERVED) + break; + + lmbs_available++; + } + + if (lmbs_available < lmbs_to_remove) + return -EINVAL; + + for (i =3D 0; i < end_index; i++) {
Shouldn't this be i =3D start_index? Otherwise it seems we'd attempt to satisfy the request using LMBs outside of the requested range.
quoted hunk ↗ jump to hunk
+ if (!(lmbs[i].flags & DRCONF_MEM_ASSIGNED)) + continue; + + rc =3D dlpar_remove_lmb(&lmbs[i]); + if (rc) + break; + + lmbs[i].reserved =3D 1; + } + + if (rc) { + pr_err("Memory indexed-count-remove failed, adding any re=
moved LMBs\n");
quoted hunk ↗ jump to hunk
+ + for (i =3D start_index; i < end_index; i++) { + if (!lmbs[i].reserved) + continue; + + rc =3D dlpar_add_lmb(&lmbs[i]); + if (rc) + pr_err("Failed to add LMB, drc index %x\n=
",
quoted hunk ↗ jump to hunk
+ be32_to_cpu(lmbs[i].drc_index)); + + lmbs[i].reserved =3D 0; + } + rc =3D -EINVAL; + } else { + for (i =3D start_index; i < end_index; i++) { + if (!lmbs[i].reserved) + continue; + + pr_info("Memory at %llx (drc index %x) was hot-re=
moved\n",
quoted hunk ↗ jump to hunk
+ lmbs[i].base_addr, lmbs[i].drc_index); + + lmbs[i].reserved =3D 0; + } + } + + return rc; +} + #else static inline int pseries_remove_memblock(unsigned long base, unsigned int memblock_size)@@ -829,6 +915,10 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog) } else if (hp_elog->id_type =3D=3D PSERIES_HP_ELOG_ID_DRC=
_INDEX) { drc_index =3D hp_elog->_drc_u.drc_index;
rc =3D dlpar_memory_remove_by_index(drc_index, pr=op);
+ } else if (hp_elog->id_type =3D=3D PSERIES_HP_ELOG_ID_DRC=
_IC) {quoted hunk ↗ jump to hunk
+ count =3D hp_elog->_drc_u.indexed_count[0]; + drc_index =3D hp_elog->_drc_u.indexed_count[1]; + rc =3D dlpar_memory_remove_by_ic(count, drc_index=
, prop);
} else {
rc =3D -EINVAL;
}
=_______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev