diff mbox series

[RFC,V2,44/45] xen/sched: carve out freeing sched_item memory into dedicated function

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

Commit Message

Jürgen Groß May 6, 2019, 6:56 a.m. UTC
We'll need a way to free a sched_item 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 | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 49ed2b5900..4336f2bdf8 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -281,25 +281,10 @@  static void sched_spin_unlock_double(spinlock_t *lock1, spinlock_t *lock2,
     spin_unlock_irqrestore(lock1, flags);
 }
 
-static void sched_free_item(struct sched_item *item, struct vcpu *v)
+static void sched_free_item_mem(struct sched_item *item)
 {
     struct sched_item *prev_item;
     struct domain *d = item->domain;
-    struct vcpu *vitem;
-    unsigned int cnt = 0;
-
-    /* Don't count to be released vcpu, might be not in vcpu list yet. */
-    for_each_sched_item_vcpu ( item, vitem )
-        if ( vitem != v )
-            cnt++;
-
-    v->sched_item = NULL;
-
-    if ( cnt )
-        return;
-
-    if ( item->vcpu == v )
-        item->vcpu = v->next_in_list;
 
     if ( d->sched_item_list == item )
         d->sched_item_list = item->next_in_list;
@@ -323,6 +308,25 @@  static void sched_free_item(struct sched_item *item, struct vcpu *v)
     xfree(item);
 }
 
+static void sched_free_item(struct sched_item *item, struct vcpu *v)
+{
+    struct vcpu *vitem;
+    unsigned int cnt = 0;
+
+    /* Don't count to be released vcpu, might be not in vcpu list yet. */
+    for_each_sched_item_vcpu ( item, vitem )
+        if ( vitem != v )
+            cnt++;
+
+    v->sched_item = NULL;
+
+    if ( item->vcpu == v )
+        item->vcpu = v->next_in_list;
+
+    if ( !cnt )
+        sched_free_item_mem(item);
+}
+
 static void sched_item_add_vcpu(struct sched_item *item, struct vcpu *v)
 {
     v->sched_item = item;