File powerpc-utils.one_cpu.patch of Package powerpc-utils.140
The drmgr command should not attempt to remove the last cpu from the system.
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Normally this would not be an issue as cpu remove operations are initiated
from the HMC and the HMC will not allow the last cpu to be removed. This
issue does arise when handling PRRN events and trying to update the affinity
on a partition that only has one cpu.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
src/drmgr/drslot_chrp_cpu.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
Index: powerpc-utils-1.2.22/src/drmgr/drslot_chrp_cpu.c
===================================================================
--- powerpc-utils-1.2.22.orig/src/drmgr/drslot_chrp_cpu.c
+++ powerpc-utils-1.2.22/src/drmgr/drslot_chrp_cpu.c
@@ -60,6 +60,28 @@ get_cpu_by_name(struct dr_info *drinfo,
}
/**
+ * cpu_count
+ *
+ * Count the number of CPUs currently on the system
+ *
+ * @param dr_info cpu drc information
+ * @return number of cpus
+ */
+static int cpu_count(struct dr_info *dr_info)
+{
+ struct dr_node *cpu;
+ int cpu_count = 0;
+
+ for (cpu = dr_info->all_cpus; cpu; cpu = cpu->next) {
+ if (cpu->is_owned)
+ cpu_count++;
+ }
+
+ say(DEBUG, "Number of CPUs = %d\n", cpu_count);
+ return cpu_count;
+}
+
+/**
* get_available_cpu
*
* Find an available cpu to that we can add or remove, depending
@@ -201,6 +223,12 @@ remove_cpus(struct options *opts, struct
cpu = get_available_cpu(opts, dr_info);
if (!cpu)
break;
+
+ if (cpu_count(dr_info) == 1) {
+ say(WARN, "Cannot remove the last CPU\n");
+ rc = -1;
+ break;
+ }
/* cpu is invalid after release_cpu, so no recovery
* steps seem feasible. We could copy the cpu name