diff mbox series

[v2,37/48] xen/sched: carve out freeing sched_unit memory into dedicated function

Message ID 20190809145833.1020-38-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series xen: add core scheduling support | expand

Commit Message

Jürgen Groß Aug. 9, 2019, 2:58 p.m. UTC
We'll need a way to free a sched_unit structure without side effects
in a later patch.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
RFC V2: new patch, carved out from RFC V1 patch 49
---
 xen/common/schedule.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index fe7ab1b4de..be5f03b626 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -348,26 +348,10 @@  static void sched_spin_unlock_double(spinlock_t *lock1, spinlock_t *lock2,
     spin_unlock_irqrestore(lock1, flags);
 }
 
-static void sched_free_unit(struct sched_unit *unit, struct vcpu *v)
+static void sched_free_unit_mem(struct sched_unit *unit)
 {
     struct sched_unit *prev_unit;
     struct domain *d = unit->domain;
-    struct vcpu *vunit;
-    unsigned int cnt = 0;
-
-    /* Don't count to be released vcpu, might be not in vcpu list yet. */
-    for_each_sched_unit_vcpu ( unit, vunit )
-        if ( vunit != v )
-            cnt++;
-
-    v->sched_unit = NULL;
-    unit->runstate_cnt[v->runstate.state]--;
-
-    if ( cnt )
-        return;
-
-    if ( unit->vcpu_list == v )
-        unit->vcpu_list = v->next_in_list;
 
     if ( d->sched_unit_list == unit )
         d->sched_unit_list = unit->next_in_list;
@@ -390,6 +374,26 @@  static void sched_free_unit(struct sched_unit *unit, struct vcpu *v)
     xfree(unit);
 }
 
+static void sched_free_unit(struct sched_unit *unit, struct vcpu *v)
+{
+    struct vcpu *vunit;
+    unsigned int cnt = 0;
+
+    /* Don't count to be released vcpu, might be not in vcpu list yet. */
+    for_each_sched_unit_vcpu ( unit, vunit )
+        if ( vunit != v )
+            cnt++;
+
+    v->sched_unit = NULL;
+    unit->runstate_cnt[v->runstate.state]--;
+
+    if ( unit->vcpu_list == v )
+        unit->vcpu_list = v->next_in_list;
+
+    if ( !cnt )
+        sched_free_unit_mem(unit);
+}
+
 static void sched_unit_add_vcpu(struct sched_unit *unit, struct vcpu *v)
 {
     v->sched_unit = unit;