]> xenbits.xensource.com Git - xen.git/commitdiff
xen/sched: Remove {init,destroy}_domain() interfaces
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 27 Feb 2018 16:48:19 +0000 (16:48 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 7 Mar 2018 16:00:37 +0000 (16:00 +0000)
These hooks have one single caller (sched_{init,destroy}_domain()
respectively) and are all identical (when implemented).

Previous changes have ensured that only real domains reach these functions, so
ASSERT() that system domains are not seen. Call sched_{alloc,free}_domdata()
directly, and handle d->sched_priv directly.

The net diffstat is:
  add/remove: 0/8 grow/shrink: 1/7 up/down: 7/-335 (-328)
  function                                     old     new   delta
  sched_destroy_domain                         130     137      +7
  sched_init_domain                            138     137      -1
  rt_dom_destroy                                 6       -      -6
  null_dom_destroy                               6       -      -6
  csched_dom_destroy                             9       -      -9
  csched2_dom_destroy                            9       -      -9
  sched_rtds_def                               264     248     -16
  sched_null_def                               264     248     -16
  sched_credit_def                             264     248     -16
  sched_credit2_def                            264     248     -16
  sched_arinc653_def                           264     248     -16
  ops                                          264     248     -16
  rt_dom_init                                   52       -     -52
  null_dom_init                                 52       -     -52
  csched_dom_init                               52       -     -52
  csched2_dom_init                              52       -     -52

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Meng Xu <mengxu@cis.upenn.edu>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/sched_arinc653.c
xen/common/sched_credit.c
xen/common/sched_credit2.c
xen/common/sched_null.c
xen/common/sched_rt.c
xen/common/schedule.c
xen/include/xen/sched-if.h

index 17e765d2cb677c2381847be2612e24c28c7c74b9..a4c6d00b818520de900895abeb5015c44b93db37 100644 (file)
@@ -712,9 +712,6 @@ static const struct scheduler sched_arinc653_def = {
     .free_vdata     = a653sched_free_vdata,
     .alloc_vdata    = a653sched_alloc_vdata,
 
-    .init_domain    = NULL,
-    .destroy_domain = NULL,
-
     .insert_vcpu    = NULL,
     .remove_vcpu    = NULL,
 
index d9ae23dee3e329a9d21fcb6a8e7c6c9369c52636..7c40ee2d00584cd21a8401ab13b97d20adda04a3 100644 (file)
@@ -1292,35 +1292,12 @@ csched_alloc_domdata(const struct scheduler *ops, struct domain *dom)
     return sdom;
 }
 
-static int
-csched_dom_init(const struct scheduler *ops, struct domain *dom)
-{
-    struct csched_dom *sdom;
-
-    if ( is_idle_domain(dom) )
-        return 0;
-
-    sdom = csched_alloc_domdata(ops, dom);
-    if ( IS_ERR(sdom) )
-        return PTR_ERR(sdom);
-
-    dom->sched_priv = sdom;
-
-    return 0;
-}
-
 static void
 csched_free_domdata(const struct scheduler *ops, void *data)
 {
     xfree(data);
 }
 
-static void
-csched_dom_destroy(const struct scheduler *ops, struct domain *dom)
-{
-    csched_free_domdata(ops, CSCHED_DOM(dom));
-}
-
 /*
  * This is a O(n) optimized sort of the runq.
  *
@@ -2257,9 +2234,6 @@ static const struct scheduler sched_credit_def = {
     .sched_id       = XEN_SCHEDULER_CREDIT,
     .sched_data     = NULL,
 
-    .init_domain    = csched_dom_init,
-    .destroy_domain = csched_dom_destroy,
-
     .insert_vcpu    = csched_vcpu_insert,
     .remove_vcpu    = csched_vcpu_remove,
 
index 29a24d6cb60b17b5eae3aac3a10580f2b1aa7d8c..5a635e8c4ced3839156ecc813f7139b2cac793f0 100644 (file)
@@ -3035,23 +3035,6 @@ csched2_alloc_domdata(const struct scheduler *ops, struct domain *dom)
     return sdom;
 }
 
-static int
-csched2_dom_init(const struct scheduler *ops, struct domain *dom)
-{
-    struct csched2_dom *sdom;
-
-    if ( is_idle_domain(dom) )
-        return 0;
-
-    sdom = csched2_alloc_domdata(ops, dom);
-    if ( IS_ERR(sdom) )
-        return PTR_ERR(sdom);
-
-    dom->sched_priv = sdom;
-
-    return 0;
-}
-
 static void
 csched2_free_domdata(const struct scheduler *ops, void *data)
 {
@@ -3072,14 +3055,6 @@ csched2_free_domdata(const struct scheduler *ops, void *data)
     }
 }
 
-static void
-csched2_dom_destroy(const struct scheduler *ops, struct domain *dom)
-{
-    ASSERT(csched2_dom(dom)->nr_vcpus == 0);
-
-    csched2_free_domdata(ops, csched2_dom(dom));
-}
-
 static void
 csched2_vcpu_insert(const struct scheduler *ops, struct vcpu *vc)
 {
@@ -4016,9 +3991,6 @@ static const struct scheduler sched_credit2_def = {
     .sched_id       = XEN_SCHEDULER_CREDIT2,
     .sched_data     = NULL,
 
-    .init_domain    = csched2_dom_init,
-    .destroy_domain = csched2_dom_destroy,
-
     .insert_vcpu    = csched2_vcpu_insert,
     .remove_vcpu    = csched2_vcpu_remove,
 
index 4dd405b2e5c3d540062d8925b58c9c70c89b4f0d..58e306a7ea681db469ff5852ce02337b106d8272 100644 (file)
@@ -259,26 +259,6 @@ static void null_free_domdata(const struct scheduler *ops, void *data)
     }
 }
 
-static int null_dom_init(const struct scheduler *ops, struct domain *d)
-{
-    struct null_dom *ndom;
-
-    if ( is_idle_domain(d) )
-        return 0;
-
-    ndom = null_alloc_domdata(ops, d);
-    if ( IS_ERR(ndom) )
-        return PTR_ERR(ndom);
-
-    d->sched_priv = ndom;
-
-    return 0;
-}
-static void null_dom_destroy(const struct scheduler *ops, struct domain *d)
-{
-    null_free_domdata(ops, null_dom(d));
-}
-
 /*
  * vCPU to pCPU assignment and placement. This _only_ happens:
  *  - on insert,
@@ -923,9 +903,6 @@ const struct scheduler sched_null_def = {
     .alloc_domdata  = null_alloc_domdata,
     .free_domdata   = null_free_domdata,
 
-    .init_domain    = null_dom_init,
-    .destroy_domain = null_dom_destroy,
-
     .insert_vcpu    = null_vcpu_insert,
     .remove_vcpu    = null_vcpu_remove,
 
index e4ff5c19c979e16fb229dec53afcc64ce4b1b03c..1c72ea831d80808a093edd370a423ec42dad2eb1 100644 (file)
@@ -851,30 +851,6 @@ rt_free_domdata(const struct scheduler *ops, void *data)
     }
 }
 
-static int
-rt_dom_init(const struct scheduler *ops, struct domain *dom)
-{
-    struct rt_dom *sdom;
-
-    /* IDLE Domain does not link on rt_private */
-    if ( is_idle_domain(dom) )
-        return 0;
-
-    sdom = rt_alloc_domdata(ops, dom);
-    if ( IS_ERR(sdom) )
-        return PTR_ERR(sdom);
-
-    dom->sched_priv = sdom;
-
-    return 0;
-}
-
-static void
-rt_dom_destroy(const struct scheduler *ops, struct domain *dom)
-{
-    rt_free_domdata(ops, rt_dom(dom));
-}
-
 static void *
 rt_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd)
 {
@@ -1585,8 +1561,6 @@ static const struct scheduler sched_rtds_def = {
     .deinit_pdata   = rt_deinit_pdata,
     .alloc_domdata  = rt_alloc_domdata,
     .free_domdata   = rt_free_domdata,
-    .init_domain    = rt_dom_init,
-    .destroy_domain = rt_dom_destroy,
     .alloc_vdata    = rt_alloc_vdata,
     .free_vdata     = rt_free_vdata,
     .insert_vcpu    = rt_vcpu_insert,
index 08a31b69de7b30c1b316462d7fd7fe9823cee266..5f596f0ec6ea5e77462ebb0fe3f1889ceb87e16c 100644 (file)
@@ -413,25 +413,37 @@ void sched_destroy_vcpu(struct vcpu *v)
 
 int sched_init_domain(struct domain *d, int poolid)
 {
+    void *sdom;
     int ret;
 
     ASSERT(d->cpupool == NULL);
+    ASSERT(d->domain_id < DOMID_FIRST_RESERVED);
 
     if ( (ret = cpupool_add_domain(d, poolid)) )
         return ret;
 
     SCHED_STAT_CRANK(dom_init);
     TRACE_1D(TRC_SCHED_DOM_ADD, d->domain_id);
-    return SCHED_OP(dom_scheduler(d), init_domain, d);
+
+    sdom = sched_alloc_domdata(dom_scheduler(d), d);
+    if ( IS_ERR(sdom) )
+        return PTR_ERR(sdom);
+
+    d->sched_priv = sdom;
+
+    return 0;
 }
 
 void sched_destroy_domain(struct domain *d)
 {
     ASSERT(d->cpupool != NULL || is_idle_domain(d));
+    ASSERT(d->domain_id < DOMID_FIRST_RESERVED);
 
     SCHED_STAT_CRANK(dom_destroy);
     TRACE_1D(TRC_SCHED_DOM_REM, d->domain_id);
-    SCHED_OP(dom_scheduler(d), destroy_domain, d);
+
+    sched_free_domdata(dom_scheduler(d), d->sched_priv);
+    d->sched_priv = NULL;
 
     cpupool_rm_domain(d);
 }
index 56e7d0c2b2116cccb0196bcc7e48666e8005eafa..48952425faae0727a3f35fa297aee3368e7aa53d 100644 (file)
@@ -155,9 +155,6 @@ struct scheduler {
     void         (*switch_sched)   (struct scheduler *, unsigned int,
                                     void *, void *);
 
-    int          (*init_domain)    (const struct scheduler *, struct domain *);
-    void         (*destroy_domain) (const struct scheduler *, struct domain *);
-
     /* Activate / deactivate vcpus in a cpu pool */
     void         (*insert_vcpu)    (const struct scheduler *, struct vcpu *);
     void         (*remove_vcpu)    (const struct scheduler *, struct vcpu *);