Skip to contentSkip to conversation

spapr: Correct reference count on spapr-cpu-core

PATCH Applied Sam Bobroff 2 participants 2 messages Aug 30, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr: Correct reference count on spapr-cpu-core

spapr_init_cpus() currently creates spapr-cpu-core objects via object_new() and setting their realized property to true. This leaves their reference count at two, because object_new() adds an initial reference and the realization attaches them to a default parent object which also increments the reference count.

This causes a problem if one of these cores is hot unplugged: no delete event is generated for it because it's reference count doesn't reach zero when it is detached from it's parent.

Correct this by adding a call to object_unref() in spapr_init_cpus().

---
 hw/ppc/spapr.c | 2 ++
 1 file changed, 2 insertions(+)
hw/ppc/spapr.c +2 -0
index 0d032a1ad0..fbb00f0c56 100644
@@ -2502,6 +2502,8 @@ static void spapr_init_cpus(sPAPRMachineState *spapr)
             object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID,
                                     &error_fatal);
             object_property_set_bool(core, true, "realized", &error_fatal);
+
+            object_unref(core);
         }
     }
 }
Signature · 1 line
2.16.1.74.g9b0b1f47b
Applied
#1 lore raw

On Thu, Aug 30, 2018 at 03:54:40PM +1000, Sam Bobroff wrote:
11;rgb:ffff/ffff/ffff> spapr_init_cpus() currently creates spapr-cpu-core objects via

Quoted 5 lines

object_new() and setting their realized property to true. This leaves their reference count at two, because object_new() adds an initial reference and the realization attaches them to a default parent object which also increments the reference count.

Quoted 7 lines

This causes a problem if one of these cores is hot unplugged: no delete event is generated for it because it's reference count doesn't reach zero when it is detached from it's parent.

Correct this by adding a call to object_unref() in spapr_init_cpus().

Applied to ppc-for-3.1.

Quoted 17 lines
---
 hw/ppc/spapr.c | 2 ++
 1 file changed, 2 insertions(+)
hw/ppc/spapr.c +2 -0
index 0d032a1ad0..fbb00f0c56 100644
@@ -2502,6 +2502,8 @@ static void spapr_init_cpus(sPAPRMachineState *spapr)
             object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID,
                                     &error_fatal);
             object_property_set_bool(core, true, "realized", &error_fatal);
+
+            object_unref(core);
         }
     }
 }
Signature · 4 lines
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